Class GenericDeploymentTool
java.lang.Object
org.apache.tools.ant.taskdefs.optional.ejb.GenericDeploymentTool
- All Implemented Interfaces:
- EJBDeploymentTool
- Direct Known Subclasses:
- BorlandDeploymentTool,- IPlanetDeploymentTool,- JbossDeploymentTool,- JonasDeploymentTool,- OrionDeploymentTool,- WeblogicDeploymentTool,- WebsphereDeploymentTool
A deployment tool which creates generic EJB jars. Generic jars contains
 only those classes and META-INF entries specified in the EJB 1.1 standard
 This class is also used as a framework for the creation of vendor specific
 deployment tools. A number of template methods are provided through which the
 vendor specific tool can hook into the EJB creation process.
- 
Field SummaryFieldsModifier and TypeFieldDescriptionstatic final StringThe analyzer class for the super analyzerstatic final StringThe analyzer class for the super analyzerstatic final StringA dependency analyzer name to find all related classesstatic final StringA dependency analyzer name for no analyzerstatic final StringA dependency analyzer name to find ancestor classesstatic final StringThe default analyzerstatic final intThe default buffer byte size to use for IOprotected static final StringName for EJB Deployment descriptor within EJB jarsstatic final intThe level to use for compressionprotected static final StringThe standard MANIFEST fileprotected static final StringThe standard META-INF directory in jar files
- 
Constructor SummaryConstructors
- 
Method SummaryModifier and TypeMethodDescriptionprotected voidaddFileToJar(JarOutputStream jStream, File inputFile, String logicalFilename) Utility method that encapsulates the logic of adding a file entry to a .jar file.protected voidaddSupportClasses(Hashtable<String, File> ejbFiles) Adds any classes the user specifies using support nested elements to theejbFilesHashtable.protected voidaddVendorFiles(Hashtable<String, File> ejbFiles, String ddPrefix) Add any vendor specific files which should be included in the EJB Jar.protected voidcheckAndAddDependants(Hashtable<String, File> checkEntries) Add all available classes, that depend on Remote, Home, Bean, PKprotected voidcheckConfiguration(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.voidconfigure(org.apache.tools.ant.taskdefs.optional.ejb.EjbJar.Config config) Configure this tool for use in the ejbjar task.Add the classpath for the user classesprotected ClassLoaderReturns a Classloader object which parses the passed in generic EjbJar classpath.protected PathGet the classpath by combining the one from the surrounding task, if any and the one from this tool.protected org.apache.tools.ant.taskdefs.optional.ejb.EjbJar.ConfigGet the basename terminator.protected DescriptorHandlergetDescriptorHandler(File srcDir) Get a descriptionHandler.protected FileGet the destination directory.protected StringgetJarBaseName(String descriptorFileName) Using the EJB descriptor file name passed from theejbjartask, this method returns the "basename" which will be used to name the completed JAR file.protected LocationGet the build file location associated with this element's task.protected FilegetManifestFile(String prefix) Get the manifest file to use for building the generic jar.protected StringReturns the Public ID of the DTD specified in the EJB descriptor.protected TaskgetTask()Get the task for this tool.getVendorDDPrefix(String baseName, String descriptorFileName) Get the prefix for vendor deployment descriptors.protected voidLog a message to the Ant output.protected booleanneedToRebuild(Hashtable<String, File> ejbFiles, File jarFile) This method checks the timestamp on each file listed in theejbFilesand compares them to the timestamp on thejarFile.parseEjbFiles(String descriptorFileName, SAXParser saxParser) This method returns a list of EJB files found when the specified EJB descriptor is parsed and processed.voidprocessDescriptor(String descriptorFileName, SAXParser saxParser) Process a deployment descriptor, generating the necessary vendor specific deployment files.protected voidregisterKnownDTDs(DescriptorHandler handler) Register the locations of all known DTDs.voidsetClasspath(Path classpath) Set the classpath to be used for this compilation.voidsetDestdir(File inDir) Set the destination directory; required.voidsetGenericJarSuffix(String inString) Set the suffix for the generated jar file.voidSet the task which owns this toolprotected booleanIndicate if this build is using the base jar name.voidCalled to validate that the tool parameters have been configured.protected voidMethod used to encapsulate the writing of the JAR file.
- 
Field Details- 
DEFAULT_BUFFER_SIZEpublic static final int DEFAULT_BUFFER_SIZEThe default buffer byte size to use for IO- See Also:
 
- 
JAR_COMPRESS_LEVELpublic static final int JAR_COMPRESS_LEVELThe level to use for compression- See Also:
 
- 
META_DIR
- 
MANIFEST
- 
EJB_DD
- 
ANALYZER_SUPERA dependency analyzer name to find ancestor classes- See Also:
 
- 
ANALYZER_FULLA dependency analyzer name to find all related classes- See Also:
 
- 
ANALYZER_NONE
- 
DEFAULT_ANALYZER
- 
ANALYZER_CLASS_SUPER
- 
ANALYZER_CLASS_FULL
 
- 
- 
Constructor Details- 
GenericDeploymentToolpublic GenericDeploymentTool()
 
- 
- 
Method Details- 
setDestdirSet the destination directory; required.- Parameters:
- inDir- the destination directory.
 
- 
getDestDirGet the destination directory.- Returns:
- the destination directory into which EJB jars are to be written
 
- 
setTaskSet the task which owns this tool- Specified by:
- setTaskin interface- EJBDeploymentTool
- Parameters:
- task- the Task to which this deployment tool is associated.
 
- 
getTaskGet the task for this tool.- Returns:
- the Task instance this tool is associated with.
 
- 
getConfigprotected org.apache.tools.ant.taskdefs.optional.ejb.EjbJar.Config getConfig()Get the basename terminator.- Returns:
- an ejbjar task configuration
 
- 
usingBaseJarNameprotected 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
 
- 
setGenericJarSuffixSet the suffix for the generated jar file.- Parameters:
- inString- the string to use as the suffix.
 
- 
createClasspathAdd the classpath for the user classes- Returns:
- a Path instance to be configured by Ant.
 
- 
setClasspathSet the classpath to be used for this compilation.- Parameters:
- classpath- the classpath to be used for this build.
 
- 
getCombinedClasspathGet the classpath by combining the one from the surrounding task, if any and the one from this tool.- Returns:
- the combined classpath
 
- 
logLog a message to the Ant output.- Parameters:
- message- the message to be logged.
- level- the severity of this message.
 
- 
getLocationGet the build file location associated with this element's task.- Returns:
- the task's location instance.
 
- 
configurepublic void configure(org.apache.tools.ant.taskdefs.optional.ejb.EjbJar.Config config) Configure this tool for use in the ejbjar task.- Specified by:
- configurein interface- EJBDeploymentTool
- Parameters:
- config- the configuration from the surrounding ejbjar task.
 
- 
addFileToJarprotected void addFileToJar(JarOutputStream jStream, File inputFile, String logicalFilename) throws 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:
- BuildException- if there is a problem.
 
- 
getDescriptorHandlerGet a descriptionHandler.- Parameters:
- srcDir- the source directory.
- Returns:
- a handler.
 
- 
registerKnownDTDsRegister the locations of all known DTDs. vendor-specific subclasses should override this method to define the vendor-specific locations of the EJB DTDs- Parameters:
- handler- no used in this class.
 
- 
processDescriptorProcess a deployment descriptor, generating the necessary vendor specific deployment files..- Specified by:
- processDescriptorin interface- EJBDeploymentTool
- Parameters:
- descriptorFileName- the name of the deployment descriptor
- saxParser- a SAX parser which can be used to parse the deployment descriptor.
 
- 
checkConfigurationprotected void checkConfiguration(String descriptorFileName, SAXParser saxParser) throws 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:
- BuildException- if there is a problem.
 
- 
parseEjbFilesprotected Hashtable<String,File> 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
- 
getJarBaseNameUsing the EJB descriptor file name passed from theejbjartask, 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
 
- 
getVendorDDPrefixGet the prefix for vendor deployment descriptors. This will contain the path and the start of the descriptor name, depending on the naming scheme- Parameters:
- baseName- the base name to use.
- descriptorFileName- the file name to use.
- Returns:
- the prefix.
 
- 
addVendorFiles
- 
needToRebuildThis method checks the timestamp on each file listed in theejbFilesand compares them to the timestamp on thejarFile. If thejarFile's timestamp is more recent than each EJB file,trueis returned. Otherwise,falseis 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 jarFileis up to date
 
- 
getPublicIdReturns the Public ID of the DTD specified in the EJB descriptor. Not every vendor-specificDeploymentToolwill 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.
 
- 
getManifestFileGet the manifest 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
 
- 
writeJarprotected void writeJar(String baseName, File jarfile, Hashtable<String, File> files, String publicId) throws BuildExceptionMethod 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:
- baseName- the base name to use.
- jarfile- the jar file to write to.
- files- the files to write to the jar.
- publicId- the id to use.
- Throws:
- BuildException- if there is a problem.
 
- 
checkAndAddDependantsAdd all available classes, that depend on Remote, Home, Bean, PK- Parameters:
- checkEntries- files, that are extracted from the deployment descriptor
- Throws:
- BuildException- if there is a problem.
 
- 
getClassLoaderForBuildReturns 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.- Returns:
- a classloader.
 
- 
validateConfiguredCalled to validate that the tool parameters have been configured.- Specified by:
- validateConfiguredin interface- EJBDeploymentTool
- Throws:
- BuildException- If the Deployment Tool's configuration isn't valid
 
 
-