org.objectweb.jonas.ear
Class EarServiceImpl

java.lang.Object
  extended byjavax.management.NotificationBroadcasterSupport
      extended byorg.objectweb.jonas.management.ReconfigDispatcher
          extended byorg.objectweb.jonas.service.AbsServiceImpl
              extended byorg.objectweb.jonas.ear.EarServiceImpl
All Implemented Interfaces:
EarService, EarServiceImplMBean, javax.management.NotificationBroadcaster, javax.management.NotificationEmitter, ReconfigDispatcherMBean, Service

public class EarServiceImpl
extends AbsServiceImpl
implements EarService, EarServiceImplMBean

JOnAS EAR Service Implementation class. This class provides an implementation of the ear service.

Author:
Florent Benoit, Ludovic Bert Contributor(s): Adriana Danes: highlight configuration properties Eric Hardesty: added ability to include rar files in an ear Michel-Ange Anton : new JSR77 MBean

Field Summary
protected static java.lang.String APPS_DIR
          The name of the apps directory.
protected static java.lang.String AUTOLOADDIR
          Directories property for autoload
protected static java.lang.String CLASS
          Property for the class of the EAR service
protected static java.lang.String DESCRIPTORS
          Property for ear to deploy at runtime
protected static java.lang.String JONAS_BASE
          The name of the JONAS_BASE directory.
protected static java.lang.String PARSINGWITHVALIDATION
          Property for parsing with validation or not
protected static java.lang.String WORK_APPS_DIR
          The name of the working apps directory.
protected static java.lang.String WORK_DIR
          The name of the working directory.
 
Fields inherited from class org.objectweb.jonas.management.ReconfigDispatcher
RECONFIG_TYPE, SAVE_RECONFIG_TYPE
 
Constructor Summary
EarServiceImpl()
           
 
Method Summary
static java.lang.String buildJ2eeApplicationName(java.lang.String pFilename)
          Build the J2EEApplication name.
static java.lang.String buildJ2eeApplicationName(java.net.URL pUrl)
          Build the J2EEApplication name.
 java.lang.String deployEar(javax.naming.Context ctx)
          Deploy an EAR file with sending JAR file to the EJB container and WAR file to the WEB container and RAR file to the resource service.
 java.lang.String deployEar(java.lang.String fileName)
          Deploy an ear with its given fileName
 java.lang.String deployEarMBean(java.lang.String fileName)
          Deploy an EAR by delegating the operation to the deployEar() method.
protected  void doInit(javax.naming.Context ctx)
          Init the EAR service.
protected  void doStart()
          Start the EAR service.
protected  void doStop()
          Stop the EAR service.
 java.lang.String getAppsDirectory()
          Return the Apps directory.
 java.util.List getAutoloadDirectories()
          Return the list of "autoload" directories for applications.
 java.lang.Integer getCurrentNumberOfEars()
           
 java.util.List getDeployableEars()
          Return the list of installed Applications ready to deploy.
 java.util.List getDeployedEars()
          Return the list of all loaded Applications.
 java.util.Set getEarNames()
          This method is added temporarily.
 java.util.List getInstalledEars()
          Return the list of installed Applications.
 java.lang.Boolean isEarDeployed(java.lang.String fileName)
          Test if the specified filename is already deployed or not.
 boolean isEarDeployedByUnpackName(java.lang.String unpackName)
          Test if the specified unpack name is already deployed or not.
 boolean isEarLoaded(java.lang.String fileName)
          Test if the specified filename is already deployed or not.
 void unDeployEar(javax.naming.Context ctx)
          Undeploy an EAR by sending the request to the EJB container and to the WEB container and the Resource service.
 void unDeployEar(java.lang.String fileName)
          Undeploy an EAR by delegating the operation to the unDeployEar() method.
 void unDeployEarMBean(java.lang.String fileName)
          Undeploy an EAR by delegating the operation to the unDeployEar() method.
 
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

JONAS_BASE

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


APPS_DIR

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


WORK_DIR

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


WORK_APPS_DIR

protected static final java.lang.String WORK_APPS_DIR
The name of the working apps directory.


DESCRIPTORS

protected static final java.lang.String DESCRIPTORS
Property for ear to deploy at runtime

See Also:
Constant Field Values

AUTOLOADDIR

protected static final java.lang.String AUTOLOADDIR
Directories property for autoload

See Also:
Constant Field Values

PARSINGWITHVALIDATION

protected static final java.lang.String PARSINGWITHVALIDATION
Property for parsing with validation or not

See Also:
Constant Field Values

CLASS

protected static final java.lang.String CLASS
Property for the class of the EAR service

See Also:
Constant Field Values
Constructor Detail

EarServiceImpl

public EarServiceImpl()
Method Detail

doInit

protected void doInit(javax.naming.Context ctx)
               throws ServiceException
Init the EAR service.

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

doStop

protected void doStop()
               throws ServiceException
Stop the EAR service.

Specified by:
doStop in class AbsServiceImpl
Throws:
ServiceException - if the stop failed.

deployEar

public java.lang.String deployEar(javax.naming.Context ctx)
                           throws EarServiceException
Deploy an EAR file with sending JAR file to the EJB container and WAR file to the WEB container and RAR file to the resource service.

Specified by:
deployEar in interface EarService
Parameters:
ctx - the context which contains the configuration in order to deploy an EAR.
Returns:
The ObjectName of the J2EE Application MBean associated to the deployed EAR the Application Container
Throws:
EarServiceException - if the deployment of the EAR failed.

deployEar

public java.lang.String deployEar(java.lang.String fileName)
                           throws java.lang.Exception
Deploy an ear with its given fileName

Specified by:
deployEar in interface EarService
Parameters:
fileName - file to deploy (ear)
Returns:
The ObjectName of the J2EE Application MBean associated to the deployed EAR
Throws:
java.lang.Exception - if the deployment of the EAR failed.
See Also:
EarService.deployEar(java.lang.String)

deployEarMBean

public java.lang.String deployEarMBean(java.lang.String fileName)
                                throws java.lang.Exception
Deploy an EAR by delegating the operation to the deployEar() method. This is used by jonasAdmin management application.

Specified by:
deployEarMBean in interface EarServiceImplMBean
Parameters:
fileName - the fileName of the ear which must be be deployed.
Returns:
The ObjectName of the J2EE Application MBean associated to the deployed EAR
Throws:
java.lang.Exception - if the deployment of the EAR failed.

doStart

protected void doStart()
                throws ServiceException
Start the EAR service.

Specified by:
doStart in class AbsServiceImpl
Throws:
ServiceException - if the startup failed.

unDeployEar

public void unDeployEar(javax.naming.Context ctx)
                 throws EarServiceException
Undeploy an EAR by sending the request to the EJB container and to the WEB container and the Resource service.

Specified by:
unDeployEar in interface EarService
Parameters:
ctx - the context which contains the configuration in order to undeploy an EAR.
Throws:
EarServiceException - if the undeployment of the EAR failed.

unDeployEar

public void unDeployEar(java.lang.String fileName)
                 throws java.lang.Exception
Undeploy an EAR by delegating the operation to the unDeployEar() method. This is used for JMX management.

Specified by:
unDeployEar in interface EarService
Parameters:
fileName - the fileName of the ear which must be be undeployed.
Throws:
java.lang.Exception - if the undeployment of the EAR failed.
See Also:
EarService.unDeployEar(java.lang.String)

unDeployEarMBean

public void unDeployEarMBean(java.lang.String fileName)
                      throws java.lang.Exception
Undeploy an EAR by delegating the operation to the unDeployEar() method. This is used for JMX management.

Specified by:
unDeployEarMBean in interface EarServiceImplMBean
Parameters:
fileName - the fileName of the ear which must be be undeployed.
Throws:
java.lang.Exception - if the undeployment of the EAR failed.

getCurrentNumberOfEars

public java.lang.Integer getCurrentNumberOfEars()
Specified by:
getCurrentNumberOfEars in interface EarServiceImplMBean
Returns:
current number of ears deployed in the JOnAS server

getInstalledEars

public java.util.List getInstalledEars()
                                throws java.lang.Exception
Return the list of installed Applications. The EAR files or the directories with expanded Applications are searched in JONAS_BASE/apps and all Applications directories 'autoload'.

Specified by:
getInstalledEars in interface EarServiceImplMBean
Returns:
The list of EAR files or the directories with expanded Applications found
Throws:
java.lang.Exception - if the list can't be retrieved

getEarNames

public java.util.Set getEarNames()
This method is added temporarily. It will disapear when Ears will have their associated MBeans (when Ears will become manageable)

Specified by:
getEarNames in interface EarServiceImplMBean
Returns:
the names of the ears currently deployed in the JOnAS server

isEarLoaded

public boolean isEarLoaded(java.lang.String fileName)
Test if the specified filename is already deployed or not. This method is a management method provided by the EarServerice MBean.

Specified by:
isEarLoaded in interface EarServiceImplMBean
Parameters:
fileName - the name of the ear file.
Returns:
true if the ear is deployed, else false.

isEarDeployed

public java.lang.Boolean isEarDeployed(java.lang.String fileName)
Test if the specified filename is already deployed or not. This method is defined in the EarService interface.

Specified by:
isEarDeployed in interface EarService
Parameters:
fileName - the name of the ear file.
Returns:
true if the ear is deployed, else false.

isEarDeployedByUnpackName

public boolean isEarDeployedByUnpackName(java.lang.String unpackName)
Test if the specified unpack name is already deployed or not. This method is defined in the EarService interface.

Specified by:
isEarDeployedByUnpackName in interface EarService
Parameters:
unpackName - the name of the ear file.
Returns:
true if the ear is deployed, else false.

getDeployedEars

public java.util.List getDeployedEars()
Return the list of all loaded Applications.

Specified by:
getDeployedEars in interface EarServiceImplMBean
Returns:
The list of deployed Applications

getDeployableEars

public java.util.List getDeployableEars()
                                 throws java.lang.Exception
Return the list of installed Applications ready to deploy.

Specified by:
getDeployableEars in interface EarServiceImplMBean
Returns:
The list of deployable Applications
Throws:
java.lang.Exception - if the list can't be built

getAutoloadDirectories

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

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

getAppsDirectory

public java.lang.String getAppsDirectory()
Return the Apps directory.

Specified by:
getAppsDirectory in interface EarService
Returns:
The Apps directory

buildJ2eeApplicationName

public static java.lang.String buildJ2eeApplicationName(java.net.URL pUrl)
Build the J2EEApplication name.

Parameters:
pUrl - The URL of Ear file
Returns:
The J2EEApplication name

buildJ2eeApplicationName

public static java.lang.String buildJ2eeApplicationName(java.lang.String pFilename)
Build the J2EEApplication name.

Parameters:
pFilename - The name of Ear file
Returns:
The J2EEApplication name