org.ow2.jonas.deployment.ejb.lib
Class EjbDeploymentDescManager

java.lang.Object
  extended by org.ow2.jonas.deployment.common.lib.AbsDeploymentDescManager
      extended by org.ow2.jonas.deployment.ejb.lib.EjbDeploymentDescManager
All Implemented Interfaces:
DeploymentDescManager

public class EjbDeploymentDescManager
extends AbsDeploymentDescManager

This class provide a way for managing the EjbDeploymentDesc. Note that there is an intance of the EjbDeploymentDescManager on each JOnAS server.

Author:
Ludovic Bert, Florent Benoit, Nicolas Van Caneghem Allow the deployment of an exploded ear Contributors:
JOnAS 4.0 Adriana Danes: keep deployement descriptors is a Stringified format JOnAS 5.0 S. Ali Tokmen: fixed URL escaping issues when folders contain spaces for management support.

Field Summary
static String EJB_JAR_FILE_NAME
          ejb-jar.xml filename
static String JONAS_EJB_JAR_FILE_NAME
          jonas-ejb-jar.xml filename
 
Fields inherited from class org.ow2.jonas.deployment.common.lib.AbsDeploymentDescManager
LINK_SEPARATOR
 
Method Summary
 void addClassLoaderUrlMapping(ClassLoader ejbClassloader, URL[] urls)
          Add a mapping between url and classloader
protected  void checkType(URL ejbJar, String ejbType, IJNDIEnvRefsGroupDesc bd)
          Check if the type of the ejb-ref is correct.
protected  void checkTypeUsage(URL url, String mdType, String mdUsage, BeanDesc bd)
          Check if the type & usage of the message-destination-ref is correct.
 int getCacheSize()
          Get the size of the cache (number of entries in the cache).
static DeploymentDesc getDeploymentDesc(String ejbjar, ClassLoader ejbLoader)
          Factory method using the ejb-jar file name.
static DeploymentDesc getDeploymentDesc(String ejbJarXmlFileName, String jonasEjbJarXmlFileName, String jarFileName)
          Factory method using deployment descriptor and Jonas deployment descriptor file names.
 DeploymentDesc getDeploymentDesc(URL url, ClassLoader ejbLoader, ClassLoader earLoader)
          Get the specified ejb deployment descriptor and put it in the cache if it is not in.
static EjbDeploymentDescManager getInstance()
          Get an instance of the EjbDeploymentDescManager.
 String getJndiName(URL currentFile, String ejbLink, ClassLoader earCl, String ejbType, DeploymentDesc deploymentDesc, boolean isEjbRef)
          Return the JNDI name from the ejbLink string.
static String getJOnASXmlContent()
          Return the content of the jonas-web.xml file
static boolean getParsingWithValidation()
          Controls whether the parser is reporting all validity errors.
static String getXmlContent()
          Return the content of the web.xml file
static EjbJar loadEjbJar(Reader reader, String name)
          Load the ejb_jar.xml file.
static JonasEjbJar loadJonasEjbJar(Reader reader, String name)
          Load the EjbJar file
 void removeCache(ClassLoader earClassLoader)
          Make a cleanup of the cache of deployment descriptor.
 void setAvailableEjbJarsAndAltDDs(ClassLoader earClassLoader, URL[] urls, URL[] altDDs)
          Set for the given ear identified by its earClassLoader the list of the ejb-jar that can be in the ejb-link and the optional Desployment Desc.
static void setParsingWithValidation(boolean validation)
          Controls whether the parser is reporting all validity errors.
 String toString()
          Return a string representation of the cache.
 
Methods inherited from class org.ow2.jonas.deployment.common.lib.AbsDeploymentDescManager
containsResource, findJonasServiceRef, mergeWebServiceRef, xmlContent
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

EJB_JAR_FILE_NAME

public static final String EJB_JAR_FILE_NAME
ejb-jar.xml filename

See Also:
Constant Field Values

JONAS_EJB_JAR_FILE_NAME

public static final String JONAS_EJB_JAR_FILE_NAME
jonas-ejb-jar.xml filename

See Also:
Constant Field Values
Method Detail

getInstance

public static EjbDeploymentDescManager getInstance()
Get an instance of the EjbDeploymentDescManager.

Returns:
the instance of the EjbDeploymentDescManager.

getDeploymentDesc

public static DeploymentDesc getDeploymentDesc(String ejbjar,
                                               ClassLoader ejbLoader)
                                        throws DeploymentDescException
Factory method using the ejb-jar file name. Used by GenIC/GenIDL/WsGen.

Parameters:
ejbjar - ejbjar file name
ejbLoader - classloader used to load bean classes.
Returns:
instance of the corresponding DeploymentDesc
Throws:
DeploymentDescException - when DeploymentDesc cannot be created with given ejb-jar file.

getDeploymentDesc

public DeploymentDesc getDeploymentDesc(URL url,
                                        ClassLoader ejbLoader,
                                        ClassLoader earLoader)
                                 throws DeploymentDescException
Get the specified ejb deployment descriptor and put it in the cache if it is not in. Called by createContainer & WebDeploymentDescManager

Parameters:
url - the url where to load xml deployment descriptors.
ejbLoader - classloader used to load bean classes.
earLoader - the parent classloader (the ear classloader). Null if there in the case of an ejb-jar application.
Returns:
DeploymentDesc the ejb deployment descriptor. (This method is used for the ear applications).
Throws:
DeploymentDescException - when DeploymentDesc cannot be created with the given files.

getJndiName

public String getJndiName(URL currentFile,
                          String ejbLink,
                          ClassLoader earCl,
                          String ejbType,
                          DeploymentDesc deploymentDesc,
                          boolean isEjbRef)
                   throws DeploymentDescException
Return the JNDI name from the ejbLink string. ejbLink format : filename.jar#beanName in the same Ear File beanName in the same ejb-jar file.

Parameters:
currentFile - the url of the jar being parsed. This is needed because ejbLink is relative. With the url and the ejbLink, we can know where the file is locate.
ejbLink - the ejbLink tag of an ejb-ref
earCl - optionnal classloader
ejbType - the type of the referenced ejb in the ejb-ref tag.
deploymentDesc - the deployment descriptor of the parsed deploymentDesc.
isEjbRef - true if the jndi name to resolve is an ejb-ref
Returns:
the JNDI name if found, null otherwise
Throws:
DeploymentDescException - when it failed

setAvailableEjbJarsAndAltDDs

public void setAvailableEjbJarsAndAltDDs(ClassLoader earClassLoader,
                                         URL[] urls,
                                         URL[] altDDs)
Set for the given ear identified by its earClassLoader the list of the ejb-jar that can be in the ejb-link and the optional Desployment Desc.

Parameters:
earClassLoader - the classloader of the ear application.
urls - the list of the URLs of the ear application that can be in the ejb-link.
altDDs - the list of the URLs of the alternate DDs to use if specified.

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.

Parameters:
earClassLoader - the URLClassLoader of the ear application to remove from the cache.

getCacheSize

public int getCacheSize()
Get the size of the cache (number of entries in the cache). Used only for debugging.

Returns:
the size of the cache (number of entries in the cache).

toString

public String toString()
Return a string representation of the cache. (Used only for debugging).

Overrides:
toString in class Object
Returns:
a string representation of the cache.

getDeploymentDesc

public static DeploymentDesc getDeploymentDesc(String ejbJarXmlFileName,
                                               String jonasEjbJarXmlFileName,
                                               String jarFileName)
                                        throws DeploymentDescException
Factory method using deployment descriptor and Jonas deployment descriptor file names. used by GEnIC or GenIDL

Parameters:
ejbJarXmlFileName - name of the standard DD
jonasEjbJarXmlFileName - name of the specific DD
jarFileName - name of the jar file
Returns:
instance of the corresponding DeploymentDesc
Throws:
DeploymentDescException - when DeploymentDesc cannot be created with given files.

loadEjbJar

public static EjbJar loadEjbJar(Reader reader,
                                String name)
                         throws DeploymentDescException
Load the ejb_jar.xml file.

Parameters:
reader - the reader of the XML file.
name - the name of the file (ejb-jar.xml).
Returns:
a structure containing the result of the ejb-jar.xml parsing.
Throws:
DeploymentDescException - if the deployment descriptor is corrupted.

loadJonasEjbJar

public static JonasEjbJar loadJonasEjbJar(Reader reader,
                                          String name)
                                   throws DeploymentDescException
Load the EjbJar file

Parameters:
reader - reader containing the stream
name - name of the file
Returns:
JOnAS DD object
Throws:
DeploymentDescException - if loading fails

getParsingWithValidation

public static boolean getParsingWithValidation()
Controls whether the parser is reporting all validity errors.

Returns:
if true, all external entities will be read.

setParsingWithValidation

public static void setParsingWithValidation(boolean validation)
Controls whether the parser is reporting all validity errors.

Parameters:
validation - if true, all external entities will be read.

getXmlContent

public static String getXmlContent()
Return the content of the web.xml file

Returns:
the content of the web.xml file

getJOnASXmlContent

public static String getJOnASXmlContent()
Return the content of the jonas-web.xml file

Returns:
the content of the jonas-web.xml file

checkType

protected void checkType(URL ejbJar,
                         String ejbType,
                         IJNDIEnvRefsGroupDesc bd)
                  throws DeploymentDescException
Check if the type of the ejb-ref is correct.

Parameters:
ejbJar - the URL of the ejb-jar being parsed.
ejbType - the type of the ejb-ref (ejb-ref-type).
bd - the descriptor of the referenced bean.
Throws:
DeploymentDescException - if the type is incorrect.

checkTypeUsage

protected void checkTypeUsage(URL url,
                              String mdType,
                              String mdUsage,
                              BeanDesc bd)
                       throws DeploymentDescException
Check if the type & usage of the message-destination-ref is correct.

Parameters:
url - the URL of the file being parsed.
mdType - the type of the message-destination-ref (message-destination-type).
mdUsage - the usage of the message-destination-ref (message-destination-usage).
bd - the descriptor of the referenced bean.
Throws:
DeploymentDescException - if the type is incorrect.

addClassLoaderUrlMapping

public void addClassLoaderUrlMapping(ClassLoader ejbClassloader,
                                     URL[] urls)
Add a mapping between url and classloader

Parameters:
ejbClassloader - EjbClassloader on which associate URLs
urls - array of urls associated to the classloader


Copyright © 2010 OW2 Consortium. All Rights Reserved.