Class GlobalContextManager

  • All Implemented Interfaces:
    javax.naming.spi.InitialContextFactory, javax.naming.spi.ObjectFactory
    Direct Known Subclasses:
    javaURLContextFactory

    public class GlobalContextManager
    extends java.lang.Object
    implements javax.naming.spi.ObjectFactory, javax.naming.spi.InitialContextFactory
    The GlobalContextManager contains the static global context object. JNDI effectively requires a single global static to resolve the root context, and this class manages that static. This class is also an URLContextFactory and an InitialContextFactory which returns the registered global context. To use this factory simply set the following system property or pass the property in the environment to new InitialContext: java.naming.factory.initial = org.apache.xbean.naming.global.GlobalContextManager
    Version:
    $Rev$ $Date$
    • Method Summary

      All Methods Static Methods Instance Methods Concrete Methods 
      Modifier and Type Method Description
      static javax.naming.Context getGlobalContext()
      Gets the global context.
      javax.naming.Context getInitialContext​(java.util.Hashtable environment)
      Returns the Context registered with the GlobalManager.
      java.lang.Object getObjectInstance​(java.lang.Object obj, javax.naming.Name name, javax.naming.Context nameCtx, java.util.Hashtable environment)
      Returns the Context registered with the GlobalManager.
      static void setGlobalContext​(javax.naming.Context globalContext)
      Sets the global context.
      • Methods inherited from class java.lang.Object

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

      • GlobalContextManager

        public GlobalContextManager()
    • Method Detail

      • getGlobalContext

        public static javax.naming.Context getGlobalContext()
        Gets the global context. This context is the root of all contexts and will contain entries such as "java:comp".
        Returns:
        the global context
      • setGlobalContext

        public static void setGlobalContext​(javax.naming.Context globalContext)
        Sets the global context. To invoke this method the calling code must have "setFactory" RuntimePermission.
        Parameters:
        globalContext - the new global context
      • getObjectInstance

        public java.lang.Object getObjectInstance​(java.lang.Object obj,
                                                  javax.naming.Name name,
                                                  javax.naming.Context nameCtx,
                                                  java.util.Hashtable environment)
                                           throws java.lang.Exception
        Returns the Context registered with the GlobalManager. This method is equivalent to: return GlobalContextManager.getGlobalContext();
        Specified by:
        getObjectInstance in interface javax.naming.spi.ObjectFactory
        Parameters:
        obj - must be null
        name - ignored
        nameCtx - ignored
        environment - ignored
        Returns:
        GlobalManager.getGlobalContext()
        Throws:
        javax.naming.OperationNotSupportedException - if obj is not null
        java.lang.Exception
      • getInitialContext

        public javax.naming.Context getInitialContext​(java.util.Hashtable environment)
        Returns the Context registered with the GlobalManager. This method is equivalent to: return GlobalContextManager.getGlobalContext();
        Specified by:
        getInitialContext in interface javax.naming.spi.InitialContextFactory
        Parameters:
        environment - ignored
        Returns:
        GlobalContextManager.getGlobalContext()