org.objectweb.easybeans.deployer
Class TomcatDeployer

java.lang.Object
  extended by org.objectweb.easybeans.deployer.AbsDeployer
      extended by org.objectweb.easybeans.deployer.AbsWebContainerDeployer
          extended by org.objectweb.easybeans.deployer.TomcatDeployer
All Implemented Interfaces:
EZBDeployer

public class TomcatDeployer
extends AbsWebContainerDeployer
implements EZBDeployer

Implementation of the Deployer for EasyBeans in Tomcat.
It will deploy EJB3 and EAR. EJB3 will be deployed in EasyBeans while WAR file will go in Tomcat.

Author:
Florent Benoit

Field Summary
private static java.lang.String CATALINA_CONTEXT_CLASSNAME
          Name of the Standard Context class.
private  java.lang.Class catalinaContextClass
          Class object for the catalina context.
private static java.lang.String DESTROY_OPERATION
          Destroy operation on the Tomcat context to undeploy the war.
private static java.lang.String ENGINE_OBJECT_NAME
          Engine Object Name.
private static JLog logger
          Logger.
private static java.lang.String SET_DEFAULT_CONTEXT_XML_METHOD_NAME
          Method name for setting the default context xml file.
private static java.lang.String SET_DEFAULT_WEB_XML_METHOD_NAME
          Method name for setting the default web xml file.
private static java.lang.String SET_DOC_BASE_METHOD_NAME
          Method name for setting the URL to the war file.
private static java.lang.String SET_JAVA_DELEGATION_MODEL_METHOD_NAME
          Name of the method for changing the Java Delegation model.
private static java.lang.String SET_PARENT_CLASSLOADER_METHOD_NAME
          Method name for setting the parent class loader on the context.
private static java.lang.String SET_PATH_METHOD_NAME
          Method name for setting the context-root of this context.
private  java.lang.reflect.Method setDefaultContextXmlMethod
          Method for setting the default context xml file.
private  java.lang.reflect.Method setDefaultWebXmlMethod
          Method for setting the default web xml file.
private  java.lang.reflect.Method setDocBaseMethod
          Method for setting the URL to the doc base.
private  java.lang.reflect.Method setJavaDelegationModelMethod
          Method object used for changing the Java Delegation model.
private  java.lang.reflect.Method setParentClassLoaderMethod
          Method for setting the parent class loader on the context.
private  java.lang.reflect.Method setPathMethod
          Method for setting the context-root of this context.
private static java.lang.String START_METHOD_NAME
          Name of the start method for the context object.
private  java.lang.reflect.Method startContextMethod
          Method for the start of the catalina context.
 
Fields inherited from class org.objectweb.easybeans.deployer.AbsDeployer
DEFAULT_FOLDER
 
Constructor Summary
TomcatDeployer()
          Build a new instance of this deployer.
 
Method Summary
private  java.lang.String buildObjectName(WARDeployable war)
          Build an objectname for the given war.
private  void checkSupportedDeployable(EZBDeployable deployable)
          Check that the given deployable is supported by this deployer.
 void deploy(EZBDeployable deployable)
          Deploy a deployable.
protected  void deployWARs(EARDeployable earDeployable, java.net.URL earURL, java.lang.ClassLoader earClassLoader, java.lang.ClassLoader parentClassLoader)
          Deploy the WAR files present in the given EAR.
private  java.lang.String getDefaultHost()
           
private  java.lang.String getDomain()
          Gets the JMX domain of Tomcat.
private  javax.management.ObjectName getEngineObjectName()
           
protected  void undeployWAR(WARDeployable warDeployable)
          Undeploy an given WAR (called by the undeploy method).
private  java.io.File unpack(java.io.File warFile, WARDeployable war, java.net.URL earURL)
          Unpack the given war into a temp directory.
 
Methods inherited from class org.objectweb.easybeans.deployer.AbsWebContainerDeployer
deployEAR, undeploy, undeployEAR
 
Methods inherited from class org.objectweb.easybeans.deployer.AbsDeployer
deployEJB, getClassLoaderForEAR, getEmbedded, getMethod, getPersistenceUnitManager, invoke, loadClass, loadClass, newInstance, newInstance, setEmbedded, undeployEJB3FromEAR, unpackEARDeployable
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.objectweb.easybeans.deployer.api.EZBDeployer
setEmbedded, undeploy
 

Field Detail

logger

private static JLog logger
Logger.


CATALINA_CONTEXT_CLASSNAME

private static final java.lang.String CATALINA_CONTEXT_CLASSNAME
Name of the Standard Context class.

See Also:
Constant Field Values

catalinaContextClass

private java.lang.Class catalinaContextClass
Class object for the catalina context.


START_METHOD_NAME

private static final java.lang.String START_METHOD_NAME
Name of the start method for the context object.

See Also:
Constant Field Values

startContextMethod

private java.lang.reflect.Method startContextMethod
Method for the start of the catalina context.


SET_PARENT_CLASSLOADER_METHOD_NAME

private static final java.lang.String SET_PARENT_CLASSLOADER_METHOD_NAME
Method name for setting the parent class loader on the context.

See Also:
Constant Field Values

setParentClassLoaderMethod

private java.lang.reflect.Method setParentClassLoaderMethod
Method for setting the parent class loader on the context.


SET_DOC_BASE_METHOD_NAME

private static final java.lang.String SET_DOC_BASE_METHOD_NAME
Method name for setting the URL to the war file.

See Also:
Constant Field Values

setDocBaseMethod

private java.lang.reflect.Method setDocBaseMethod
Method for setting the URL to the doc base.


SET_PATH_METHOD_NAME

private static final java.lang.String SET_PATH_METHOD_NAME
Method name for setting the context-root of this context.

See Also:
Constant Field Values

setPathMethod

private java.lang.reflect.Method setPathMethod
Method for setting the context-root of this context.


SET_DEFAULT_CONTEXT_XML_METHOD_NAME

private static final java.lang.String SET_DEFAULT_CONTEXT_XML_METHOD_NAME
Method name for setting the default context xml file.

See Also:
Constant Field Values

setDefaultContextXmlMethod

private java.lang.reflect.Method setDefaultContextXmlMethod
Method for setting the default context xml file.


SET_DEFAULT_WEB_XML_METHOD_NAME

private static final java.lang.String SET_DEFAULT_WEB_XML_METHOD_NAME
Method name for setting the default web xml file.

See Also:
Constant Field Values

SET_JAVA_DELEGATION_MODEL_METHOD_NAME

private static final java.lang.String SET_JAVA_DELEGATION_MODEL_METHOD_NAME
Name of the method for changing the Java Delegation model.

See Also:
Constant Field Values

setJavaDelegationModelMethod

private java.lang.reflect.Method setJavaDelegationModelMethod
Method object used for changing the Java Delegation model.


setDefaultWebXmlMethod

private java.lang.reflect.Method setDefaultWebXmlMethod
Method for setting the default web xml file.


ENGINE_OBJECT_NAME

private static final java.lang.String ENGINE_OBJECT_NAME
Engine Object Name.

See Also:
Constant Field Values

DESTROY_OPERATION

private static final java.lang.String DESTROY_OPERATION
Destroy operation on the Tomcat context to undeploy the war.

See Also:
Constant Field Values
Constructor Detail

TomcatDeployer

public TomcatDeployer()
               throws EZBDeployerException
Build a new instance of this deployer.

Throws:
EZBDeployerException - if the instance is not built.
Method Detail

deploy

public void deploy(EZBDeployable deployable)
            throws EZBDeployerException
Deploy a deployable. It can be an EJB jar, EAR, WAR, etc.

Specified by:
deploy in interface EZBDeployer
Parameters:
deployable - a given deployable
Throws:
EZBDeployerException - if the deployment is not done.

deployWARs

protected void deployWARs(EARDeployable earDeployable,
                          java.net.URL earURL,
                          java.lang.ClassLoader earClassLoader,
                          java.lang.ClassLoader parentClassLoader)
                   throws EZBDeployerException
Deploy the WAR files present in the given EAR.

Specified by:
deployWARs in class AbsWebContainerDeployer
Parameters:
earDeployable - the EAR containing the WARs
earURL - the EAR URL
earClassLoader - the EAR classloader
parentClassLoader - the parent classloader (EJB) to use
Throws:
EZBDeployerException - if the wars are not deployed.

checkSupportedDeployable

private void checkSupportedDeployable(EZBDeployable deployable)
                               throws EZBDeployerException
Check that the given deployable is supported by this deployer. If it is not supported, throw an error.

Parameters:
deployable - the deployable that needs to be deployed
Throws:
EZBDeployerException - if this deployable is not supported.

undeployWAR

protected void undeployWAR(WARDeployable warDeployable)
                    throws EZBDeployerException
Undeploy an given WAR (called by the undeploy method).

Specified by:
undeployWAR in class AbsWebContainerDeployer
Parameters:
warDeployable - a given WAR deployable
Throws:
EZBDeployerException - if the undeployment is not done.

buildObjectName

private java.lang.String buildObjectName(WARDeployable war)
                                  throws EZBDeployerException
Build an objectname for the given war.

Parameters:
war - the given war deployable that contains the datas.
Returns:
a JMX object name.
Throws:
EZBDeployerException - if the object name cannot be built.

getDomain

private java.lang.String getDomain()
                            throws EZBDeployerException
Gets the JMX domain of Tomcat.

Returns:
the JMX domain of Tomcat.
Throws:
EZBDeployerException - if the domain cannot be found

getEngineObjectName

private javax.management.ObjectName getEngineObjectName()
                                                 throws EZBDeployerException
Returns:
the first Engine object name found in the MBean server
Throws:
EZBDeployerException - if the engine object name is not found in the MBean server.

getDefaultHost

private java.lang.String getDefaultHost()
                                 throws EZBDeployerException
Returns:
the default host of the first engine found in the MBean server
Throws:
EZBDeployerException - if the MBean is not found.

unpack

private java.io.File unpack(java.io.File warFile,
                            WARDeployable war,
                            java.net.URL earURL)
                     throws EZBDeployerException
Unpack the given war into a temp directory.

Parameters:
warFile - the war to unpack
war - data on the given war
earURL - url of the EAR that contains the war
Returns:
the File to the unpack directory
Throws:
EZBDeployerException - if unpack fails