org.objectweb.jonas.web
Class AbsJWebContainerServiceImpl

java.lang.Object
  extended by javax.management.NotificationBroadcasterSupport
      extended by org.objectweb.jonas.management.reconfig.emitter.ReconfigEmitter
          extended by org.objectweb.jonas.service.AbsServiceImpl
              extended by org.objectweb.jonas.web.AbsJWebContainerServiceImpl
All Implemented Interfaces:
NotificationBroadcaster, NotificationEmitter, Service, AbsJWebContainerServiceImplMBean, JWebContainerService
Direct Known Subclasses:
Jetty6Service, Tomcat6Service

public abstract class AbsJWebContainerServiceImpl
extends AbsServiceImpl
implements JWebContainerService, AbsJWebContainerServiceImplMBean

This abstract class provides an implementation for a dynamic JWebContainerService service.

Author:
Florent Benoit, Ludovic Bert (J2EE 1.3), Nicolas Van Caneghem (exploded ear), Michel-Ange Anton (contributor)

Nested Class Summary
 class AbsJWebContainerServiceImpl.WebLoaderHolder
          Holds the ClassLoader used to retrieve the WebApp JNDI Context and the JOnAS Webapp ClasLoader
 
Field Summary
static String AUTOLOADDIR
          Web service configuration properties : Autdeployed the files in these directories
static String CLASS
          Web service configuration properties : Implementation of the web container
static String DESCRIPTORS
          Web service configuration properties : Files deployed
protected static String INEAR_WORK_WEBAPPS_DIR_SUFFIX
          The name of the property used in work directory for EAR webapps (in ear case).
protected  JmxService jmx
          JMX Service
protected static String JONAS_BASE
          The name of the JONAS_BASE directory.
static String PARSINGWITHVALIDATION
          Web service configuration properties : Xml parsing with validation
protected static String SINGLE_WORK_WEBAPPS_DIR_SUFFIX
          The name of the property used in work directory for single webapps (not ear case).
protected static String WEBAPPS_DIR
          The name of the webapps directory.
protected static String WORK_DIR
          The name of the working directory.
protected static String WORK_WEBAPPS_DIR
          The name of the working apps directory.
 
Fields inherited from class org.objectweb.jonas.management.reconfig.emitter.ReconfigEmitter
RECONFIG_TYPE, SAVE_RECONFIG_TYPE
 
Constructor Summary
AbsJWebContainerServiceImpl()
           
 
Method Summary
 void deployWars(Context ctx)
          Deploy the given wars of an ear file with the specified parent classloader (ejb classloader or ear classloader).
protected  void doInit(Context ctx)
          Initialize the service.
protected abstract  void doRegisterWar(Context ctx)
          Create the environment and delegate the operation to the implementation of the web container.
protected  void doStart()
          Start the service.
protected  void doStop()
          Stop the service.
protected abstract  void doUnRegisterWar(Context ctx)
          Delegate the unregistration to the implementation of the web container.
 List getAutoloadDirectories()
          Return the list of "autoload" directories for web applications.
 URLClassLoader getClassLoader(URL warURL, String earAppName, ClassLoader parentLoader)
          Return the class loader of the given warURL.
protected  JComponentContextFactory getContextFactory()
           
 ClassLoader getContextLinkedClassLoader(URL warURL)
           
 Integer getCurrentNumberOfWars()
           
abstract  String getDefaultHost()
          Return the Default host name of the web container.
abstract  String getDefaultHttpPort()
          Return the Default HTTP port number of the web container (can be null if multiple HTTP connector has been set).
abstract  String getDefaultHttpsPort()
          Return the Default HTTPS port number of the web container (can be null if multiple HTTPS connector has been set).
 List getDeployableWars()
          Return the list of installed web applications ready to deploy.
 List getDeployedWars()
          Return the list of all loaded web applications.
 List getInstalledWars()
          Return the list of installed web applications.
protected static org.objectweb.util.monolog.api.Logger getLogger()
           
protected  JNamingManager getNaming()
           
 String getServerName()
          Gets the name of the server which is the web container
 String getServerVersion()
          Gets the version of the server which is the web container
protected  URL getUnpackDir(URL warURL, String earAppName)
          Return the URL where warURL has been unpacked.
 War getWar(URL url)
          Get the war identified by its URL (.war).
 Set getWarNames()
          This method is added temporarily.
 String getWarsDirectory()
          Return the webapps directory.
 boolean isWarLoaded(String fileName)
          Test if the specified filename is already deployed or not
 void registerWar(String fileName)
          Register a WAR by delegating the operation to the registerWar() method.
 void removeCache(ClassLoader earClassLoader)
          Make a cleanup of the cache of deployment descriptor.
protected  void setServerName(String serverName)
           
protected  void setServerVersion(String serverVersion)
           
 void unDeployWars(URL[] urls)
          Undeploy the given wars of an ear file with the specified parent classloader (ejb classloader or ear classloader).
 void unRegisterWar(String fileName)
          Unregister a WAR by delegating the operation to the unRegisterWar() method.
protected abstract  void updateServerInfos()
          Update info of the serverName and serverVersion
 
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.reconfig.emitter.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, 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 String JONAS_BASE
The name of the JONAS_BASE directory.


WEBAPPS_DIR

protected static final String WEBAPPS_DIR
The name of the webapps directory.


WORK_DIR

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


WORK_WEBAPPS_DIR

protected static final String WORK_WEBAPPS_DIR
The name of the working apps directory.


SINGLE_WORK_WEBAPPS_DIR_SUFFIX

protected static final String SINGLE_WORK_WEBAPPS_DIR_SUFFIX
The name of the property used in work directory for single webapps (not ear case).

See Also:
Constant Field Values

INEAR_WORK_WEBAPPS_DIR_SUFFIX

protected static final String INEAR_WORK_WEBAPPS_DIR_SUFFIX
The name of the property used in work directory for EAR webapps (in ear case).

See Also:
Constant Field Values

DESCRIPTORS

public static final String DESCRIPTORS
Web service configuration properties : Files deployed

See Also:
Constant Field Values

AUTOLOADDIR

public static final String AUTOLOADDIR
Web service configuration properties : Autdeployed the files in these directories

See Also:
Constant Field Values

PARSINGWITHVALIDATION

public static final String PARSINGWITHVALIDATION
Web service configuration properties : Xml parsing with validation

See Also:
Constant Field Values

CLASS

public static final String CLASS
Web service configuration properties : Implementation of the web container

See Also:
Constant Field Values

jmx

protected JmxService jmx
JMX Service

Constructor Detail

AbsJWebContainerServiceImpl

public AbsJWebContainerServiceImpl()
Method Detail

doInit

protected void doInit(Context ctx)
               throws ServiceException
Initialize the service.

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

doStart

protected void doStart()
                throws ServiceException
Start the service.

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

doStop

protected void doStop()
               throws ServiceException
Stop the service.

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

doRegisterWar

protected abstract void doRegisterWar(Context ctx)
                               throws JWebContainerServiceException
Create the environment and delegate the operation to the implementation of the web container.

Parameters:
ctx - the context which contains the configuration in order to deploy a WAR.
Throws:
JWebContainerServiceException - if the registration of the WAR failed.

doUnRegisterWar

protected abstract void doUnRegisterWar(Context ctx)
                                 throws JWebContainerServiceException
Delegate the unregistration to the implementation of the web container.

Parameters:
ctx - the context which contains the configuration in order to undeploy a WAR.
Throws:
JWebContainerServiceException - if the unregistration failed.

getUnpackDir

protected URL getUnpackDir(URL warURL,
                           String earAppName)
                    throws JWebContainerServiceException
Return the URL where warURL has been unpacked.

Parameters:
warURL - the URL of the war
earAppName - EAR Application name (can be null if not in EAR case)
Returns:
the URL where warURL has been unpacked.
Throws:
JWebContainerServiceException - when it is impossible to retrieve the unpacked URL.

getClassLoader

public URLClassLoader getClassLoader(URL warURL,
                                     String earAppName,
                                     ClassLoader parentLoader)
                              throws JWebContainerServiceException
Return the class loader of the given warURL. Unpack the associated war and build the loader if it's not in the cache.

Specified by:
getClassLoader in interface JWebContainerService
Parameters:
warURL - the url of the war we want to get the loader
earAppName - the name of the ear application containing the war. May be null in non ear case.
parentLoader - the ejb class loader of the ear. May be null in non ear case.
Returns:
the class loader of the given warURL.
Throws:
JWebContainerServiceException - if the process failed.

getContextLinkedClassLoader

public ClassLoader getContextLinkedClassLoader(URL warURL)
Specified by:
getContextLinkedClassLoader in interface JWebContainerService
Parameters:
warURL - the URL of the webapp
Returns:
Returns the ClassLoader used to link a JNDI environnment to a webapp

registerWar

public void registerWar(String fileName)
                 throws RemoteException,
                        JWebContainerServiceException
Register a WAR by delegating the operation to the registerWar() method. This is used for JMX management.

Specified by:
registerWar in interface AbsJWebContainerServiceImplMBean
Specified by:
registerWar in interface JWebContainerService
Parameters:
fileName - the name of the war to deploy.
Throws:
RemoteException - if rmi call failed.
JWebContainerServiceException - if the registration failed.

unRegisterWar

public void unRegisterWar(String fileName)
                   throws RemoteException,
                          JWebContainerServiceException
Unregister a WAR by delegating the operation to the unRegisterWar() method. This is used for JMX management.

Specified by:
unRegisterWar in interface AbsJWebContainerServiceImplMBean
Specified by:
unRegisterWar in interface JWebContainerService
Parameters:
fileName - the name of the war to undeploy.
Throws:
RemoteException - if rmi call failed.
JWebContainerServiceException - if the unregistration failed.

deployWars

public void deployWars(Context ctx)
                throws JWebContainerServiceException
Deploy the given wars of an ear file with the specified parent classloader (ejb classloader or ear classloader). (This method is only used for the ear applications, not for the web applications).

Specified by:
deployWars in interface JWebContainerService
Parameters:
ctx - the context containing the configuration to deploy the wars.
This context contains the following parameters :
- urls the list of the urls of the wars to deploy.
- earURL the URL of the ear application file.
- parentClassLoader the parent classLoader of the wars.
- earClassLoader the ear classLoader of the j2ee app.
- altDDs the optional URI of deployment descriptor.
- contextRoots the optional context root of the wars.
Throws:
JWebContainerServiceException - if an error occurs during the deployment.

unDeployWars

public void unDeployWars(URL[] urls)
Undeploy the given wars of an ear file with the specified parent classloader (ejb classloader or ear classloader). (This method is only used for the ear applications, not for the war applications).

Specified by:
unDeployWars in interface JWebContainerService
Parameters:
urls - the list of the urls of the wars to undeploy.

getWar

public War getWar(URL url)
Get the war identified by its URL (.war).

Parameters:
url - the URL of the war to get.
Returns:
the war indentified by its URL, or null if the war is not found.

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.

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

getCurrentNumberOfWars

public Integer getCurrentNumberOfWars()
Specified by:
getCurrentNumberOfWars in interface AbsJWebContainerServiceImplMBean
Returns:
current number of wars deployed in the JOnAS server

getInstalledWars

public List getInstalledWars()
                      throws Exception
Return the list of installed web applications. The WAR files or the directories with expanded web application are searched in JONAS_BASE/webapps and all webapps directories 'autoload'.

Specified by:
getInstalledWars in interface AbsJWebContainerServiceImplMBean
Returns:
The list of WAR files or the directories with expanded web application found
Throws:
Exception - if the list can't be retrieved

getWarNames

public Set getWarNames()
This method is added temporarily. It will disapear when Wars will have their associated MBeans (when Wars will become manageable)

Specified by:
getWarNames in interface AbsJWebContainerServiceImplMBean
Returns:
the names of the wars currently deployed in the JOnAS server

isWarLoaded

public boolean isWarLoaded(String fileName)
Test if the specified filename is already deployed or not

Specified by:
isWarLoaded in interface AbsJWebContainerServiceImplMBean
Specified by:
isWarLoaded in interface JWebContainerService
Parameters:
fileName - the name of the war file.
Returns:
true if the war is deployed, else false.

getDeployedWars

public List getDeployedWars()
Return the list of all loaded web applications.

Specified by:
getDeployedWars in interface AbsJWebContainerServiceImplMBean
Returns:
The list of deployed web applications

getDeployableWars

public List getDeployableWars()
                       throws Exception
Return the list of installed web applications ready to deploy.

Specified by:
getDeployableWars in interface AbsJWebContainerServiceImplMBean
Returns:
The list of deployable web applications
Throws:
Exception - if the list can't be retrieved

getAutoloadDirectories

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

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

getWarsDirectory

public String getWarsDirectory()
Return the webapps directory.

Specified by:
getWarsDirectory in interface AbsJWebContainerServiceImplMBean
Returns:
The webapps directory

getServerName

public String getServerName()
Gets the name of the server which is the web container

Specified by:
getServerName in interface AbsJWebContainerServiceImplMBean
Returns:
the name of the server which is the web container

getServerVersion

public String getServerVersion()
Gets the version of the server which is the web container

Specified by:
getServerVersion in interface AbsJWebContainerServiceImplMBean
Returns:
the version of the server which is the web container

updateServerInfos

protected abstract void updateServerInfos()
Update info of the serverName and serverVersion


getDefaultHost

public abstract String getDefaultHost()
                               throws JWebContainerServiceException
Return the Default host name of the web container.

Specified by:
getDefaultHost in interface JWebContainerService
Returns:
the Default host name of the web container.
Throws:
JWebContainerServiceException - when it is impossible to get the Default Host.

getDefaultHttpPort

public abstract String getDefaultHttpPort()
                                   throws JWebContainerServiceException
Return the Default HTTP port number of the web container (can be null if multiple HTTP connector has been set).

Specified by:
getDefaultHttpPort in interface JWebContainerService
Returns:
the Default HTTP port number of the web container.
Throws:
JWebContainerServiceException - when it is impossible to get the Default Http port.

getDefaultHttpsPort

public abstract String getDefaultHttpsPort()
                                    throws JWebContainerServiceException
Return the Default HTTPS port number of the web container (can be null if multiple HTTPS connector has been set).

Specified by:
getDefaultHttpsPort in interface JWebContainerService
Returns:
the Default HTTPS port number of the web container.
Throws:
JWebContainerServiceException - when it is impossible to get the Default Https port.

getLogger

protected static org.objectweb.util.monolog.api.Logger getLogger()
Returns:
Returns the logger.

getNaming

protected JNamingManager getNaming()
Returns:
Returns the naming.

setServerName

protected void setServerName(String serverName)
Parameters:
serverName - The serverName to set.

setServerVersion

protected void setServerVersion(String serverVersion)
Parameters:
serverVersion - The serverVersion to set.

getContextFactory

protected JComponentContextFactory getContextFactory()


Copyright © 2007 OW2 Consortium. All Rights Reserved.