org.objectweb.jonas.web.wrapper.catalina55
Class CatalinaJWebContainerServiceWrapper

java.lang.Object
  extended by org.objectweb.jonas.web.wrapper.catalina55.CatalinaJWebContainerServiceWrapper
All Implemented Interfaces:
Service, AbsJWebContainerServiceImplMBean, JWebContainerService, CatalinaJWebContainerService

public class CatalinaJWebContainerServiceWrapper
extends java.lang.Object
implements CatalinaJWebContainerService, AbsJWebContainerServiceImplMBean

Wrap the Catalina 5.0 Web Container Service because Catalina use Digester to parse its server.xml

Author:
Guillaume Sauthier

Constructor Summary
CatalinaJWebContainerServiceWrapper()
          Construct the instance and init the service.
 
Method Summary
 void deployWars(javax.naming.Context ctx)
          Deploy the given wars of an ear file with the specified parent classloader (ejb classloader or ear classloader).
 java.util.List getAutoloadDirectories()
          Return the list of "autoload" directories for web applications.
 java.net.URLClassLoader getClassLoader(java.net.URL warURL, java.lang.String earAppName, java.lang.ClassLoader parentLoader)
          Return the class loader of the given warURL.
 java.lang.ClassLoader getContextLinkedClassLoader(java.net.URL url)
           
 java.lang.Integer getCurrentNumberOfWars()
           
 java.lang.String getDefaultHost()
          Return the Default host name of the web container.
 java.lang.String getDefaultHttpPort()
          Return the Default HTTP port number of the web container (can be null if multiple HTTP connector has been set).
 java.lang.String getDefaultHttpsPort()
          Return the Default HTTPS port number of the web container (can be null if multiple HTTPS connector has been set).
 java.util.List getDeployableWars()
          Return the list of installed web applications ready to deploy.
 java.util.List getDeployedWars()
          Return the list of all loaded web applications.
 java.util.List getInstalledWars()
          Return the list of installed web applications.
 java.lang.String getName()
           
 java.lang.String getServerName()
          Gets the name of the server which is the web container
 java.lang.String getServerVersion()
          Gets the version of the server which is the web container
 War getWar(java.net.URL url)
          Get the war identified by its URL (.war).
 java.util.Set getWarNames()
          This method is added temporarily.
 java.lang.String getWebappsDirectory()
          Return the WebApps directory.
 void init(javax.naming.Context ctx)
          Initialize the Catalina service.
 boolean isStarted()
           
 boolean isTomcatStarted()
          The server is started ?
 boolean isWarLoaded(java.lang.String fileName)
          Test if the specified filename is already deployed or not
 void registerWarMBean(java.lang.String fileName)
          Register a WAR by delegating the operation to the registerWar() method.
 void removeCache(java.lang.ClassLoader earClassLoader)
          Make a cleanup of the cache of deployment descriptor.
 void setName(java.lang.String name)
          Set the service's name
 void start()
          Start the Catalina service in a new thread
 void stop()
          Stop the Catalina service.
 void unDeployWars(java.net.URL[] urls)
          Undeploy the given wars of an ear file with the specified parent classloader (ejb classloader or ear classloader).
 void unRegisterWarMBean(java.lang.String fileName)
          Unregister a WAR by delegating the operation to the unRegisterWar() method.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

CatalinaJWebContainerServiceWrapper

public CatalinaJWebContainerServiceWrapper()
                                    throws ServiceException
Construct the instance and init the service.

Throws:
ServiceException - when Catalina Loader cannot be found
Method Detail

deployWars

public void deployWars(javax.naming.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.

getWar

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

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

unDeployWars

public void unDeployWars(java.net.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.

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.

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

registerWarMBean

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

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

unRegisterWarMBean

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

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

getInstalledWars

public java.util.List getInstalledWars()
                                throws java.lang.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:
java.lang.Exception - if the list can't be retrieved

getCurrentNumberOfWars

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

getWarNames

public java.util.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(java.lang.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.

getServerName

public java.lang.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 java.lang.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

getDeployedWars

public java.util.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 java.util.List getDeployableWars()
                                 throws java.lang.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:
java.lang.Exception - if the list can't be retrieved

getAutoloadDirectories

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

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

getWebappsDirectory

public java.lang.String getWebappsDirectory()
Return the WebApps directory.

Specified by:
getWebappsDirectory in interface AbsJWebContainerServiceImplMBean
Specified by:
getWebappsDirectory in interface JWebContainerService
Returns:
The WebApps directory

init

public void init(javax.naming.Context ctx)
          throws ServiceException
Initialize the Catalina service.

Specified by:
init in interface Service
Parameters:
ctx - the configuration context of the service.
Throws:
ServiceException - if the initialization failed.
See Also:
Service.init(javax.naming.Context)

start

public void start()
           throws ServiceException
Start the Catalina service in a new thread

Specified by:
start in interface Service
Throws:
ServiceException - if the startup failed.
See Also:
Service.start()

stop

public void stop()
          throws ServiceException
Stop the Catalina service.

Specified by:
stop in interface Service
Throws:
ServiceException - if the stop failed.
See Also:
Service.stop()

isStarted

public boolean isStarted()
Specified by:
isStarted in interface Service
Returns:
true if the service is started, false otherwise

setName

public void setName(java.lang.String name)
Set the service's name

Specified by:
setName in interface Service
Parameters:
name - to set

getName

public java.lang.String getName()
Specified by:
getName in interface Service
Returns:
the service's name

getDefaultHost

public java.lang.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 java.lang.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 java.lang.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.

getClassLoader

public java.net.URLClassLoader getClassLoader(java.net.URL warURL,
                                              java.lang.String earAppName,
                                              java.lang.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.

isTomcatStarted

public boolean isTomcatStarted()
The server is started ?

Specified by:
isTomcatStarted in interface CatalinaJWebContainerService
Returns:
boolean true if the catalina container is running.

getContextLinkedClassLoader

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