org.objectweb.jonas.naming
Class NamingManager

java.lang.Object
  extended by org.objectweb.jonas.naming.NamingManager
All Implemented Interfaces:
ContainerNaming

public class NamingManager
extends java.lang.Object
implements ContainerNaming

Naming Manager for an EJB Server. this singleton class must exist in each jonas server.

Author:
Philippe Durieux, Philippe Coq : Monolog, Florent Benoit & Ludovic Bert : Context for web container

Method Summary
 javax.naming.Context createEnvironmentContext(java.lang.String namespace)
          Create Context for application and component environments.
 javax.naming.Context createImmutableEnvironmentContext(java.lang.String namespace)
          Create Immutable Context.
 javax.naming.Context getComponentContext()
          Get the Context associated with the current thread or to a class loader
 javax.naming.Context getComponentContext(java.lang.ClassLoader cl)
          Return the CompNamingContext associated with the given classloader.
 java.util.Hashtable getEnv()
          Return the environment for JNDI This is used only for handles today.
 javax.ejb.spi.HandleDelegate getHandleDelegate()
           
 javax.naming.InitialContext getInitialContext()
          Get the initialContext used in this jonas server.
static NamingManager getInstance()
          Return the unique instance of a NamingManager.
 javax.naming.Context getServerContext()
          Get the server component context.
 void resetComponentContext(javax.naming.Context ctx)
          Set back the context with the given value.
 void setClientContainerComponentContext(javax.naming.Context ctx)
          Set the context used by client container (per JVM instead of per thread)
 javax.naming.Context setComponentContext(javax.naming.Context ctx)
          Associate this CompNamingContext with the current thread.
 void setComponentContext(javax.naming.Context ctx, java.lang.ClassLoader cl)
          Associate the specified CompNamingContext with the given classloader.
 void unSetComponentContext(java.lang.ClassLoader cl)
          Remove the CompNamingContext associated with the given classloader.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Method Detail

getInstance

public static NamingManager getInstance()
                                 throws javax.naming.NamingException
Return the unique instance of a NamingManager.

Returns:
NamingManager the unique instance.
Throws:
javax.naming.NamingException - if it failed.

getInitialContext

public javax.naming.InitialContext getInitialContext()
Get the initialContext used in this jonas server.

Specified by:
getInitialContext in interface ContainerNaming
Returns:
InitialContext the initial context.

getHandleDelegate

public javax.ejb.spi.HandleDelegate getHandleDelegate()
Returns:
The HandleDelegate implementation for this server

createEnvironmentContext

public javax.naming.Context createEnvironmentContext(java.lang.String namespace)
                                              throws javax.naming.NamingException
Create Context for application and component environments. (formally known as createComponentContext)

Specified by:
createEnvironmentContext in interface ContainerNaming
Parameters:
namespace - namespace to used for the Context
Returns:
a java: context with comp/ subcontext
Throws:
javax.naming.NamingException - if the creation of the java: context failed.

getComponentContext

public javax.naming.Context getComponentContext()
                                         throws javax.naming.NamingException
Get the Context associated with the current thread or to a class loader

Specified by:
getComponentContext in interface ContainerNaming
Returns:
Context the component context.
Throws:
javax.naming.NamingException - When operation is not allowed

setComponentContext

public javax.naming.Context setComponentContext(javax.naming.Context ctx)
Associate this CompNamingContext with the current thread. This method should be called in preinvoke/postinvoke and when we build the bean environment or web environment.

Specified by:
setComponentContext in interface ContainerNaming
Parameters:
ctx - the context to associate to the current thread.
Returns:
Context the context of the thread

resetComponentContext

public void resetComponentContext(javax.naming.Context ctx)
Set back the context with the given value. Don't return the previous context, use setComponentContext() method for this.

Specified by:
resetComponentContext in interface ContainerNaming
Parameters:
ctx - the context to associate to the current thread.

setComponentContext

public void setComponentContext(javax.naming.Context ctx,
                                java.lang.ClassLoader cl)
Associate the specified CompNamingContext with the given classloader.

Specified by:
setComponentContext in interface ContainerNaming
Parameters:
ctx - the context to associate to the classloader.
cl - the classloader which is bind to the context.

setClientContainerComponentContext

public void setClientContainerComponentContext(javax.naming.Context ctx)
Set the context used by client container (per JVM instead of per thread)

Specified by:
setClientContainerComponentContext in interface ContainerNaming
Parameters:
ctx - the context to set

getComponentContext

public javax.naming.Context getComponentContext(java.lang.ClassLoader cl)
Return the CompNamingContext associated with the given classloader.

Specified by:
getComponentContext in interface ContainerNaming
Parameters:
cl - the classloader which is bind to the context.
Returns:
the CompNamingContext associated with the given classloader.

unSetComponentContext

public void unSetComponentContext(java.lang.ClassLoader cl)
Remove the CompNamingContext associated with the given classloader.

Specified by:
unSetComponentContext in interface ContainerNaming
Parameters:
cl - the classloader which is bind to the context.

getEnv

public java.util.Hashtable getEnv()
Return the environment for JNDI This is used only for handles today.

Specified by:
getEnv in interface ContainerNaming
Returns:
Hashtable the environment.

createImmutableEnvironmentContext

public javax.naming.Context createImmutableEnvironmentContext(java.lang.String namespace)
                                                       throws javax.naming.NamingException
Create Immutable Context. Not implemented !

Specified by:
createImmutableEnvironmentContext in interface ContainerNaming
Parameters:
namespace - namespace to used for the Context
Returns:
Context an immutable context
Throws:
javax.naming.NamingException - if the creation of the java: context failed.

getServerContext

public javax.naming.Context getServerContext()
Get the server component context. This is used only internally in the jonas NamingManager.

Returns:
Context the server component context.