|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectcom.sun.naming.internal.ResourceManager
public final class ResourceManager
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 |
|---|
public static Hashtable getInitialEnvironment(Hashtable env)
throws NamingException
NamingException
public static String getProperty(String propName,
Hashtable env,
Context ctx,
boolean concat)
throws NamingException
propName - The non-null property nameenv - The possibly null environment propertiesctx - The possibly null contextconcat - True if multiple values should be concatenated
NamingException - if an error occurs while reading the provider
resource file.
public static FactoryEnumeration getFactories(String propName,
Hashtable env,
Context ctx)
throws NamingException
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.
propName - The non-null property nameenv - The possibly null environment propertiesctx - The possibly null context
NamingException - If encounter problem while reading the provider
property file.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)
public static Object getFactory(String propName,
Hashtable env,
Context ctx,
String classSuffix,
String defaultPkgPrefix)
throws NamingException
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.
propName - The non-null property nameenv - The possibly null environment propertiesctx - The possibly null contextclassSuffix - The non-null class name
(e.g. ".ldap.ldapURLContextFactory).defaultPkgPrefix - The non-null default package prefix.
(e.g., "com.sun.jndi.url").
NamingException - If encounter problem while reading the provider
property file, or problem instantiating the factory.NamingManager.getURLContext(java.lang.Object, javax.naming.Name, javax.naming.Context, java.lang.String, java.util.Hashtable)
|
|
|||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||