com.mockrunner.ejb
Class JNDIUtil

java.lang.Object
  extended by com.mockrunner.ejb.JNDIUtil

public class JNDIUtil
extends java.lang.Object

Util class for creating and managing the JNDI context


Constructor Summary
JNDIUtil()
           
 
Method Summary
static void bindUserTransaction(Configuration configuration, javax.naming.Context context, javax.transaction.UserTransaction transaction)
          Binds the specified UserTransaction to the specified JNDI context.
static javax.naming.Context getContext(Configuration configuration)
          Tries to get the JNDI context from the specified configuration.
static void initMockContextFactory()
          Calls MockContextFactory.setAsInitial(), if the MockContextFactory is not already the current context factory.
static void resetMockContextFactory()
          Calls MockContextFactory.revertSetAsInitial(), if the MockContextFactory is the current context factory.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

JNDIUtil

public JNDIUtil()
Method Detail

initMockContextFactory

public static void initMockContextFactory()
                                   throws javax.naming.NamingException
Calls MockContextFactory.setAsInitial(), if the MockContextFactory is not already the current context factory.

Throws:
javax.naming.NamingException

resetMockContextFactory

public static void resetMockContextFactory()
Calls MockContextFactory.revertSetAsInitial(), if the MockContextFactory is the current context factory.


getContext

public static javax.naming.Context getContext(Configuration configuration)
Tries to get the JNDI context from the specified configuration. If the configuration returns null for the context, this method initializes the MockEJB JNDI implementation.

Parameters:
configuration - the configuration
Returns:
the JNDI context

bindUserTransaction

public static void bindUserTransaction(Configuration configuration,
                                       javax.naming.Context context,
                                       javax.transaction.UserTransaction transaction)
                                throws javax.naming.NamingException
Binds the specified UserTransaction to the specified JNDI context.

Parameters:
configuration - the configuration
context - the JNDI context
transaction - the UserTransaction
Throws:
javax.naming.NamingException