aicas logo Jamaica 3.4 release 8

com.sun.naming.internal
Class ResourceManager

java.lang.Object
  extended by com.sun.naming.internal.ResourceManager

public final class ResourceManager
extends Object

The ResourceManager class facilitates the reading of JNDI resource files.


Method Summary
static FactoryEnumeration getFactories(String propName, Hashtable env, Context ctx)
          Retrieves an enumeration of factory classes/object specified by a property.
static Object getFactory(String propName, Hashtable env, Context ctx, String classSuffix, String defaultPkgPrefix)
          Retrieves a factory from a list of packages specified in a property.
static Hashtable getInitialEnvironment(Hashtable env)
           
static String getProperty(String propName, Hashtable env, Context ctx, boolean concat)
          Retrieves the property from the environment, or from the provider resource file associated with the given context.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInitialEnvironment

public static Hashtable getInitialEnvironment(Hashtable env)
                                       throws NamingException
Throws:
NamingException

getProperty

public static String getProperty(String propName,
                                 Hashtable env,
                                 Context ctx,
                                 boolean concat)
                          throws NamingException
Retrieves the property from the environment, or from the provider resource file associated with the given context. The environment may in turn contain values that come from applet parameters, system properties, or application resource files. If concat is true and both the environment and the provider resource file contain the property, the two values are concatenated (with a ':' separator). Returns null if no value is found.

Parameters:
propName - The non-null property name
env - The possibly null environment properties
ctx - The possibly null context
concat - True if multiple values should be concatenated
Returns:
the property value, or null is there is none.
Throws:
NamingException - if an error occurs while reading the provider resource file.

getFactories

public static FactoryEnumeration getFactories(String propName,
                                              Hashtable env,
                                              Context ctx)
                                       throws NamingException
Retrieves an enumeration of factory classes/object specified by a property. The property is gotten from the environment and the provider resource file associated with the given context and concantenated. See getProperty(). The resulting property value is a list of class names.

This method then loads each class using the current thread's context class loader and keeps them in a list. Any class that cannot be loaded is ignored. The resulting list is then cached in a two-level hash table, keyed first by the context class loader and then by the property's value. The next time threads of the same context class loader call this method, they can use the cached list.

After obtaining the list either from the cache or by creating one from the property value, this method then creates and returns a FactoryEnumeration using the list. As the FactoryEnumeration is traversed, the cached Class object in the list is instantiated and replaced by an instance of the factory object itself. Both class objects and factories are wrapped in weak references so as not to prevent GC of the class loader.

Note that multiple threads can be accessing the same cached list via FactoryEnumeration, which locks the list during each next(). The size of the list will not change, but a cached Class object might be replaced by an instantiated factory object.

Parameters:
propName - The non-null property name
env - The possibly null environment properties
ctx - The possibly null context
Returns:
An enumeration of factory classes/objects; null if none.
Throws:
NamingException - If encounter problem while reading the provider property file.
See Also:
NamingManager.getObjectInstance(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable), NamingManager.getStateToBind(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable), DirectoryManager.getObjectInstance(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable, javax.naming.directory.Attributes), DirectoryManager.getStateToBind(java.lang.Object, javax.naming.Name, javax.naming.Context, java.util.Hashtable, javax.naming.directory.Attributes), ControlFactory.getControlInstance(javax.naming.ldap.Control)

getFactory

public static Object getFactory(String propName,
                                Hashtable env,
                                Context ctx,
                                String classSuffix,
                                String defaultPkgPrefix)
                         throws NamingException
Retrieves a factory from a list of packages specified in a property. The property is gotten from the environment and the provider resource file associated with the given context and concatenated. classSuffix is added to the end of this list. See getProperty(). The resulting property value is a list of package prefixes.

This method then constructs a list of class names by concatenating each package prefix with classSuffix and attempts to load and instantiate the class until one succeeds. Any class that cannot be loaded is ignored. The resulting object is then cached in a two-level hash table, keyed first by the context class loader and then by the property's value and classSuffix. The next time threads of the same context class loader call this method, they use the cached factory. If no factory can be loaded, NO_FACTORY is recorded in the table so that next time it'll return quickly.

Parameters:
propName - The non-null property name
env - The possibly null environment properties
ctx - The possibly null context
classSuffix - The non-null class name (e.g. ".ldap.ldapURLContextFactory).
defaultPkgPrefix - The non-null default package prefix. (e.g., "com.sun.jndi.url").
Returns:
An factory object; null if none.
Throws:
NamingException - If encounter problem while reading the provider property file, or problem instantiating the factory.
See Also:
NamingManager.getURLContext(java.lang.Object, javax.naming.Name, javax.naming.Context, java.lang.String, java.util.Hashtable)

aicas logo Jamaica 3.4 release 8

aicas GmbH, Karlsruhe - Germany    www.aicas.com
Copyright 2001-2009 aicas GmbH. All Rights Reserved.