org.objectweb.easybeans.naming
Class NamingManager

java.lang.Object
  extended by org.objectweb.easybeans.naming.NamingManager

public final class NamingManager
extends java.lang.Object

Manages the java: context used by components.

Author:
Florent Benoit

Field Summary
private static javax.naming.Context clientCtx
          Static context used by client container.
private  javax.naming.InitialContext ictx
          Initial Context.
private static JLog logger
          Logger.
private static java.lang.ThreadLocal<javax.naming.Context> threadContext
          Associate a context to a thread.
private static NamingManager unique
          Singleton management: - the constructor is private.
private  javax.transaction.UserTransaction userTransaction
          UserTransaction object, to be shared by all components.
 
Constructor Summary
private NamingManager()
          Create the naming manager.
 
Method Summary
 javax.naming.Context createEnvironmentContext(java.lang.String namespace)
          Create Context for application and component environments.
 javax.naming.Context getComponentContext()
          Get the Context associated with the current thread or to a class loader.
 javax.naming.InitialContext getInitialContext()
          Get the initialContext used in this jonas server.
static NamingManager getInstance()
          Return the unique instance of a NamingManager.
 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.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static JLog logger
Logger.


threadContext

private static java.lang.ThreadLocal<javax.naming.Context> threadContext
Associate a context to a thread.


ictx

private javax.naming.InitialContext ictx
Initial Context.


clientCtx

private static javax.naming.Context clientCtx
Static context used by client container. One context for all the JVM.


unique

private static NamingManager unique
Singleton management: - the constructor is private. - use static method getInstance to retrieve/create the instance.


userTransaction

private javax.transaction.UserTransaction userTransaction
UserTransaction object, to be shared by all components.

Constructor Detail

NamingManager

private NamingManager()
               throws javax.naming.NamingException
Create the naming manager.

Throws:
javax.naming.NamingException - if no initial context is built
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.

Returns:
InitialContext the initial context.

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)

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.

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 before the call to the business method. After, resetComponentContext should be called to reset the context.

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.

Parameters:
ctx - the context to associate to the current thread.

setClientContainerComponentContext

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

Parameters:
ctx - the context to set