org.objectweb.easybeans.deployer
Class AbsDeployer

java.lang.Object
  extended by org.objectweb.easybeans.deployer.AbsDeployer
All Implemented Interfaces:
EZBDeployer
Direct Known Subclasses:
AbsWebContainerDeployer, EasyBeansDeployer, JOnASDeployer

public abstract class AbsDeployer
extends java.lang.Object
implements EZBDeployer

Abstract class that defines common methods for deployer.

Author:
Florent Benoit

Field Summary
static java.lang.String DEFAULT_FOLDER
          Folder to create in tmp folder.
private  EZBServer embedded
          Embedded server linked to this deployer.
private static JLog logger
          Logger.
 
Constructor Summary
AbsDeployer()
           
 
Method Summary
protected  void deployEJB(EJBDeployable ejbDeployable)
          Deploy an EJB (called by the deploy method).
protected  java.lang.ClassLoader getClassLoaderForEAR(EARDeployable earDeployable)
          Build and return a classloader for the given EAR.
 EZBServer getEmbedded()
           
protected static java.lang.reflect.Method getMethod(java.lang.Class clazz, java.lang.String methodName, java.lang.Class... parameters)
          Get the method on the given class with the given method name and the given parameters.
protected  PersistenceUnitManager getPersistenceUnitManager(EARDeployable earDeployable, java.lang.ClassLoader appClassLoader)
          Gets the persistence unit manager for the given EAR and classloader.
protected static java.lang.Object invoke(java.lang.reflect.Method method, java.lang.Object object, java.lang.Object... args)
          Invoke the given method on the given object (null for static method) and with the given args.
protected static java.lang.Class loadClass(java.lang.String className)
          Load the given class with its given classname.
protected static java.lang.Class loadClass(java.lang.String className, java.lang.ClassLoader classLoader)
          Load the given class with its given classname.
protected static java.lang.Object newInstance(java.lang.Class clazz)
          Build an instance of the given class.
protected static java.lang.Object newInstance(java.lang.reflect.Constructor constructor, java.lang.Object... parameters)
          Build an instance by using the given constructor and given parameters.
 void setEmbedded(EZBServer embedded)
          Receive Embedded instance for this deployer.
protected  void undeployEJB3FromEAR(EARDeployable earDeployable)
          Undeploy EJB3s of an EAR (called by the undeploy method).
protected  EARDeployable unpackEARDeployable(EARDeployable earDeployable)
          Unpack the given archive in a temp folder, then build a local EARDeployable and fill it with submodules and then return it.
 
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
deploy, undeploy
 

Field Detail

DEFAULT_FOLDER

public static final java.lang.String DEFAULT_FOLDER
Folder to create in tmp folder.

See Also:
Constant Field Values

logger

private static JLog logger
Logger.


embedded

private EZBServer embedded
Embedded server linked to this deployer.

Constructor Detail

AbsDeployer

public AbsDeployer()
Method Detail

getEmbedded

public EZBServer getEmbedded()
Returns:
the embedded instance used by this server.

setEmbedded

public void setEmbedded(EZBServer embedded)
Receive Embedded instance for this deployer.

Specified by:
setEmbedded in interface EZBDeployer
Parameters:
embedded - the given instance of the embedded server.

getClassLoaderForEAR

protected java.lang.ClassLoader getClassLoaderForEAR(EARDeployable earDeployable)
                                              throws EZBDeployerException
Build and return a classloader for the given EAR.

Parameters:
earDeployable - the given EAR
Returns:
a classloader
Throws:
EZBDeployerException - if the classloader cannot be built

getPersistenceUnitManager

protected PersistenceUnitManager getPersistenceUnitManager(EARDeployable earDeployable,
                                                           java.lang.ClassLoader appClassLoader)
Gets the persistence unit manager for the given EAR and classloader.

Parameters:
earDeployable - the ear deployable
appClassLoader - the classloader used as deployable
Returns:
the given persistence unit manager

deployEJB

protected void deployEJB(EJBDeployable ejbDeployable)
                  throws EZBDeployerException
Deploy an EJB (called by the deploy method).

Parameters:
ejbDeployable - a given EJB deployable
Throws:
EZBDeployerException - if the deployment is not done.

newInstance

protected static java.lang.Object newInstance(java.lang.Class clazz)
                                       throws EZBDeployerException
Build an instance of the given class.

Parameters:
clazz - the class to instantiate
Returns:
a new object
Throws:
EZBDeployerException - if the class can't be loaded

newInstance

protected static java.lang.Object newInstance(java.lang.reflect.Constructor constructor,
                                              java.lang.Object... parameters)
                                       throws EZBDeployerException
Build an instance by using the given constructor and given parameters.

Parameters:
constructor - the constructor to use
parameters - the parameters of the given constructor
Returns:
a new object
Throws:
EZBDeployerException - if the class can't be loaded

loadClass

protected static java.lang.Class loadClass(java.lang.String className)
                                    throws EZBDeployerException
Load the given class with its given classname.

Parameters:
className - the name of the class to load
Returns:
the class object
Throws:
EZBDeployerException - if the class can't be loaded

loadClass

protected static java.lang.Class loadClass(java.lang.String className,
                                           java.lang.ClassLoader classLoader)
                                    throws EZBDeployerException
Load the given class with its given classname.

Parameters:
className - the name of the class to load
classLoader - the given classloader (or null to use thread context classloader)
Returns:
the class object
Throws:
EZBDeployerException - if the class can't be loaded

invoke

protected static java.lang.Object invoke(java.lang.reflect.Method method,
                                         java.lang.Object object,
                                         java.lang.Object... args)
                                  throws EZBDeployerException
Invoke the given method on the given object (null for static method) and with the given args.

Parameters:
method - the method to invoke
object - the object on which the method is invoked
args - the arguments of the method
Returns:
the result of the invocation
Throws:
EZBDeployerException - if the method is not invoked

getMethod

protected static java.lang.reflect.Method getMethod(java.lang.Class clazz,
                                                    java.lang.String methodName,
                                                    java.lang.Class... parameters)
                                             throws EZBDeployerException
Get the method on the given class with the given method name and the given parameters.

Parameters:
clazz - the class on which search the method
methodName - the name of the method to search
parameters - the class parameters of the method that is searched
Returns:
the method found
Throws:
EZBDeployerException - if the method is not found

undeployEJB3FromEAR

protected void undeployEJB3FromEAR(EARDeployable earDeployable)
                            throws EZBDeployerException
Undeploy EJB3s of an EAR (called by the undeploy method).

Parameters:
earDeployable - a given EAR deployable
Throws:
EZBDeployerException - if the deployment is not done.

unpackEARDeployable

protected EARDeployable unpackEARDeployable(EARDeployable earDeployable)
                                     throws EZBDeployerException
Unpack the given archive in a temp folder, then build a local EARDeployable and fill it with submodules and then return it.

Parameters:
earDeployable - the archive to unpack.
Returns:
a new deployable (which is unpacked)
Throws:
EZBDeployerException - if the EAR can't be unpacked