com.interface21.jndi.mock
Class MockInitialContextFactoryBuilder
java.lang.Object
|
+--com.interface21.jndi.mock.MockInitialContextFactoryBuilder
- All Implemented Interfaces:
- javax.naming.spi.InitialContextFactoryBuilder
- public class MockInitialContextFactoryBuilder
- extends java.lang.Object
- implements javax.naming.spi.InitialContextFactoryBuilder
Mock JNDI naming context builder.
Mainly targetted at test environments, but also usable for standalone
applications. Typically used for binding a JDBC DataSource to a well-known JNDI
location, to be able to use J2EE data access code outside of a J2EE container.
There are various choices for mock DataSource implementations:
- SingleConnectionDataSource (using the same Connection for all getConnection calls);
- DriverManagerDataSource (creating a new Connection on each getConnection call);
- Apache's Jakarta Commons DBCP offers BasicDataSource (a real pool).
- Author:
- Juergen Hoeller
- See Also:
init(),
bind(java.lang.String, java.lang.Object),
MockContext,
SingleConnectionDataSource,
DriverManagerDataSource
|
Method Summary |
static void |
bind(java.lang.String name,
java.lang.Object obj)
Bind the given object under the given name, for all naming contexts
that this context builder will generate. |
javax.naming.spi.InitialContextFactory |
createInitialContextFactory(java.util.Hashtable props)
|
static void |
init()
Initialize the context builder by registering it with the JNDI NamingManager. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
MockInitialContextFactoryBuilder
public MockInitialContextFactoryBuilder()
init
public static void init()
throws javax.naming.NamingException
- Initialize the context builder by registering it with the JNDI NamingManager.
- Throws:
javax.naming.NamingException - if there's already a naming context builder
registered with the JNDI NamingManager
bind
public static void bind(java.lang.String name,
java.lang.Object obj)
- Bind the given object under the given name, for all naming contexts
that this context builder will generate.
- Parameters:
name - the JNDI name of the object (e.g. "java:comp/env/jdbc/myds")obj - the object to bind (e.g. a DataSource implementation)
createInitialContextFactory
public javax.naming.spi.InitialContextFactory createInitialContextFactory(java.util.Hashtable props)
throws javax.naming.NamingException
- Specified by:
createInitialContextFactory in interface javax.naming.spi.InitialContextFactoryBuilder
Rod Johnson and Spring contributors 2001-2003.