Overview | Package | Class | Use | Tree | Deprecated | Index | Help
|  | Oracle
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD

## weblogic.jndi
Class WLInitialContextFactoryDelegate

    java.lang.Object
      weblogic.jndi.WLInitialContextFactoryDelegate

All Implemented Interfaces:
  InitialContextFactory, weblogic.jndi.spi.EnvironmentFactory

    public class WLInitialContextFactoryDelegate

extends Object
implements InitialContextFactory, weblogic.jndi.spi.EnvironmentFactory

The WLInitialContextFactoryDelegate creates initial contexts for accessing the WebLogic naming service locally or remotely via t3. It can also be used to create a multitier connection to another naming service through a WebLogic Server.

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:

- If you don't set an initial context factory, the default is to use WLInitialContextFactory.
- If you don't set a principal and password, the default is to use guest/guest.
- If you don't set a server URL, the default is to use "t3://localhost:7001".

The Environment object offers some convenience "setter" methods that provide type-safety (and less chance of typos). Here's how you would write the same example using an Environment object:

       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.

See Also:
  `Context`, `InitialContext`, `WLContext`, `Environment`

Constructor Summary
`WLInitialContextFactoryDelegate()` Default constructor.

Method Summary
`Context` | `getInitialContext(Environment environment, String contextName)` Returns a subcontext of the initial context with the specified name.
`Context` | `getInitialContext(Environment env, String subCtxName, weblogic.rmi.spi.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()`

Methods inherited from class java.lang.Object
`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

Constructor Detail

### WLInitialContextFactoryDelegate

    public WLInitialContextFactoryDelegate()

  Default constructor.

Method Detail

### theOne

    public static final WLInitialContextFactoryDelegate theOne()

### getInitialContext

    public final Context getInitialContext(Hashtable env)
                                    throws NamingException

  Creates an InitialContext. These properties affect how the context is created and to what naming service the context refers.
  - `java.naming.provider.url`. String that specifies the URL of the WebLogic server that will provide the name service. Defaults to `t3://localhost:7001` if unset. You can also set this property with the `Environment.setProviderURL()` method.
  - `java.naming.provider.delegate.environment`. Optional `java.util.Hashtable` object that can be used to specify the use of a third-party naming service. It contains all the properties needed to create the third-party InitialContext on the WebLogic Server. If this property is specified, the WebLogic Server acts as a router to the third-party name service. Conceptually, the WebLogic Server creates an InitialContext using these properties and then provides the caller with a local context that delegates to this remote context. If this property is specified, the properties `java.naming.security.principal` and `java.naming.security.credentials` are ignored.
  - `java.naming.security.principal`. String that specifies the identity of the principal (user) for security purposes. Defaults to "guest".
  - `java.naming.security.credentials`. String that specifies the password for the principal or, alternatively, an Object that implements the `weblogic.security.acl.UserInfo` interface. If it is a UserInfo object, the property `javax.naming.security.principal` is ignored. Defaults to "guest".

  Specified by:
    `getInitialContext` in interface `InitialContextFactory`
  Parameters:
    `env` - Environment used for creating the context
  Returns:
    javax.naming.Context
  Throws:
    `NamingException` - if the context cannot be created

### getInitialContext

    public final Context getInitialContext(Environment env,
                                           String subCtxName,
                                           weblogic.rmi.spi.HostID hostID)
                                    throws NamingException

  Creates a new context given the context environment.

  Specified by:
    `getInitialContext` in interface `weblogic.jndi.spi.EnvironmentFactory`
  Parameters:
    `env` - Environment used for creating the context
    `subCtxName` - Name of subcontext to return (or null)
    `hostID` - host ID to ignore while getting initial context if the url specified maps to a cluster.
  Returns:
    Initial context
  Throws:
    `NamingException` - if the context cannot be created

### getInitialReference

    public Remote getInitialReference(Environment env,
                                      Class implClass)
                               throws NamingException

  Description copied from interface: `weblogic.jndi.spi.EnvironmentFactory`
  Returns a remote reference to the initial reference with the specified id. This may or may not involve a remote call.

  Specified by:
    `getInitialReference` in interface `weblogic.jndi.spi.EnvironmentFactory`
  Parameters:
    `env` - environment to use.
    `implClass` - of the singleton to retrieve
  Returns:
    remote object
  Throws:
    `NamingException` - if the remote object cannot be obtained

### getInitialContext

    public Context getInitialContext(Environment environment,
                                     String contextName)
                              throws NamingException

  Description copied from interface: `weblogic.jndi.spi.EnvironmentFactory`
  Returns a subcontext of the initial context with the specified name.

  Specified by:
    `getInitialContext` in interface `weblogic.jndi.spi.EnvironmentFactory`
  Parameters:
    `environment` - environment to use
    `contextName` - of the context to retrieve
  Returns:
    Initial context
  Throws:
    `NamingException` - if the initial context cannot be obtained

Overview | Package | Class | Use | Tree | Deprecated | Index | Help
| Documentation is available at http://edocs.bea.com/wls/docs103 Copyright 1996,2008, Oracle and/or its affiliates. All rights reserved. Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
PREV CLASS NEXT CLASS | FRAMES NO FRAMES
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD