public class WLInitialContextFactoryDelegate extends Object implements InitialContextFactory, weblogic.jndi.spi.EnvironmentFactory
To create a WebLogic context from a client, your code must minimally specify this Factory as the initial context factory, and the URL of a WebLogic Server in the JNDI environment, as properties passed to the constructor of InitialContext. Here's an example of the minimal setup required to establish a context:
Hashtable env = new Hashtable(5);
env.put(Context.INITIAL_CONTEXT_FACTORY,
"weblogic.jndi.WLInitialContextFactory");
env.put(Context.PROVIDER_URL,
"t3://weblogicServer:7001");
Context ctx = new InitialContext(env);
For a complete list of standard JNDI properties, see the contants defined in javax.naming.Context. For a list of WebLogic-specific properties, see the constants defined in weblogic.jndi.WLContext.
An Environment object can be used as a type-safe alternative to specifying properties in a Hashtable. Environment comes with a set of built-in defaults:
Environment env = new Environment();
env.setProviderURL("t3://weblogicServer:7001");
Context ctx = new env.getInitialContext();
Note that here we've depended on the built-in defaults for the
initial context factory and a WebLogic user/password. We've
supplied the provider URL since it doesn't match the default.
Creating a context from within a server-side object is simpler. You need not specify any properties; those are set for you by the Server. Here's the same example code written for getting a context from within a server-side object:
Context ctx = new InitialContext();There is no need to specify a factory or a URL. By default, the server will use WLInitialContextFactory and connect to the local naming service. Use one of the techniques described above to create a context using special properties on the server.
Context,
InitialContext,
WLContext,
Environment| Modifier and Type | Method and Description |
|---|---|
Context |
getInitialContext(Environment environment,
String contextName)
Returns a subcontext of the initial context with the
specified name.
|
Context |
getInitialContext(Environment env,
String subCtxName,
HostID hostID)
Creates a new context given the context environment.
|
Context |
getInitialContext(Hashtable env)
Creates an InitialContext.
|
Remote |
getInitialReference(Environment env,
Class implClass)
Returns a remote reference to the initial reference with the
specified id.
|
static WLInitialContextFactoryDelegate |
theOne() |
public static WLInitialContextFactoryDelegate theOne()
public final Context getInitialContext(Hashtable env) throws NamingException
getInitialContext in interface InitialContextFactoryenv - Environment used for creating the contextNamingException - if the context cannot be createdpublic final Context getInitialContext(Environment env, String subCtxName, HostID hostID) throws NamingException
getInitialContext in interface weblogic.jndi.spi.EnvironmentFactoryenv - Environment used for creating the contextsubCtxName - Name of subcontext to return (or null)hostID - host ID to ignore while getting initial context if
the url specified maps to a cluster.NamingException - if the context cannot
be createdpublic Remote getInitialReference(Environment env, Class implClass) throws NamingException
weblogic.jndi.spi.EnvironmentFactorygetInitialReference in interface weblogic.jndi.spi.EnvironmentFactoryenv - environment to use.implClass - of the singleton to retrieveNamingException - if the remote object cannot be obtainedpublic Context getInitialContext(Environment environment, String contextName) throws NamingException
weblogic.jndi.spi.EnvironmentFactorygetInitialContext in interface weblogic.jndi.spi.EnvironmentFactoryenvironment - environment to usecontextName - of the context to retrieveNamingException - if the initial context cannot be obtained