org.ow2.jonas.ejb2.internal
Class JOnASEJBService

java.lang.Object
  extended by javax.management.NotificationBroadcasterSupport
      extended by org.ow2.jonas.lib.reconfig.ReconfigEmitter
          extended by org.ow2.jonas.lib.service.AbsServiceImpl
              extended by org.ow2.jonas.ejb2.internal.JOnASEJBService
All Implemented Interfaces:
NotificationBroadcaster, NotificationEmitter, EJBService, JOnASEJBServiceMBean, Service

public class JOnASEJBService
extends AbsServiceImpl
implements EJBService, JOnASEJBServiceMBean

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), S. Ali Tokmen (versioning), S. Ali Tokmen, Malek Chahine: EJB statistics

Field Summary
static String BMP
          BeanManaged Management properties.
static String CMP
          ContainerManaged Management properties.
protected static String WORK_DIR
          The name of the working directory.
protected static String WORK_EJBJARS_DIR
          The name of the working ejbjars directory.
 
Fields inherited from class org.ow2.jonas.lib.reconfig.ReconfigEmitter
RECONFIG_TYPE, SAVE_RECONFIG_TYPE
 
Constructor Summary
JOnASEJBService()
          Default constructor.
 
Method Summary
 void applyMonitorSettings(String scope)
          Applies the current monitoring settings to deployed EJBs.
 void checkGenIC(String fileName, 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.
 String createContainer(Context ctx)
          Create a JOnAS Container for all the beans that are described in a .xml file, or belong to .jar file.
 String createContainer(String fileName)
          Create an ejb container for the EJBs contained in a .jar (or .xml) file.
 void deployJars(Context ctx)
          Deploy the given ejb-jars of an ear file with the specified parent classloader (ear classloader).
 void doStart()
          Start the Service Initialization of the service is already done.
 void doStop()
          Stop the service.
 long getAverageBusinessProcessingTime()
          get the average time spent in business execution for all beans of this ejb container per request
 long getAverageProcessingTime()
          get the average time spent in container + business execution for all beans of this ejb container per request
 CmiService getCmiService()
           
 Container getContainer(String fileName)
          Get the Container by its file name (.xml or .jar).
 String getContainerContextID(String containerFileName)
          Returns the ContextID associated to this container filename.
 Integer getCurrentNumberOfContainer()
          MBean method.
 Set<ObjectName> getDataSourceDependence(String dsName)
          MBean method.
 List<String> getDeployedJars()
          Return the list of all loaded EJB container.
 org.ow2.util.event.api.IEventService getEventService()
           
 Set<ObjectName> getJmsConnectionFactoryDependence(String cfName)
          MBean method.
 Set<ObjectName> getJmsDestinationDependence(String destName)
          MBean method.
 Set<ObjectName> getMailFactoryDependence(String mfName)
          MBean method.
 boolean getMonitoringEnabled()
           
 long getNumberOfCalls()
          get the total number of calls on all beans of this ejb container
 IResourceCheckerManager getResourceCheckerManager()
           
 Timer getTimer(JTimerHandleInfo info)
          Get a new Timer.
 long getTotalBusinessProcessingTime()
          get the total time spent in business execution for all beans of this ejb container
 Integer getTotalCurrentNumberOfBeanType()
          MBean method.
 Integer getTotalCurrentNumberOfBMPType()
          MBean method.
 Integer getTotalCurrentNumberOfCMPType()
          MBean method.
 Integer getTotalCurrentNumberOfMDBType()
          MBean method.
 Integer getTotalCurrentNumberOfSBFType()
          MBean method.
 Integer getTotalCurrentNumberOfSBLType()
          MBean method.
 long getTotalProcessingTime()
          get the total time spent in container + business execution for all beans of this ejb container
 VersioningService getVersioningService()
           
 int getWarningThreshold()
           
protected  void initWorkingDirectory()
          Create working directory for EJB2.
 Boolean isJarDeployed(String fileName)
          Test if the specified file is already deployed (if a container is created for this jar).
 boolean isJarDeployedByWorkName(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(String fileName)
          Test if the specified filename is already deployed or not.
 boolean isVersioningEnabled()
           
 Container[] listContainers()
           
 void removeCache(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(String fileName)
          Remove EJB container corresponding to a .JAR file.
 Timer restartTimer(JTimerHandleInfo info)
          Restart a Timer given some input infos.
 void setAutoGenic(boolean autoGenIC)
           
 void setAutoGenicArgs(String args)
           
 void setCmiService(CmiService cmiService)
          Set the reference on CMI service.
 void setComponentContextFactory(JComponentContextFactory componentContextFactory)
           
 void setDeployerManager(org.ow2.util.ee.deploy.api.deployer.IDeployerManager deployerManager)
           
 void setEventService(org.ow2.util.event.api.IEventService eventService)
           
 void setHaService(HaService haService)
          Set the reference on HA service.
 void setJmxService(JmxService jmxService)
           
 void setMonitoringEnabled(boolean monitoringEnabled)
           
 void setNaming(JNamingManager naming)
           
 void setParsingwithvalidation(boolean validate)
           
 void setRegistry(RegistryService registry)
           
 void setResourceCheckerManager(IResourceCheckerManager resourceCheckerManager)
          Sets the resource checker manager.
 void setResourceService(ResourceService resService)
          Set the reference on resource service.
 void setSecurityService(SecurityService securityService)
           
 void setTransactionService(TransactionService transactionService)
           
 void setVersioningService(VersioningService versioningService)
           
 void setWarningThreshold(int warningThreshold)
           
 void setWebServicesService(IJAXRPCService jaxrpcService)
           
protected  void setWorkCleanerService(WorkCleanerService workCleanerService)
          Method called when the workCleanerService is bound to the component.
 void setWorkManagerService(WorkManagerService workManagerService)
           
 void syncAllEntities(boolean passivate)
          Synchronized all entity bean containers.
 void unDeployJars(URL[] urls)
          Undeploy the given ejb-jars of an ear file.
 void unsetResourceCheckerManager()
          Unset the resource checker manager.
 void unsetVersioningService()
          Sets the versioning service to null.
 
Methods inherited from class org.ow2.jonas.lib.service.AbsServiceImpl
convertToList, doInit, getDomainName, getJonasServerName, getName, getServerProperties, init, isStarted, setName, setServerProperties, start, stop, throwRequirementException, toString
 
Methods inherited from class org.ow2.jonas.lib.reconfig.ReconfigEmitter
initLogger, sendReconfigNotification, sendSaveNotification
 
Methods inherited from class javax.management.NotificationBroadcasterSupport
addNotificationListener, getNotificationInfo, handleNotification, removeNotificationListener, removeNotificationListener, sendNotification
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 
Methods inherited from interface org.ow2.jonas.service.Service
getName, init, isStarted, setName, start, stop
 

Field Detail

WORK_DIR

protected static final String WORK_DIR
The name of the working directory.


WORK_EJBJARS_DIR

protected static final String WORK_EJBJARS_DIR
The name of the working ejbjars directory.


BMP

public static final String BMP
BeanManaged Management properties.

See Also:
Constant Field Values

CMP

public static final String CMP
ContainerManaged Management properties.

See Also:
Constant Field Values
Constructor Detail

JOnASEJBService

public JOnASEJBService()
Default constructor.

Method Detail

setAutoGenic

public void setAutoGenic(boolean autoGenIC)
Parameters:
autoGenIC - Engage Auto GenIC ?

setParsingwithvalidation

public void setParsingwithvalidation(boolean validate)
Parameters:
validate - Use a validating parser ?

setAutoGenicArgs

public void setAutoGenicArgs(String args)
Parameters:
args - List of arguments to the Auto-GenIC process.

doStart

public void doStart()
             throws ServiceException
Start the Service Initialization of the service is already done. Abstract start-up method to be implemented by sub-classes.

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

doStop

public void doStop()
Stop the service.

Specified by:
doStop in class AbsServiceImpl

initWorkingDirectory

protected void initWorkingDirectory()
Create working directory for EJB2.


setWorkCleanerService

protected void setWorkCleanerService(WorkCleanerService workCleanerService)
Method called when the workCleanerService is bound to the component.

Parameters:
workCleanerService - the workCleanerService reference

createContainer

public String createContainer(Context ctx)
                       throws 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 - Deployment context holding all needed values for an EjbJar deployment.
Returns:
The ObjectName of the MBean associated to the container (i.e. to the deployed module)
Throws:
Exception - if an error occur during the creation of the container.

getContainer

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

Parameters:
fileName - given file name on which
Returns:
Container

removeContainer

public void removeContainer(Container cont)
Remove a JOnAS container.

Parameters:
cont - EJB 2.1 Container to be removed

listContainers

public Container[] listContainers()
Returns:
JOnAS containers created by the EJB Service.

syncAllEntities

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

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

getCurrentNumberOfContainer

public Integer getCurrentNumberOfContainer()
MBean method.

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

getTotalCurrentNumberOfBeanType

public Integer getTotalCurrentNumberOfBeanType()
MBean method.

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

getTotalCurrentNumberOfBMPType

public Integer getTotalCurrentNumberOfBMPType()
MBean method.

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

getTotalCurrentNumberOfCMPType

public Integer getTotalCurrentNumberOfCMPType()
MBean method.

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

getTotalCurrentNumberOfSBFType

public Integer getTotalCurrentNumberOfSBFType()
MBean method.

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

getTotalCurrentNumberOfSBLType

public Integer getTotalCurrentNumberOfSBLType()
MBean method.

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

getTotalCurrentNumberOfMDBType

public Integer getTotalCurrentNumberOfMDBType()
MBean method.

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

getDeployedJars

public List<String> getDeployedJars()
Return the list of all loaded EJB container.

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

removeContainer

public void removeContainer(String fileName)
                     throws Exception
Remove EJB container corresponding to a .JAR file. This method is called by the J2EEServer MBean's undeployJar(fileName)

Specified by:
removeContainer in interface EJBService
Parameters:
fileName - name of the file containing the JAR module
Throws:
Exception - when there is no such container to undeploy or when the service was unable to undeploy the container.

createContainer

public String createContainer(String fileName)
                       throws Exception
Create an ejb container for the EJBs contained in a .jar (or .xml) file.

Specified by:
createContainer in interface EJBService
Parameters:
fileName - Name of the file to be deployed
Returns:
The ObjectName of the MBean associated to the container (to the deployed module)
Throws:
Exception - when the EjbJar cannot be deployed.

isJarDeployed

public Boolean isJarDeployed(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(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 Set<ObjectName> getDataSourceDependence(String dsName)
MBean method.

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

getJmsDestinationDependence

public Set<ObjectName> getJmsDestinationDependence(String destName)
MBean method.

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

getJmsConnectionFactoryDependence

public Set<ObjectName> getJmsConnectionFactoryDependence(String cfName)
MBean method.

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

getMailFactoryDependence

public Set<ObjectName> getMailFactoryDependence(String mfName)
MBean method.

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

deployJars

public void deployJars(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(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(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(String fileName)
Test if the specified filename is already deployed or not.

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

checkGenIC

public void checkGenIC(String fileName,
                       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

getContainerContextID

public String getContainerContextID(String containerFileName)
Returns the ContextID associated to this container filename. Used by the EARService for security purpose.

Specified by:
getContainerContextID in interface EJBService
Parameters:
containerFileName - container filename
Returns:
Returns the ContextID associated to this container filename.

getTimer

public Timer getTimer(JTimerHandleInfo info)
Get a new Timer.

Specified by:
getTimer in interface EJBService
Parameters:
info - JTimerHandleInfo instance used for Timer creation.
Returns:
a newly created Timer

restartTimer

public Timer restartTimer(JTimerHandleInfo info)
Restart a Timer given some input infos.

Specified by:
restartTimer in interface EJBService
Parameters:
info - JTimerHandleInfo instance used for Timer restart.
Returns:
a newly restarted Timer.

setJmxService

public void setJmxService(JmxService jmxService)
Parameters:
jmxService - the jmxService to set

setSecurityService

public void setSecurityService(SecurityService securityService)
Parameters:
securityService - the securityService to set

setTransactionService

public void setTransactionService(TransactionService transactionService)
Parameters:
transactionService - the transactionService to set

setWorkManagerService

public void setWorkManagerService(WorkManagerService workManagerService)
Parameters:
workManagerService - the workManagerService to set

setWebServicesService

public void setWebServicesService(IJAXRPCService jaxrpcService)
Parameters:
jaxrpcService - the jaxrpcService to set

setNaming

public void setNaming(JNamingManager naming)
Parameters:
naming - the naming to set

setComponentContextFactory

public void setComponentContextFactory(JComponentContextFactory componentContextFactory)
Parameters:
componentContextFactory - the componentContextFactory to set

setRegistry

public void setRegistry(RegistryService registry)
Parameters:
registry - the registry to set

setHaService

public void setHaService(HaService haService)
Set the reference on HA service.

Parameters:
haService - the reference on HA service

setResourceService

public void setResourceService(ResourceService resService)
Set the reference on resource service.

Parameters:
resService - the reference on Resource service

getCmiService

public CmiService getCmiService()
Returns:
the reference on CMI service

setCmiService

public void setCmiService(CmiService cmiService)
Set the reference on CMI service.

Parameters:
cmiService - the reference on CMI service

setDeployerManager

public void setDeployerManager(org.ow2.util.ee.deploy.api.deployer.IDeployerManager deployerManager)
Parameters:
deployerManager - the IDeployerManager to set

setVersioningService

public void setVersioningService(VersioningService versioningService)
Parameters:
versioningService - The versioning service to set.

unsetVersioningService

public void unsetVersioningService()
Sets the versioning service to null.


getVersioningService

public VersioningService getVersioningService()
Returns:
The versioning service.

isVersioningEnabled

public boolean isVersioningEnabled()
Returns:
Whether versioning is enabled.

getMonitoringEnabled

public boolean getMonitoringEnabled()
Specified by:
getMonitoringEnabled in interface JOnASEJBServiceMBean
Returns:
Will EJB monitoring enabled for EJBs deployed in the future?

setMonitoringEnabled

public void setMonitoringEnabled(boolean monitoringEnabled)
Specified by:
setMonitoringEnabled in interface JOnASEJBServiceMBean
Parameters:
monitoringEnabled - Whether EJB monitoring will enabled for EJBs deployed in the future.

getWarningThreshold

public int getWarningThreshold()
Specified by:
getWarningThreshold in interface JOnASEJBServiceMBean
Returns:
Number of milliseconds after which methods of EJBs deployed in the future will start warning.

setWarningThreshold

public void setWarningThreshold(int warningThreshold)
Specified by:
setWarningThreshold in interface JOnASEJBServiceMBean
Parameters:
warningThreshold - Number of milliseconds after which methods of EJBs deployed in the future will start warning.

getNumberOfCalls

public long getNumberOfCalls()
get the total number of calls on all beans of this ejb container

Specified by:
getNumberOfCalls in interface JOnASEJBServiceMBean
Returns:
the total number of calls on all beans of this ejb container

getTotalProcessingTime

public long getTotalProcessingTime()
get the total time spent in container + business execution for all beans of this ejb container

Specified by:
getTotalProcessingTime in interface JOnASEJBServiceMBean
Returns:
the total time spent in container + business execution for all beans of this ejb container

getTotalBusinessProcessingTime

public long getTotalBusinessProcessingTime()
get the total time spent in business execution for all beans of this ejb container

Specified by:
getTotalBusinessProcessingTime in interface JOnASEJBServiceMBean
Returns:
the total time spent in business execution for all beans of this ejb container

getAverageProcessingTime

public long getAverageProcessingTime()
get the average time spent in container + business execution for all beans of this ejb container per request

Specified by:
getAverageProcessingTime in interface JOnASEJBServiceMBean
Returns:
the average time spent in container + business execution for all beans of this ejb container per request

getAverageBusinessProcessingTime

public long getAverageBusinessProcessingTime()
get the average time spent in business execution for all beans of this ejb container per request

Specified by:
getAverageBusinessProcessingTime in interface JOnASEJBServiceMBean
Returns:
the average time spent in business execution for all beans of this ejb container per request

applyMonitorSettings

public void applyMonitorSettings(String scope)
Applies the current monitoring settings to deployed EJBs.

Specified by:
applyMonitorSettings in interface JOnASEJBServiceMBean

setEventService

public void setEventService(org.ow2.util.event.api.IEventService eventService)
Parameters:
eventService - IEventService to set.

getEventService

public org.ow2.util.event.api.IEventService getEventService()
Returns:
IEventService in use.

getResourceCheckerManager

public IResourceCheckerManager getResourceCheckerManager()
Returns:
the resource checker manager

setResourceCheckerManager

public void setResourceCheckerManager(IResourceCheckerManager resourceCheckerManager)
Sets the resource checker manager.

Parameters:
resourceCheckerManager - the given instance

unsetResourceCheckerManager

public void unsetResourceCheckerManager()
Unset the resource checker manager.



Copyright © 2010 OW2 Consortium. All Rights Reserved.