org.objectweb.easybeans.container
Class JContainer3

java.lang.Object
  extended by org.objectweb.easybeans.container.JContainer3
All Implemented Interfaces:
EZBContainer, EZBManageableContainer

public class JContainer3
extends java.lang.Object
implements EZBContainer

Defines an EJB3 container.

Author:
Florent Benoit

Field Summary
private  boolean available
          Container available.
private  java.lang.ClassLoader classLoader
          Classloader use to manage this archive.
private  EZBContainerConfig configuration
          JContainer Configuration.
private  Deployment deployment
          Deployment for the managed archive.
private  IEJBJarInfo ejbJarInfo
          Info on an ejb-jar file.
private  java.util.Map<java.lang.String,Factory> factories
          Map of managed ejb3 factories.
private  java.lang.String id
          Id of this container.
private static JLog logger
          Logger.
private  EZBPermissionManager permissionManager
          PermissionManager for the security permissions.
private  EZBPersistenceUnitManager persistenceUnitManager
          Persistence manager object which manages all persistence-unit associated to this container.
 
Constructor Summary
protected JContainer3()
          Default constructor.
  JContainer3(EZBContainerConfig config)
          Build a new container on the given archive.
 
Method Summary
private  void bindLocalHome(java.lang.String itf, java.lang.Integer embeddedId, java.lang.String containerID, java.lang.String factoryName, ClassAnnotationMetadata bean)
          Bind into registry the EJB Local Home.
private  void bindLocalItf(java.lang.String itf, java.lang.Integer embeddedId, java.lang.String containerID, java.lang.String factoryName, ClassAnnotationMetadata bean)
          Bind into registry interfaces for a bean making them available from clients.
private  void bindRemoteHome(java.lang.String remoteHome, java.lang.String containerID, java.lang.String factoryName, ClassAnnotationMetadata bean)
          Bind into registry the home interface for a bean making it available from clients.
private  void bindRemoteItf(java.lang.String itf, java.lang.String containerID, java.lang.String factoryName, ClassAnnotationMetadata bean)
          Bind into registry interfaces for a bean making them available from clients.
private  void createBeanFactories()
          Create the factories of the beans (session and MDB).
private  Factory createMessageDrivenBeanFactory(ClassAnnotationMetadata messageDrivenBean)
          Creates the given message driven bean factory.
private  Factory createSessionBeanFactory(ClassAnnotationMetadata sessionBean)
          Creates the given session bean and bind it.
 EZBArchive getArchive()
          Gets the archive used by this container.
private  java.util.List<EZBContainerLifeCycleCallback> getCallbacksLifeCycle()
           
 java.lang.ClassLoader getClassLoader()
          Gets the classloader.
 EZBContainerConfig getConfiguration()
           
private  EZBContainerCallbackInfo getContainer3CallbackInfo()
          Gets information on the container that can be given to container callbacks.
 EZBServer getEmbedded()
          Gets the parent EZBServer instance.
 java.util.Collection<Factory> getFactories()
           
 Factory getFactory(java.lang.String factoryName)
          Gets a factory with its given name.
 java.lang.String getId()
          Gets the id of this container.
 java.lang.String getName()
          Gets the name of this container.
 EZBPermissionManager getPermissionManager()
          Gets the permission manager (that manages EJB permissions).
 EZBPersistenceUnitManager getPersistenceUnitManager()
          Gets the persistence manager object which manages all persistence-unit associated to this container.
 boolean isAvailable()
          Check if the container is available or not.
static java.lang.String jndiNameEncode(java.lang.String beanClassName, java.lang.String itfName, java.lang.String mode)
          Encode a given name by prefixing it with given mode.
 void setClassLoader(java.lang.ClassLoader classLoader)
          Sets the classloader.
protected  void setContainerConfig(EZBContainerConfig config)
          Configure ths JConatiner.
 void setPermissionManager(EZBPermissionManager ezbPermissionManager)
          Sets the permission manager (that manages EJB permissions).
 void setPersistenceUnitManager(EZBPersistenceUnitManager persistenceUnitManager)
          Sets the persistence manager object which manages all persistence-unit associated to this container.
 void start()
          Start this container.
 void stop()
          Stop this container.
 
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.


id

private java.lang.String id
Id of this container.


classLoader

private java.lang.ClassLoader classLoader
Classloader use to manage this archive.


deployment

private Deployment deployment
Deployment for the managed archive.


available

private boolean available
Container available.


factories

private java.util.Map<java.lang.String,Factory> factories
Map of managed ejb3 factories.


persistenceUnitManager

private EZBPersistenceUnitManager persistenceUnitManager
Persistence manager object which manages all persistence-unit associated to this container.


configuration

private EZBContainerConfig configuration
JContainer Configuration.


permissionManager

private EZBPermissionManager permissionManager
PermissionManager for the security permissions.


ejbJarInfo

private IEJBJarInfo ejbJarInfo
Info on an ejb-jar file.

Constructor Detail

JContainer3

public JContainer3(EZBContainerConfig config)
Build a new container on the given archive.

Parameters:
config - The JContainer configuration storing the archive (jar file or exploded).

JContainer3

protected JContainer3()
Default constructor. Must be used in conjonction with setContainerConfig().

Method Detail

setContainerConfig

protected void setContainerConfig(EZBContainerConfig config)
Configure ths JConatiner. Must be called before start().

Parameters:
config - ContainerConfiguration instance.

getId

public java.lang.String getId()
Gets the id of this container.

Specified by:
getId in interface EZBManageableContainer
Returns:
string id.

start

public void start()
           throws EZBContainerException
Start this container.

Specified by:
start in interface EZBManageableContainer
Throws:
EZBContainerException - if starting fails.

createBeanFactories

private void createBeanFactories()
                          throws EZBContainerException
Create the factories of the beans (session and MDB).

Throws:
EZBContainerException - if binding fails.

createMessageDrivenBeanFactory

private Factory createMessageDrivenBeanFactory(ClassAnnotationMetadata messageDrivenBean)
                                        throws EZBContainerException
Creates the given message driven bean factory.

Parameters:
messageDrivenBean - the message driven bean class metadata.
Returns:
the build factory.
Throws:
EZBContainerException - if the message driven bean cannot be created.

createSessionBeanFactory

private Factory createSessionBeanFactory(ClassAnnotationMetadata sessionBean)
                                  throws EZBContainerException
Creates the given session bean and bind it.

Parameters:
sessionBean - the session bean class metadata.
Returns:
the build factory.
Throws:
EZBContainerException - if the session bean cannot be created

stop

public void stop()
Stop this container.

Specified by:
stop in interface EZBManageableContainer

getContainer3CallbackInfo

private EZBContainerCallbackInfo getContainer3CallbackInfo()
Gets information on the container that can be given to container callbacks.

Returns:
information on the managed container.

bindRemoteHome

private void bindRemoteHome(java.lang.String remoteHome,
                            java.lang.String containerID,
                            java.lang.String factoryName,
                            ClassAnnotationMetadata bean)
                     throws EZBContainerException
Bind into registry the home interface for a bean making it available from clients.

Parameters:
remoteHome - the name of the remote home interface that object will have.
containerID - the ID of the container.
factoryName - the name of the factory.
bean - the bean class associated to given interface.
Throws:
EZBContainerException - if interface cannot be loaded or if the bind fails

bindLocalHome

private void bindLocalHome(java.lang.String itf,
                           java.lang.Integer embeddedId,
                           java.lang.String containerID,
                           java.lang.String factoryName,
                           ClassAnnotationMetadata bean)
                    throws EZBContainerException
Bind into registry the EJB Local Home.

Parameters:
itf - the name of the interface that object will have.
embeddedId - the ID of the embedded server.
containerID - the ID of the container.
factoryName - the name of the factory.
bean - the bean class associated to given interface.
Throws:
EZBContainerException - if interface cannot be loaded or if the bind fails

bindLocalItf

private void bindLocalItf(java.lang.String itf,
                          java.lang.Integer embeddedId,
                          java.lang.String containerID,
                          java.lang.String factoryName,
                          ClassAnnotationMetadata bean)
                   throws EZBContainerException
Bind into registry interfaces for a bean making them available from clients.

Parameters:
itf - the name of the interface that object will have.
embeddedId - the ID of the embedded server.
containerID - the ID of the container.
factoryName - the name of the factory.
bean - the bean class associated to given interface.
Throws:
EZBContainerException - if interface cannot be loaded or if the bind fails

bindRemoteItf

private void bindRemoteItf(java.lang.String itf,
                           java.lang.String containerID,
                           java.lang.String factoryName,
                           ClassAnnotationMetadata bean)
                    throws EZBContainerException
Bind into registry interfaces for a bean making them available from clients.

Parameters:
itf - the name of the interface that object will have.
containerID - the ID of the container.
factoryName - the name of the factory.
bean - the bean class associated to given interface.
Throws:
EZBContainerException - if interface cannot be loaded or if the bind fails

getFactory

public Factory getFactory(java.lang.String factoryName)
Gets a factory with its given name.

Specified by:
getFactory in interface EZBContainer
Parameters:
factoryName - the factory name.
Returns:
the factory found or null.

getFactories

public java.util.Collection<Factory> getFactories()
Returns:
Returns a Collection of managed Factories.

getName

public java.lang.String getName()
Gets the name of this container.

Specified by:
getName in interface EZBManageableContainer
Returns:
the name.

getClassLoader

public java.lang.ClassLoader getClassLoader()
Gets the classloader.

Specified by:
getClassLoader in interface EZBContainer
Returns:
classloader of the container

getArchive

public EZBArchive getArchive()
Gets the archive used by this container. It can be a .jar file or a directory.

Specified by:
getArchive in interface EZBManageableContainer
Returns:
the archive.

getEmbedded

public EZBServer getEmbedded()
Gets the parent EZBServer instance.

Returns:
Returns the Embedded instance.

getCallbacksLifeCycle

private java.util.List<EZBContainerLifeCycleCallback> getCallbacksLifeCycle()
Returns:
Returns the LifeCycleCallback(s) instances as a List.

isAvailable

public boolean isAvailable()
Check if the container is available or not.

Specified by:
isAvailable in interface EZBManageableContainer
Returns:
true if the container is available.

getPersistenceUnitManager

public EZBPersistenceUnitManager getPersistenceUnitManager()
Gets the persistence manager object which manages all persistence-unit associated to this container.

Specified by:
getPersistenceUnitManager in interface EZBContainer
Returns:
persistence unit manager object

jndiNameEncode

public static java.lang.String jndiNameEncode(java.lang.String beanClassName,
                                              java.lang.String itfName,
                                              java.lang.String mode)
Encode a given name by prefixing it with given mode.

Parameters:
beanClassName - name of the bean class.
itfName - name of the interface.
mode - local/remote, etc
Returns:
encoded jndi Name

setClassLoader

public void setClassLoader(java.lang.ClassLoader classLoader)
Sets the classloader.

Specified by:
setClassLoader in interface EZBContainer
Parameters:
classLoader - to be used by the container

setPersistenceUnitManager

public void setPersistenceUnitManager(EZBPersistenceUnitManager persistenceUnitManager)
Sets the persistence manager object which manages all persistence-unit associated to this container.

Specified by:
setPersistenceUnitManager in interface EZBContainer
Parameters:
persistenceUnitManager - persistence unit manager object to set.

getConfiguration

public EZBContainerConfig getConfiguration()
Specified by:
getConfiguration in interface EZBContainer
Returns:
Returns the Container Configuration.

getPermissionManager

public EZBPermissionManager getPermissionManager()
Gets the permission manager (that manages EJB permissions).

Specified by:
getPermissionManager in interface EZBContainer
Returns:
permission manager.

setPermissionManager

public void setPermissionManager(EZBPermissionManager ezbPermissionManager)
Sets the permission manager (that manages EJB permissions).

Specified by:
setPermissionManager in interface EZBContainer
Parameters:
ezbPermissionManager - the EasyBeans permission manager.