Save This Page
Home » openjdk-7 » com.sun.naming » internal » [javadoc | source]
com.sun.naming.internal
public final class: ResourceManager [javadoc | source]
java.lang.Object
   com.sun.naming.internal.ResourceManager
The ResourceManager class facilitates the reading of JNDI resource files.
Method from com.sun.naming.internal.ResourceManager Summary:
getFactories,   getFactory,   getInitialEnvironment,   getProperty
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from com.sun.naming.internal.ResourceManager Detail:
 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.

 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.

 public static Hashtable getInitialEnvironment(Hashtable env) throws NamingException 
 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.