org.objectweb.jonas.container
Class EJBServiceImpl

java.lang.Object
  extended by javax.management.NotificationBroadcasterSupport
      extended by org.objectweb.jonas.management.ReconfigDispatcher
          extended by org.objectweb.jonas.service.AbsServiceImpl
              extended by org.objectweb.jonas.container.EJBServiceImpl
All Implemented Interfaces:
javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, EJBService, EJBServiceImplMBean, ReconfigDispatcherMBean, Service

public class EJBServiceImpl
extends AbsServiceImpl
implements EJBService, EJBServiceImplMBean

Implementation of the EJB Container Service for jonas. This class works only with jonas_ejb classes.

Author:
Philippe Coq, Jeff Mesnil (Security), Markus Karg (Novell port), Christophe Ney (for making easier Enhydra integration), Adriana Danes (complete management methods), Florent Benoit & Ludovic Bert (Ear service, deployJars, undeployJars), Benjamin Bonnet (max thread pool size), Michel-Ange Anton (JSR77 MBean : EJBModule), Adriana Danes (JSR77)

Field Summary
static java.lang.String AUTO_GENIC
          Auto-GenIC is enabled or disabled ?
static java.lang.String AUTO_GENIC_ARGS
          Arguments for the Auto-GenIC
static java.lang.String AUTOLOADDIR
          autoloaddir property
static java.lang.String BMP
          BeanManaged Management properties
static java.lang.String CLASS
          EJB service class
static java.lang.String CMP
          ContainerManaged Management properties
static java.lang.String DESCRIPTORS
          descriptors property
protected static java.lang.String EJBJARS_DIR
          The name of the directory containing the ejb-jar files.
protected static java.lang.String JONAS_BASE
          The name of the JONAS_BASE directory.
static java.lang.String JONAS_EJB
          base for properties
static java.lang.String MAXWORKTHREADS
          Max Work Thread property name
static java.lang.String MINWORKTHREADS
          Min Work Thread property name
static java.lang.String PARSINGWITHVALIDATION
          parsing with validation property
static java.lang.String THREADWAITTIMEOUT
          Thread Wait Timeout property name
 
Fields inherited from class org.objectweb.jonas.management.ReconfigDispatcher
RECONFIG_TYPE, SAVE_RECONFIG_TYPE
 
Constructor Summary
EJBServiceImpl()
           
 
Method Summary
static java.lang.String buildEJBModuleName(java.lang.String pFilename)
          Build the EJBModule name.
static java.lang.String buildEJBModuleName(java.net.URL pUrl)
          Build the EJBModule name.
 void checkGenIC(java.lang.String fileName, java.net.URL[] urls)
          Check that GenIC have been applied on the given ejb-jar file If it was not done, it run GenIC against the file.
 java.lang.String createContainer(javax.naming.Context ctx)
          Create a JOnAS Container for all the beans that are described in a .xml file, or belong to .jar file.
 java.lang.String createContainer(java.lang.String file)
           
 java.lang.String createContainerMBean(java.lang.String file)
          MBean method allowing to create an EJB container for the EJBs contained in a .jar (or .xml) file.
 void deployJars(javax.naming.Context ctx)
          Deploy the given ejb-jars of an ear file with the specified parent classloader (ear classloader).
 void doInit(javax.naming.Context ctx)
          Init the Service.
 void doStart()
          Start the Service Initialization of the service is already done.
 void doStop()
          Stop the service: - Remove all JOnAS Containers.
 java.util.List getAutoloadDirectories()
          Return the list of "autoload" directories for EJB containers.
 Container getContainer(java.lang.String fileName)
          Get the Container by its file name (.xml or .jar)
 java.lang.Integer getCurrentNumberOfContainer()
          MBean method
 java.util.Set getDataSourceDependence(java.lang.String dsName)
          MBean method
 java.util.List getDeployableJars()
          Return the list of installed EJB container ready to deploy.
 java.util.List getDeployedJars()
          Return the list of all loaded EJB container.
 java.lang.String getEjbjarsDirectory()
          Return the Ejbjars directory.
 java.util.List getInstalledJars()
          Return the list of installed EJB containers.
 java.util.Set getJmsConnectionFactoryDependence(java.lang.String cfName)
          Management method
 java.util.Set getJmsDestinationDependence(java.lang.String destName)
          Manangement method
 java.util.Set getMailFactoryDependence(java.lang.String mfName)
          Management method
 java.lang.Integer getTotalCurrentNumberOfBeanType()
          MBean method
 java.lang.Integer getTotalCurrentNumberOfBMPType()
          MBean method
 java.lang.Integer getTotalCurrentNumberOfCMPType()
          MBean method
 java.lang.Integer getTotalCurrentNumberOfMDBType()
          MBean method
 java.lang.Integer getTotalCurrentNumberOfSBFType()
          MBean method
 java.lang.Integer getTotalCurrentNumberOfSBLType()
          MBean method
 JWorkManager getWorkManager()
          Get the workManager
 java.lang.Boolean isJarDeployed(java.lang.String fileName)
          Test if the specified file is already deployed (if a container is created for this jar).
 boolean isJarDeployedByWorkName(java.lang.String workFileName)
          Test if the specified jar identified with its work name is already deployed (if a container is created for this jar).
 boolean isJarLoaded(java.lang.String fileName)
          Test if the specified filename is already deployed or not
 Container[] listContainers()
          List JOnAS container created by EJB Service
 void removeCache(java.lang.ClassLoader earClassLoader)
          Make a cleanup of the cache of deployment descriptor.
 void removeContainer(Container cont)
          Remove a JOnAS container
 void removeContainer(Container cont, boolean isEarCase)
          Remove the specified container.
 void removeContainer(java.lang.String fileName)
           
 void removeContainerMBean(java.lang.String fileName)
          MBean method remove a container application
 void syncAllEntities(boolean passivate)
          Synchronized all entity bean containers
 void unDeployJars(java.net.URL[] urls)
          Undeploy the given ejb-jars of an ear file.
 
Methods inherited from class org.objectweb.jonas.service.AbsServiceImpl
getDomainName, getJonasServerName, getName, init, isStarted, setName, start, stop
 
Methods inherited from class org.objectweb.jonas.management.ReconfigDispatcher
addNotificationListener, getFilter, getHandback, getListener, getNotificationInfo, initLogger, removeNotificationListener, sendReconfigNotification, sendSaveNotification
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
handleNotification, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.jonas.service.Service
getName, init, isStarted, setName, start, stop
 

Field Detail

AUTO_GENIC

public static final java.lang.String AUTO_GENIC
Auto-GenIC is enabled or disabled ?

See Also:
Constant Field Values

AUTO_GENIC_ARGS

public static final java.lang.String AUTO_GENIC_ARGS
Arguments for the Auto-GenIC

See Also:
Constant Field Values

MINWORKTHREADS

public static final java.lang.String MINWORKTHREADS
Min Work Thread property name

See Also:
Constant Field Values

MAXWORKTHREADS

public static final java.lang.String MAXWORKTHREADS
Max Work Thread property name

See Also:
Constant Field Values

THREADWAITTIMEOUT

public static final java.lang.String THREADWAITTIMEOUT
Thread Wait Timeout property name

See Also:
Constant Field Values

JONAS_BASE

protected static final java.lang.String JONAS_BASE
The name of the JONAS_BASE directory.


EJBJARS_DIR

protected static final java.lang.String EJBJARS_DIR
The name of the directory containing the ejb-jar files.


JONAS_EJB

public static final java.lang.String JONAS_EJB
base for properties

See Also:
Constant Field Values

AUTOLOADDIR

public static final java.lang.String AUTOLOADDIR
autoloaddir property

See Also:
Constant Field Values

PARSINGWITHVALIDATION

public static final java.lang.String PARSINGWITHVALIDATION
parsing with validation property

See Also:
Constant Field Values

DESCRIPTORS

public static final java.lang.String DESCRIPTORS
descriptors property

See Also:
Constant Field Values

CLASS

public static final java.lang.String CLASS
EJB service class

See Also:
Constant Field Values

BMP

public static final java.lang.String BMP
BeanManaged Management properties

See Also:
Constant Field Values

CMP

public static final java.lang.String CMP
ContainerManaged Management properties

See Also:
Constant Field Values
Constructor Detail

EJBServiceImpl

public EJBServiceImpl()
Method Detail

doInit

public void doInit(javax.naming.Context ctx)
            throws ServiceException
Init the Service. Configuration information is passed thru a Context object.

Specified by:
doInit in class AbsServiceImpl
Parameters:
ctx - configuration of the service
Throws:
ServiceException - service initialization failed

getWorkManager

public JWorkManager getWorkManager()
Description copied from interface: EJBService
Get the workManager

Specified by:
getWorkManager in interface EJBService
Returns:
Returns the WorkManager instance

doStart

public void doStart()
             throws ServiceException
Start the Service Initialization of the service is already done.

Specified by:
doStart in class AbsServiceImpl
Throws:
ServiceException - service start-up failed

doStop

public void doStop()
Stop the service: - Remove all JOnAS Containers. - Unbinds all the EJBHome names from JNDI

Specified by:
doStop in class AbsServiceImpl

createContainer

public java.lang.String createContainer(javax.naming.Context ctx)
                                 throws java.lang.Exception
Create a JOnAS Container for all the beans that are described in a .xml file, or belong to .jar file.

Specified by:
createContainer in interface EJBService
Parameters:
ctx - JNDI context in which is found the container configuration.
Returns:
The ObjectName of the MBean associated to the container (i.e. to the deployed module)
Throws:
java.lang.Exception - if an error occur during the creation of the container.

getContainer

public Container getContainer(java.lang.String fileName)
Get the Container by its file name (.xml or .jar)

Specified by:
getContainer in interface EJBService
Parameters:
fileName - given file name on which
Returns:
Container

removeContainer

public void removeContainer(Container cont)
Remove a JOnAS container

Specified by:
removeContainer in interface EJBService
Parameters:
cont - JOnAS container to remove.

listContainers

public Container[] listContainers()
List JOnAS container created by EJB Service

Specified by:
listContainers in interface EJBService
Returns:
an array of Container objects

syncAllEntities

public void syncAllEntities(boolean passivate)
Synchronized all entity bean containers

Specified by:
syncAllEntities in interface EJBService
Specified by:
syncAllEntities in interface EJBServiceImplMBean
Parameters:
passivate - passivate instances after synchronization.

getCurrentNumberOfContainer

public java.lang.Integer getCurrentNumberOfContainer()
MBean method

Specified by:
getCurrentNumberOfContainer in interface EJBServiceImplMBean
Returns:
Integer Total Number of Container currently in JOnAS

getTotalCurrentNumberOfBeanType

public java.lang.Integer getTotalCurrentNumberOfBeanType()
MBean method

Specified by:
getTotalCurrentNumberOfBeanType in interface EJBServiceImplMBean
Returns:
Integer Total Number of Bean Type currently in JOnAS

getTotalCurrentNumberOfBMPType

public java.lang.Integer getTotalCurrentNumberOfBMPType()
MBean method

Specified by:
getTotalCurrentNumberOfBMPType in interface EJBServiceImplMBean
Returns:
Integer Total Number of Bmp Type currently in JOnAS

getTotalCurrentNumberOfCMPType

public java.lang.Integer getTotalCurrentNumberOfCMPType()
MBean method

Specified by:
getTotalCurrentNumberOfCMPType in interface EJBServiceImplMBean
Returns:
Integer Total Number of Cmp Type currently in JOnAS

getTotalCurrentNumberOfSBFType

public java.lang.Integer getTotalCurrentNumberOfSBFType()
MBean method

Specified by:
getTotalCurrentNumberOfSBFType in interface EJBServiceImplMBean
Returns:
Integer Total Number of Sbf Type currently in JOnAS

getTotalCurrentNumberOfSBLType

public java.lang.Integer getTotalCurrentNumberOfSBLType()
MBean method

Specified by:
getTotalCurrentNumberOfSBLType in interface EJBServiceImplMBean
Returns:
Integer Total Number of Sbl Type currently in JOnAS

getTotalCurrentNumberOfMDBType

public java.lang.Integer getTotalCurrentNumberOfMDBType()
MBean method

Specified by:
getTotalCurrentNumberOfMDBType in interface EJBServiceImplMBean
Returns:
Integer Total Number of Mdb Type currently in JOnAS

removeContainer

public void removeContainer(java.lang.String fileName)
                     throws java.lang.Exception
Specified by:
removeContainer in interface EJBService
Throws:
java.lang.Exception

removeContainerMBean

public void removeContainerMBean(java.lang.String fileName)
                          throws java.lang.Exception
MBean method remove a container application

Specified by:
removeContainerMBean in interface EJBServiceImplMBean
Parameters:
fileName - the Name of this container
Throws:
java.lang.Exception

createContainer

public java.lang.String createContainer(java.lang.String file)
                                 throws java.lang.Exception
Specified by:
createContainer in interface EJBService
Throws:
java.lang.Exception

createContainerMBean

public java.lang.String createContainerMBean(java.lang.String file)
                                      throws java.lang.Exception
MBean method allowing to create an EJB container for the EJBs contained in a .jar (or .xml) file.

Specified by:
createContainerMBean in interface EJBServiceImplMBean
Parameters:
file - Name of the file to be deployed
Returns:
The ObjectName of the MBean associated to the container (to the deployed module)
Throws:
java.lang.Exception

isJarDeployed

public java.lang.Boolean isJarDeployed(java.lang.String fileName)
Test if the specified file is already deployed (if a container is created for this jar).

Specified by:
isJarDeployed in interface EJBService
Parameters:
fileName - the name of the jar file
Returns:
true if the jar was deployed, false otherwise

isJarDeployedByWorkName

public boolean isJarDeployedByWorkName(java.lang.String workFileName)
Test if the specified jar identified with its work name is already deployed (if a container is created for this jar).

Specified by:
isJarDeployedByWorkName in interface EJBService
Parameters:
workFileName - the internal name of the jar file (working copy)
Returns:
true if the jar was deployed, false otherwise

getDataSourceDependence

public java.util.Set getDataSourceDependence(java.lang.String dsName)
MBean method

Specified by:
getDataSourceDependence in interface EJBServiceImplMBean
Returns:
the ObjectName of all the ejbs using this datasource.

getJmsDestinationDependence

public java.util.Set getJmsDestinationDependence(java.lang.String destName)
Manangement method

Specified by:
getJmsDestinationDependence in interface EJBServiceImplMBean
Returns:
the ObjectName of all the ejb using this destination.

getJmsConnectionFactoryDependence

public java.util.Set getJmsConnectionFactoryDependence(java.lang.String cfName)
Management method

Specified by:
getJmsConnectionFactoryDependence in interface EJBServiceImplMBean
Returns:
the ObjectName of all the ejb using this Connection Factory.

getMailFactoryDependence

public java.util.Set getMailFactoryDependence(java.lang.String mfName)
Management method

Specified by:
getMailFactoryDependence in interface EJBServiceImplMBean
Returns:
the ObjectName of all the ejb using a given Mail Factory.

getInstalledJars

public java.util.List getInstalledJars()
                                throws java.lang.Exception
Return the list of installed EJB containers. The JAR files or the directories with expanded EJB container are searched in JONAS_BASE/ejbjars and all ejbjar directories 'autoload'.

Specified by:
getInstalledJars in interface EJBServiceImplMBean
Returns:
The list of JAR files or the directories with expanded EJB container found
Throws:
java.lang.Exception - if the list can't be retrieved

deployJars

public void deployJars(javax.naming.Context ctx)
                throws ServiceException
Deploy the given ejb-jars of an ear file with the specified parent classloader (ear classloader). (This method is only used for the ear applications, not for the ejb-jar applications).

Specified by:
deployJars in interface EJBService
Parameters:
ctx - the context containing the configuration to deploy the ejbjars.
This context contains the following parameters :
- earRootUrl the root of the ear application.
- earURL filename of the EAR.
- earClassLoader the ear classLoader of the ear application.
- ejbClassLoader the ejb classLoader for the ejbjars.
- jarURLs the list of the urls of the ejb-jars to deploy.
- roleNames the role names of the security-role.
Throws:
ServiceException - if an error occurs during the deployment.

unDeployJars

public void unDeployJars(java.net.URL[] urls)
Undeploy the given ejb-jars of an ear file. (This method is only used for the ear applications, not for the ejb-jar applications).

Specified by:
unDeployJars in interface EJBService
Parameters:
urls - the list of the urls of the ejb-jars to undeploy.

removeContainer

public void removeContainer(Container cont,
                            boolean isEarCase)
Remove the specified container.

Parameters:
cont - the container to remove.
isEarCase - true if only if the removeContainer method is called in the ear case, false otherwise.

removeCache

public void removeCache(java.lang.ClassLoader earClassLoader)
Make a cleanup of the cache of deployment descriptor. This method must be invoked after the ear deployment by the EAR service. the deployment of an ear by .

Specified by:
removeCache in interface EJBService
Parameters:
earClassLoader - the ClassLoader of the ear application to remove from the cache.

isJarLoaded

public boolean isJarLoaded(java.lang.String fileName)
Test if the specified filename is already deployed or not

Specified by:
isJarLoaded in interface EJBServiceImplMBean
Parameters:
fileName - the name of the jar file.
Returns:
true if the jar is deployed, else false.

getDeployedJars

public java.util.List getDeployedJars()
Return the list of all loaded EJB container.

Specified by:
getDeployedJars in interface EJBServiceImplMBean
Returns:
The list of deployed EJB container

getDeployableJars

public java.util.List getDeployableJars()
                                 throws java.lang.Exception
Return the list of installed EJB container ready to deploy.

Specified by:
getDeployableJars in interface EJBServiceImplMBean
Returns:
The list of deployable EJB container
Throws:
java.lang.Exception - when cannot get installed jars list

getAutoloadDirectories

public java.util.List getAutoloadDirectories()
Return the list of "autoload" directories for EJB containers.

Specified by:
getAutoloadDirectories in interface EJBServiceImplMBean
Returns:
The list of all "autoload" directories

getEjbjarsDirectory

public java.lang.String getEjbjarsDirectory()
Return the Ejbjars directory.

Specified by:
getEjbjarsDirectory in interface EJBService
Specified by:
getEjbjarsDirectory in interface EJBServiceImplMBean
Returns:
The Ejbjars directory

buildEJBModuleName

public static java.lang.String buildEJBModuleName(java.net.URL pUrl)
Build the EJBModule name.

Parameters:
pUrl - The URL of Jar file
Returns:
The EJBModule name

buildEJBModuleName

public static java.lang.String buildEJBModuleName(java.lang.String pFilename)
Build the EJBModule name.

Parameters:
pFilename - The name of Jar file
Returns:
The EJBModule name

checkGenIC

public void checkGenIC(java.lang.String fileName,
                       java.net.URL[] urls)
Check that GenIC have been applied on the given ejb-jar file If it was not done, it run GenIC against the file.

Specified by:
checkGenIC in interface EJBService
Parameters:
fileName - given EJB-JAR file.
urls - Array of URLs used as CLASSPATH during EJB compilation