org.ow2.jonas.ant
Class GenericDeploymentTool

java.lang.Object
  extended by org.ow2.jonas.ant.GenericDeploymentTool
All Implemented Interfaces:
EJBDeploymentTool
Direct Known Subclasses:
JonasDeploymentTool

public class GenericDeploymentTool
extends Object
implements EJBDeploymentTool


Field Summary
static String ANALYZER_CLASS_FULL
          The analyzer class for the super analyzer
static String ANALYZER_CLASS_SUPER
          The analyzer class for the super analyzer
static String ANALYZER_FULL
          A dependency analyzer name to find all related classes
static String ANALYZER_NONE
          A dependency analyzer name for no analyzer
static String ANALYZER_SUPER
          A dependency analyzer name to find ancestor classes
static String DEFAULT_ANALYZER
          The default analyzer
protected static String EJB_DD
          Name for EJB Deployment descriptor within EJB jars
protected static String MANIFEST
          The standard MANIFEST file
protected static String META_DIR
          The standard META-INF directory in jar files
 
Constructor Summary
GenericDeploymentTool()
           
 
Method Summary
protected  void addFileToJar(JarOutputStream jStream, File inputFile, String logicalFilename)
          Utility method that encapsulates the logic of adding a file entry to a .jar file.
protected  void addSupportClasses(Hashtable ejbFiles)
          Adds any classes the user specifies using support nested elements to the ejbFiles Hashtable.
protected  void addVendorFiles(Hashtable ejbFiles, String ddPrefix)
          Add any vendor specific files which should be included in the EJB Jar.
protected  void checkAndAddDependants(Hashtable checkEntries)
          Add all available classes, that depend on Remote, Home, Bean, PK
protected  void checkConfiguration(String descriptorFileName, SAXParser saxParser)
          This method is called as the first step in the processDescriptor method to allow vendor-specific subclasses to validate the task configuration prior to processing the descriptor.
 void configure(org.ow2.jonas.ant.EjbJar.Config config)
          Configure this tool for use in the ejbjar task.
 org.apache.tools.ant.types.Path createClasspath()
          Add the classpath for the user classes
protected  ClassLoader getClassLoaderForBuild()
          Returns a Classloader object which parses the passed in generic EjbJar classpath.
protected  org.apache.tools.ant.types.Path getCombinedClasspath()
          Get the classpath by combining the one from the surrounding task, if any and the one from this tool.
protected  org.ow2.jonas.ant.EjbJar.Config getConfig()
          Get the basename terminator.
protected  DescriptorHandler getDescriptorHandler(File srcDir)
           
protected  File getDestDir()
          Get the destination directory.
protected  String getJarBaseName(String descriptorFileName)
          Using the EJB descriptor file name passed from the ejbjar task, this method returns the "basename" which will be used to name the completed JAR file.
protected  org.apache.tools.ant.Location getLocation()
          Get the build file location associated with this element's task.
protected  File getManifestFile(String prefix)
          Get the manifets file to use for building the generic jar.
protected  String getPublicId()
          Returns the Public ID of the DTD specified in the EJB descriptor.
protected  org.apache.tools.ant.Task getTask()
          Get the task for this tool.
 String getVendorDDPrefix(String baseName, String descriptorFileName)
          Get the prefix for vendor deployment descriptors.
protected  void log(String message, int level)
          Log a message to the Ant output.
protected  boolean needToRebuild(Hashtable ejbFiles, File jarFile)
          This method checks the timestamp on each file listed in the ejbFiles and compares them to the timestamp on the jarFile .
protected  Hashtable parseEjbFiles(String descriptorFileName, SAXParser saxParser)
          This method returns a list of EJB files found when the specified EJB descriptor is parsed and processed.
 void processDescriptor(String descriptorFileName, SAXParser saxParser)
          Process a deployment descriptor, generating the necessary vendor specific deployment files.
protected  void registerKnownDTDs(DescriptorHandler handler)
          Register the locations of all known DTDs.
 void setClasspath(org.apache.tools.ant.types.Path classpath)
          Set the classpath to be used for this compilation.
 void setDestdir(File inDir)
          Set the destination directory; required.
 void setGenericJarSuffix(String inString)
          Set the suffix for the generated jar file.
 void setTask(org.apache.tools.ant.Task task)
          Set the task which owns this tool
protected  boolean usingBaseJarName()
          Indicate if this build is using the base jar name.
 void validateConfigured()
          Called to validate that the tool parameters have been configured.
protected  void writeJar(String baseName, File jarfile, Hashtable files, String publicId, boolean includeInnerClasses)
          Method used to encapsulate the writing of the JAR file.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

META_DIR

protected static final String META_DIR
The standard META-INF directory in jar files

See Also:
Constant Field Values

MANIFEST

protected static final String MANIFEST
The standard MANIFEST file

See Also:
Constant Field Values

EJB_DD

protected static final String EJB_DD
Name for EJB Deployment descriptor within EJB jars

See Also:
Constant Field Values

ANALYZER_SUPER

public static final String ANALYZER_SUPER
A dependency analyzer name to find ancestor classes

See Also:
Constant Field Values

ANALYZER_FULL

public static final String ANALYZER_FULL
A dependency analyzer name to find all related classes

See Also:
Constant Field Values

ANALYZER_NONE

public static final String ANALYZER_NONE
A dependency analyzer name for no analyzer

See Also:
Constant Field Values

DEFAULT_ANALYZER

public static final String DEFAULT_ANALYZER
The default analyzer

See Also:
Constant Field Values

ANALYZER_CLASS_SUPER

public static final String ANALYZER_CLASS_SUPER
The analyzer class for the super analyzer

See Also:
Constant Field Values

ANALYZER_CLASS_FULL

public static final String ANALYZER_CLASS_FULL
The analyzer class for the super analyzer

See Also:
Constant Field Values
Constructor Detail

GenericDeploymentTool

public GenericDeploymentTool()
Method Detail

setDestdir

public void setDestdir(File inDir)
Set the destination directory; required.

Parameters:
inDir - the destination directory.

getDestDir

protected File getDestDir()
Get the destination directory.

Returns:
the destination directory into which EJB jars are to be written

setTask

public void setTask(org.apache.tools.ant.Task task)
Set the task which owns this tool

Specified by:
setTask in interface EJBDeploymentTool
Parameters:
task - the Task to which this deployment tool is associated.

getTask

protected org.apache.tools.ant.Task getTask()
Get the task for this tool.

Returns:
the Task instance this tool is associated with.

getConfig

protected org.ow2.jonas.ant.EjbJar.Config getConfig()
Get the basename terminator.

Returns:
an ejbjar task configuration

usingBaseJarName

protected boolean usingBaseJarName()
Indicate if this build is using the base jar name.

Returns:
true if the name of the generated jar is coming from the basejarname attribute

setGenericJarSuffix

public void setGenericJarSuffix(String inString)
Set the suffix for the generated jar file.

Parameters:
inString - the string to use as the suffix.

createClasspath

public org.apache.tools.ant.types.Path createClasspath()
Add the classpath for the user classes

Returns:
a Path instance to be configured by Ant.

setClasspath

public void setClasspath(org.apache.tools.ant.types.Path classpath)
Set the classpath to be used for this compilation.

Parameters:
classpath - the classpath to be used for this build.

getCombinedClasspath

protected org.apache.tools.ant.types.Path getCombinedClasspath()
Get the classpath by combining the one from the surrounding task, if any and the one from this tool.

Returns:
the combined classpath

log

protected void log(String message,
                   int level)
Log a message to the Ant output.

Parameters:
message - the message to be logged.
level - the severity of this message.

getLocation

protected org.apache.tools.ant.Location getLocation()
Get the build file location associated with this element's task.

Returns:
the task's location instance.

configure

public void configure(org.ow2.jonas.ant.EjbJar.Config config)
Configure this tool for use in the ejbjar task.

Specified by:
configure in interface EJBDeploymentTool
Parameters:
config - the configuration from the surrounding ejbjar task.

addFileToJar

protected void addFileToJar(JarOutputStream jStream,
                            File inputFile,
                            String logicalFilename)
                     throws org.apache.tools.ant.BuildException
Utility method that encapsulates the logic of adding a file entry to a .jar file. Used by execute() to add entries to the jar file as it is constructed.

Parameters:
jStream - A JarOutputStream into which to write the jar entry.
inputFile - A File from which to read the contents the file being added.
logicalFilename - A String representing the name, including all relevant path information, that should be stored for the entry being added.
Throws:
org.apache.tools.ant.BuildException

getDescriptorHandler

protected DescriptorHandler getDescriptorHandler(File srcDir)

registerKnownDTDs

protected void registerKnownDTDs(DescriptorHandler handler)
Register the locations of all known DTDs. vendor-specific subclasses should override this method to define the vendor-specific locations of the EJB DTDs


processDescriptor

public void processDescriptor(String descriptorFileName,
                              SAXParser saxParser)
Description copied from interface: EJBDeploymentTool
Process a deployment descriptor, generating the necessary vendor specific deployment files.

Specified by:
processDescriptor in interface EJBDeploymentTool
Parameters:
descriptorFileName - the name of the deployment descriptor
saxParser - a SAX parser which can be used to parse the deployment descriptor.

checkConfiguration

protected void checkConfiguration(String descriptorFileName,
                                  SAXParser saxParser)
                           throws org.apache.tools.ant.BuildException
This method is called as the first step in the processDescriptor method to allow vendor-specific subclasses to validate the task configuration prior to processing the descriptor. If the configuration is invalid, a BuildException should be thrown.

Parameters:
descriptorFileName - String representing the file name of an EJB descriptor to be processed
saxParser - SAXParser which may be used to parse the XML descriptor
Throws:
org.apache.tools.ant.BuildException - Thrown if the configuration is invalid

parseEjbFiles

protected Hashtable parseEjbFiles(String descriptorFileName,
                                  SAXParser saxParser)
                           throws IOException,
                                  SAXException
This method returns a list of EJB files found when the specified EJB descriptor is parsed and processed.

Parameters:
descriptorFileName - String representing the file name of an EJB descriptor to be processed
saxParser - SAXParser which may be used to parse the XML descriptor
Returns:
Hashtable of EJB class (and other) files to be added to the completed JAR file
Throws:
SAXException - Any SAX exception, possibly wrapping another exception
IOException - An IOException from the parser, possibly from a the byte stream or character stream

addSupportClasses

protected void addSupportClasses(Hashtable ejbFiles)
Adds any classes the user specifies using support nested elements to the ejbFiles Hashtable.

Parameters:
ejbFiles - Hashtable of EJB classes (and other) files that will be added to the completed JAR file

getJarBaseName

protected String getJarBaseName(String descriptorFileName)
Using the EJB descriptor file name passed from the ejbjar task, this method returns the "basename" which will be used to name the completed JAR file.

Parameters:
descriptorFileName - String representing the file name of an EJB descriptor to be processed
Returns:
The "basename" which will be used to name the completed JAR file

getVendorDDPrefix

public String getVendorDDPrefix(String baseName,
                                String descriptorFileName)
Get the prefix for vendor deployment descriptors. This will contain the path and the start of the descriptor name, depending on the naming scheme


addVendorFiles

protected void addVendorFiles(Hashtable ejbFiles,
                              String ddPrefix)
Add any vendor specific files which should be included in the EJB Jar.


needToRebuild

protected boolean needToRebuild(Hashtable ejbFiles,
                                File jarFile)
This method checks the timestamp on each file listed in the ejbFiles and compares them to the timestamp on the jarFile . If the jarFile's timestamp is more recent than each EJB file, true is returned. Otherwise, false is returned. TODO: find a way to check the manifest-file, that is found by naming convention

Parameters:
ejbFiles - Hashtable of EJB classes (and other) files that will be added to the completed JAR file
jarFile - JAR file which will contain all of the EJB classes (and other) files
Returns:
boolean indicating whether or not the jarFile is up to date

getPublicId

protected String getPublicId()
Returns the Public ID of the DTD specified in the EJB descriptor. Not every vendor-specific DeploymentTool will need to reference this value or may want to determine this value in a vendor-specific way.

Returns:
Public ID of the DTD specified in the EJB descriptor.

getManifestFile

protected File getManifestFile(String prefix)
Get the manifets file to use for building the generic jar. If the file does not exist the global manifest from the config is used otherwise the default Ant manifest will be used.

Parameters:
prefix - the prefix where to llook for the manifest file based on the naming convention.
Returns:
the manifest file or null if the manifest file does not exist

writeJar

protected void writeJar(String baseName,
                        File jarfile,
                        Hashtable files,
                        String publicId,
                        boolean includeInnerClasses)
                 throws org.apache.tools.ant.BuildException
Method used to encapsulate the writing of the JAR file. Iterates over the filenames/java.io.Files in the Hashtable stored on the instance variable ejbFiles.

Parameters:
includeInnerClasses - if true, include inner classes
Throws:
org.apache.tools.ant.BuildException

checkAndAddDependants

protected void checkAndAddDependants(Hashtable checkEntries)
                              throws org.apache.tools.ant.BuildException
Add all available classes, that depend on Remote, Home, Bean, PK

Parameters:
checkEntries - files, that are extracted from the deployment descriptor
Throws:
org.apache.tools.ant.BuildException

getClassLoaderForBuild

protected ClassLoader getClassLoaderForBuild()
Returns a Classloader object which parses the passed in generic EjbJar classpath. The loader is used to dynamically load classes from javax.ejb.* and the classes being added to the jar.


validateConfigured

public void validateConfigured()
                        throws org.apache.tools.ant.BuildException
Called to validate that the tool parameters have been configured.

Specified by:
validateConfigured in interface EJBDeploymentTool
Throws:
org.apache.tools.ant.BuildException - If the Deployment Tool's configuration isn't valid


Copyright © 2010 OW2 Consortium. All Rights Reserved.