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, [EMAIL PROTECTED] wrote: > /** > * The namespace object is used in configuration schemas where namespace > is * important. > * > * @author <a href="mailto:[EMAIL PROTECTED]">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: [EMAIL PROTECTED] For additional commands, e-mail: [EMAIL PROTECTED]
