Java Reference
In-Depth Information
stance. The EJBContainer.createEJBContainer method is used to create and
initialize an embedded container instance.
The following code snippet shows how to create an embedded container that is initialized
with the container provider's default settings:
EJBContainer ec = EJBContainer.createEJBContainer();
By default, the embedded container will search the virtual machine classpath for enter-
prise bean modules: directories containing a META-INF/ejb-jar.xml deployment
descriptor, directories containing a class file with one of the enterprise bean component
annotations (such as @Stateless ), or JAR files containing an ejb-jar.xml deploy-
ment descriptor or class file with an enterprise bean annotation. Any matching entries are
considered enterprise bean modules within the same application. Once all the valid enter-
prise bean modules have been found in the classpath, the container will begin initializing
the modules. When the createEJBContainer method successfully returns, the client
application can obtain references to the client view of any enterprise bean module found
by the embedded container.
An alternate version of the EJBContainer.createEJBContainer method takes a
Map of properties and settings for customizing the embeddable container instance:
Click here to view code image
Properties props = new Properties();
props.setProperty(...);
...
EJBContainer ec = EJBContainer.createEJBContainer(props);
Explicitly Specifying Enterprise Bean Modules to be Initialized
Developers can specify exactly which enterprise bean modules the embedded container
will initialize. To explicitly specify the enterprise bean modules initialized by the embed-
ded container, set the EJBContainer.MODULES property.
The modules may be located either in the virtual machine classpath in which the embed-
ded container and client code run, or alternately outside the virtual machine classpath.
To specify modules in the virtual machine classpath, set EJBContainer.MODULES to
a String to specify a single module name, or a String array containing the module
names. The embedded container searches the virtual machine classpath for enterprise bean
modules matching the specified names.
Search WWH ::




Custom Search