Oracle Fusion Middleware
Oracle WebLogic Server API Reference
11g Release 1 (10.3.3)

Part Number E13941-03

Class WLInitialContextFactory

  extended by weblogic.jndi.WLInitialContextFactory
All Implemented Interfaces:
Direct Known Subclasses:

public class WLInitialContextFactory
extends Object
implements InitialContextFactory

The WLInitialContextFactory creates initial contexts for accessing the WebLogic naming service. 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);
   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:

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();
   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
          Default constructor.
Method Summary
 Context getInitialContext(Hashtable env)
          Creates an InitialContext.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

Constructor Detail


public WLInitialContextFactory()
Default constructor.

Method Detail


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.

Specified by:
getInitialContext in interface InitialContextFactory
env - Environment used for creating the context
NamingException - if the context cannot be created

Copyright 1996, 2010, 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.

Oracle Fusion Middleware
Oracle WebLogic Server 10.3.3 API Reference
11g Release 1 (10.3.3)

Part Number E13941-03