com.ibm.websphere.naming

Class genericURLInitialContextFactory

  1. java.lang.Object
  2. extended bycom.ibm.websphere.naming.genericURLInitialContextFactory
All implemented interfaces:
javax.naming.spi.InitialContextFactory

  1. public class genericURLInitialContextFactory
  2. extends java.lang.Object
  3. implements javax.naming.spi.InitialContextFactory
This class is part of a framework that enables applications to easily create local name spaces associated with a given URL scheme. A local name space created with this framework is shared across a process. That is, all threads running in a JVM instance will use the same name space instance.

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:

The constant com.ibm.websphere.naming.PROPS.GENERIC_URL_INITIAL_CONTEXT_FACTORY can be used for the class name.

The code example below 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.

See Also:
genericURLContextFactory, PROPS.GENERIC_URL_INITIAL_CONTEXT_FACTORY, PROPS.GENERIC_URL_SCHEMEID, PROPS.GENERIC_URL_PACKAGE

Constructor Summary

Constructor and Description
genericURLInitialContextFactory()
This constructor creates an instance of genericURLInitialContextFactory.

Method Summary

Modifier and Type Method and Description
  1. 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.
  1. java.lang.String
toString()
Returns a string representation of this object.
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait

Constructor Detail

genericURLInitialContextFactory

  1. public genericURLInitialContextFactory( )
This constructor creates an instance of genericURLInitialContextFactory. It should not be used directly by users. Instead, it will be invoked by java.naming.InitialContext when this class is specified as the initial context factory.

Method Detail

getInitialContext

  1. public javax.naming.Context getInitialContext( java.util.Hashtable env)
  2. throws javax.naming.NamingException
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. This method is invoked by the constructor for javax.naming.InitialContext as part of the JNDI SPI and should not be invoked directly by users.
Specified by:
getInitialContext in interface javax.naming.spi.InitialContextFactory
Parameters:
env - The set of properties collected by the InitialContext constructor from various locations.
Returns:
The root context of the name space for the specified scheme.
Throws:
javax.naming.NamingException

toString

  1. public java.lang.String toString( )
Returns a string representation of this object.
Overrides:
toString in class java.lang.Object
Returns:
a string representation of this object.