avalon-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Peter Donald <dona...@apache.org>
Subject Re: cvs commit: jakarta-avalon/src/java/org/apache/avalon/framework/configuration Namespace.java DefaultConfigurationBuilder.java
Date Sun, 07 Oct 2001 10:13:45 GMT
Hi,

Whats does everyone think of moving this Namespace cache into 
ConfigurationHandler and making it contain weak references? As it stands now 
the Namespace objects can never be reclaimed by GC.

On Wed, 3 Oct 2001 02:26, bloritsch@apache.org wrote:
>   /**
>    * The namespace object is used in configuration schemas where namespace
> is * important.
>    *
>    * @author <a href="mailto:bloritsch@apache.org">Berin Loritsch</a>
>    */
>   public final class Namespace implements Serializable
>   {
>       private final static HashMap cache = new HashMap();
>
>       private final        String  m_prefix;
>       private final        String  m_uri;
>
>       /**
>        * Hide constructor so that the default factory methods must be used
>        */
>       private Namespace()
>       {
>           this("", "");
>       }
>
>       /**
>        * Create a Namespace object with a prefix and uri.
>        */
>       private Namespace( final String prefix, final String uri )
>       {
>           this.m_prefix = prefix;
>           this.m_uri = uri;
>       }
...snip...
>
>       /**
>        * Get an instance of the Namespace with separate prefix and uri
> strings *
>        * @param  prefix  The prefix portion of the namespace
>        * @param  uri     The uri portion of the namespace
>        *
>        * @return a Namespace object
>        */
>       public static final synchronized Namespace getNamespace( final String
> prefix, final String uri ) {
>           String pre = prefix;
>           String loc = uri;
>
>           if ( null == prefix )
>           {
>               pre = "";
>           }
>
>           if ( null == uri )
>           {
>               loc = "";
>           }
>
>           Namespace ns = (Namespace) Namespace.cache.get( pre + loc );
>
>           if ( null == ns )
>           {
>              ns = new Namespace( pre, loc );
>              Namespace.cache.put( pre + loc, ns );
>           }
>
>           return ns;
>       }
>   }
>

-- 
Cheers,

Pete

------------------------------------------------------
 Mark Twain: "In the real world, the right thing never
happens in the right place at the right time. It is 
the task of journalists and historians to rectify 
this error."
------------------------------------------------------

---------------------------------------------------------------------
To unsubscribe, e-mail: avalon-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: avalon-dev-help@jakarta.apache.org


Mime
View raw message