Package org.apache.xbean.naming.global
Class GlobalContextManager
java.lang.Object
org.apache.xbean.naming.global.GlobalContextManager
- All Implemented Interfaces:
InitialContextFactory
,ObjectFactory
- Direct Known Subclasses:
javaURLContextFactory
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$
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic Context
Gets the global context.getInitialContext
(Hashtable environment) Returns the Context registered with the GlobalManager.getObjectInstance
(Object obj, Name name, Context nameCtx, Hashtable environment) Returns the Context registered with the GlobalManager.static void
setGlobalContext
(Context globalContext) Sets the global context.
-
Constructor Details
-
GlobalContextManager
public GlobalContextManager()
-
-
Method Details
-
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
Sets the global context. To invoke this method the calling code must have "setFactory" RuntimePermission.- Parameters:
globalContext
- the new global context
-
getObjectInstance
public Object getObjectInstance(Object obj, Name name, Context nameCtx, Hashtable environment) throws Exception Returns the Context registered with the GlobalManager. This method is equivalent to: return GlobalContextManager.getGlobalContext();- Specified by:
getObjectInstance
in interfaceObjectFactory
- Parameters:
obj
- must be nullname
- ignorednameCtx
- ignoredenvironment
- ignored- Returns:
- GlobalManager.getGlobalContext()
- Throws:
OperationNotSupportedException
- if obj is not nullException
-
getInitialContext
Returns the Context registered with the GlobalManager. This method is equivalent to: return GlobalContextManager.getGlobalContext();- Specified by:
getInitialContext
in interfaceInitialContextFactory
- Parameters:
environment
- ignored- Returns:
- GlobalContextManager.getGlobalContext()
-