public class genericURLInitialContextFactory
extends java.lang.Object
implements javax.naming.spi.InitialContextFactory
This class is used to create a local name space for a given URL scheme. To create a local name space, set the following two properties, and instantiate an InitialContext, specifying this class as the initial context factory:
Here is the code example that shows how to use this class to create a local name space for
the URL scheme, myscheme:
...
import java.util.Hashtable;
import javax.naming.Context;
import javax.naming.InitialContext;
import com.ibm.websphere.naming.PROPS;
...
Hashtable env = new Hashtable();
env.put(PROPS.GENERIC_URL_SCHEMEID, "myscheme");
env.put(PROPS.GENERIC_URL_PACKAGE, "com.mycompany");
env.put(Context.INITIAL_CONTEXT_FACTORY, PROPS.GENERIC_URL_INITIAL_CONTEXT_FACTORY);
// The initial context will be the root context of the local name space
Context ic = new InitialContext(env);
Before JNDI operations with name URLs of the specified scheme will work, you need
to define an object factory for the URL scheme by creating a subclass of
genericURLContextFactory
.
Refer to the documententation for genericURLContextFactory for usage details.
Constructor and Description |
---|
genericURLInitialContextFactory()
This constructor creates an instance of genericURLInitialContextFactory.
|
Modifier and Type | Method and Description |
---|---|
javax.naming.Context |
getInitialContext(java.util.Hashtable env)
This method appends the object factory package name for the specified URL
scheme to the property, java.naming.factory.url.pkgs property value
in the system properties.
|
java.lang.String |
toString()
Returns a string representation of this object.
|
public genericURLInitialContextFactory()
public javax.naming.Context getInitialContext(java.util.Hashtable env) throws javax.naming.NamingException
getInitialContext
in interface javax.naming.spi.InitialContextFactory
env
- The set of properties collected by the InitialContext constructor from
various locations.javax.naming.NamingException
public java.lang.String toString()
toString
in class java.lang.Object