org.objectweb.easybeans.server
Class Embedded

java.lang.Object
  extended by org.objectweb.easybeans.server.Embedded
All Implemented Interfaces:
EZBServer

public class Embedded
extends java.lang.Object
implements EZBServer

Allows to create an embedded EJB3 server.

Author:
Florent Benoit

Field Summary
private  ComponentManager componentManager
          Manager of components.
private  Components components
          List of components that have been defined.
private  java.util.Map<java.lang.String,EZBContainer> containers
          Map of managed ejb3 containers.
static java.lang.String CORE_XML_FILE
          Core XML file (that will load Quartz component, etc).
private static int counter
          Internal (global) counter of all embedded instance created.
static java.lang.String DEFAULT_DEPLOY_DIRECTORY
          Default deployment directory.
private  RemoteDeployer deployer
          Deployer instance.
static java.lang.String DEPRECATED_DEFAULT_DEPLOY_DIRECTORY
          Deprecated default deployment directory.
private  java.util.List<EasyBeansConfigurationExtension> extensionFactories
          List of Callbacks factories.
private  java.lang.Integer id
          ID of this embedded server.
private static JLog logger
          Logger.
private  ContainersMonitor monitor
          Monitor of the containers.
private  ServerConfig serverConfig
          Configuration of this server.
private static int SLEEP_VALUE
          Default sleep value (for server loop).
private  boolean started
          Server started ?
 
Constructor Summary
Embedded()
          Creates a new Embedded server.
It will take default values of configuration.
 
Method Summary
 void addContainer(EZBContainer container)
          Add an already created container.
private  void callJContainerConfigExtensions(EZBContainerConfig jcc)
          Adapt the JContainerConfig for all EasyBeansConfigurationExtension.
private  void configure()
          Configure the server by using the given configuration.
 EZBContainer createContainer(EZBArchive archive)
          Creates and adds an ejb3 container to the managed container.
 EZBContainer findContainer(EZBArchive archive)
          Gets a container managed by this server.
 EZBComponent getComponent(java.lang.String componentName)
          Gets component with the given name.
 ComponentManager getComponentManager()
           
 Components getComponents()
          Gets the components that have been defined for this embedded server.
 EZBContainer getContainer(java.lang.String id)
          Gets a container managed by this server.
 java.util.Map<java.lang.String,EZBContainer> getContainers()
           
 IRemoteDeployer getDeployer()
           
 java.lang.Integer getID()
          Gets the id of this embedded server.
 ServerConfig getServerConfig()
           
 void removeContainer(EZBContainer container)
          Remove a given container.
 void setComponents(Components components)
          Sets the components that needs to be launched.
 void setServerConfig(ServerConfig serverConfig)
          Sets the server configuration (not the components).
 void start()
          Starts the EJB3 server.
 void stop()
          Stops the EJB3 server.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SLEEP_VALUE

private static final int SLEEP_VALUE
Default sleep value (for server loop).

See Also:
Constant Field Values

CORE_XML_FILE

public static final java.lang.String CORE_XML_FILE
Core XML file (that will load Quartz component, etc).

See Also:
Constant Field Values

DEFAULT_DEPLOY_DIRECTORY

public static final java.lang.String DEFAULT_DEPLOY_DIRECTORY
Default deployment directory.

See Also:
Constant Field Values

DEPRECATED_DEFAULT_DEPLOY_DIRECTORY

public static final java.lang.String DEPRECATED_DEFAULT_DEPLOY_DIRECTORY
Deprecated default deployment directory.

See Also:
Constant Field Values

logger

private static JLog logger
Logger.


counter

private static int counter
Internal (global) counter of all embedded instance created.


id

private java.lang.Integer id
ID of this embedded server.


serverConfig

private ServerConfig serverConfig
Configuration of this server.


containers

private java.util.Map<java.lang.String,EZBContainer> containers
Map of managed ejb3 containers.


extensionFactories

private java.util.List<EasyBeansConfigurationExtension> extensionFactories
List of Callbacks factories.


deployer

private RemoteDeployer deployer
Deployer instance.


components

private Components components
List of components that have been defined.


componentManager

private ComponentManager componentManager
Manager of components.


started

private boolean started
Server started ?


monitor

private ContainersMonitor monitor
Monitor of the containers.

Constructor Detail

Embedded

public Embedded()
Creates a new Embedded server.
It will take default values of configuration.

Method Detail

start

public void start()
           throws EmbeddedException
Starts the EJB3 server.

Throws:
EmbeddedException - if there is a failure while starting the server.

stop

public void stop()
          throws EmbeddedException
Stops the EJB3 server.

Throws:
EmbeddedException - if container cannot be stopped.

setServerConfig

public void setServerConfig(ServerConfig serverConfig)
Sets the server configuration (not the components).

Parameters:
serverConfig - the given configuration

getContainer

public EZBContainer getContainer(java.lang.String id)
Gets a container managed by this server.

Specified by:
getContainer in interface EZBServer
Parameters:
id - the container id.
Returns:
the container if it is found, else null.

findContainer

public EZBContainer findContainer(EZBArchive archive)
Gets a container managed by this server.

Specified by:
findContainer in interface EZBServer
Parameters:
archive - the archive used by the given container.
Returns:
the container if it is found, else null.

configure

private void configure()
Configure the server by using the given configuration.


createContainer

public EZBContainer createContainer(EZBArchive archive)
Creates and adds an ejb3 container to the managed container.

Specified by:
createContainer in interface EZBServer
Parameters:
archive - jar file or exploded archive.
Returns:
the created container.

addContainer

public void addContainer(EZBContainer container)
Add an already created container.

Parameters:
container - the EZBContainer to be added.

removeContainer

public void removeContainer(EZBContainer container)
Remove a given container.

Specified by:
removeContainer in interface EZBServer
Parameters:
container - the container to be removed.

callJContainerConfigExtensions

private void callJContainerConfigExtensions(EZBContainerConfig jcc)
Adapt the JContainerConfig for all EasyBeansConfigurationExtension.

Parameters:
jcc - the JContainerConfig to adapt.

getServerConfig

public ServerConfig getServerConfig()
Returns:
the configuration of this server.

getContainers

public java.util.Map<java.lang.String,EZBContainer> getContainers()
Specified by:
getContainers in interface EZBServer
Returns:
the containers managed by this server.

getID

public java.lang.Integer getID()
Gets the id of this embedded server.

Specified by:
getID in interface EZBServer
Returns:
the id of this server.

getDeployer

public IRemoteDeployer getDeployer()
Returns:
the Remote deployer instance.

getComponents

public Components getComponents()
Gets the components that have been defined for this embedded server.

Returns:
the components.

setComponents

public void setComponents(Components components)
Sets the components that needs to be launched.

Parameters:
components - the set of components.

getComponent

public EZBComponent getComponent(java.lang.String componentName)
Gets component with the given name.

Parameters:
componentName - the name of the component.
Returns:
the component (if any)

getComponentManager

public ComponentManager getComponentManager()
Specified by:
getComponentManager in interface EZBServer
Returns:
Returns the ComponentManager used by this instance.