com.ibm.websphere.naming

Class genericURLInitialContextFactory

  • java.lang.Object
    • com.ibm.websphere.naming.genericURLInitialContextFactory
  • All Implemented Interfaces:
    javax.naming.spi.InitialContextFactory


    public class genericURLInitialContextFactory
    extends java.lang.Object
    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:

    • com.ibm.websphere.naming.generic.url.schemeid - The URL scheme associated with the name space. The Java constant for this property name is com.ibm.websphere.naming.PROPS.GENERIC_URL_SCHEMEID.
    • com.ibm.websphere.naming.generic.url.package - The package prefix of the object factory class, not including the last component, which must be the same as the URL scheme. The Java constant for this property name is com.ibm.websphere.naming.PROPS.GENERIC_URL_PACKAGE.
    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

      Constructors 
      Constructor and Description
      genericURLInitialContextFactory()
      This constructor creates an instance of genericURLInitialContextFactory.
    • Method Summary

      Methods 
      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.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
    • Constructor Detail

      • genericURLInitialContextFactory

        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

        public javax.naming.Context getInitialContext(java.util.Hashtable env)
                                               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

        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.
IBM WebSphere Application ServerTM
Release 8.5