Top Description Fields Constructors Methods
org.apache.tools.ant.taskdefs.optional.ejb

public Class GenericDeploymentTool

extends Object
implements EJBDeploymentTool
Class Inheritance
All Implemented Interfaces
org.apache.tools.ant.taskdefs.optional.ejb.EJBDeploymentTool
Known Direct Subclasses
org.apache.tools.ant.taskdefs.optional.ejb.IPlanetDeploymentTool, org.apache.tools.ant.taskdefs.optional.ejb.JbossDeploymentTool, org.apache.tools.ant.taskdefs.optional.ejb.JonasDeploymentTool, org.apache.tools.ant.taskdefs.optional.ejb.OrionDeploymentTool, org.apache.tools.ant.taskdefs.optional.ejb.WeblogicDeploymentTool, org.apache.tools.ant.taskdefs.optional.ejb.WebsphereDeploymentTool, org.apache.tools.ant.taskdefs.optional.ejb.BorlandDeploymentTool
Imports
java.io.File, .IOException, .InputStream, java.nio.file.Files, java.util.Collections, .HashSet, .Hashtable, .Map, .Set, java.util.jar.JarOutputStream, .Manifest, java.util.zip.ZipEntry, javax.xml.parsers.SAXParser, org.apache.tools.ant.BuildException, .DirectoryScanner, .Location, .Project, .Task, org.apache.tools.ant.taskdefs.optional.ejb.EjbJar.DTDLocation, org.apache.tools.ant.types.FileSet, .Path, org.apache.tools.ant.util.depend.DependencyAnalyzer, org.xml.sax.InputSource, .SAXException

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 Summary

Modifier and TypeField and Description
private Set<String>
addedfiles

Set of files have been loaded into the EJB jar

public static final String
ANALYZER_CLASS_FULL

The analyzer class for the super analyzer

public static final String
ANALYZER_CLASS_SUPER

The analyzer class for the super analyzer

public static final String
ANALYZER_FULL

A dependency analyzer name to find all related classes

public static final String
ANALYZER_NONE

A dependency analyzer name for no analyzer

public static final String
ANALYZER_SUPER

A dependency analyzer name to find ancestor classes

private Path
classpath

The classpath to use with this deployment tool.

private ClassLoader
classpathLoader

The classloader generated from the given classpath to load the super classes and super interfaces.

private EjbJar.Config
config

The configuration from the containing task.

public static final String
DEFAULT_ANALYZER

The default analyzer

public static final int
DEFAULT_BUFFER_SIZE

The default buffer byte size to use for IO

private DependencyAnalyzer
dependencyAnalyzer

Dependency analyzer used to collect class dependencies

private File
destDir

Stores a handle to the directory to put the Jar files in

protected static final String
EJB_DD

Name for EJB Deployment descriptor within EJB jars

private String
genericJarSuffix

Instance variable that stores the suffix for the generated jarfile.

private DescriptorHandler
handler

Handler used to parse the EJB XML descriptor

public static final int
JAR_COMPRESS_LEVEL

The level to use for compression

protected static final String
MANIFEST

The standard MANIFEST file

protected static final String
META_DIR

The standard META-INF directory in jar files

private Task
task

The task to which this tool belongs.

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
protected void
addFileToJar(JarOutputStream
A JarOutputStream into which to write the jar entry.
jStream
,
File
A File from which to read the contents the file being added.
inputFile
,
String
A String representing the name, including all relevant path information, that should be stored for the entry being added.
logicalFilename
)

Utility method that encapsulates the logic of adding a file entry to a .jar file.

protected void
addSupportClasses(Hashtable<String, File>
Hashtable of EJB classes (and other) files that will be added to the completed JAR file
ejbFiles
)

Adds any classes the user specifies using support nested elements to the ejbFiles Hashtable.

protected void
addVendorFiles(Hashtable<String, File>
a hashtable entryname -> file.
ejbFiles
,
String
a prefix to use.
ddPrefix
)

Add any vendor specific files which should be included in the EJB Jar.

protected void
checkAndAddDependants(Hashtable<String, File>
files, that are extracted from the deployment descriptor
checkEntries
)

Add all available classes, that depend on Remote, Home, Bean, PK

protected void
checkConfiguration(String
String representing the file name of an EJB descriptor to be processed
descriptorFileName
,
SAXParser
SAXParser which may be used to parse the XML descriptor
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.

public void
configure(EjbJar.Config
the configuration from the surrounding ejbjar task.
config
)

Implements org.apache.tools.ant.taskdefs.optional.ejb.EJBDeploymentTool.configure.

Configure this tool for use in the ejbjar task.
private void
public Path

Returns:

a Path instance to be configured by Ant.
createClasspath
()

Add the classpath for the user classes

protected ClassLoader

Returns:

a classloader.
getClassLoaderForBuild
()

Returns a Classloader object which parses the passed in generic EjbJar classpath.

protected Path

Returns:

the combined classpath
getCombinedClasspath
()

Get the classpath by combining the one from the surrounding task, if any and the one from this tool.

protected EjbJar.Config

Returns:

an ejbjar task configuration
getConfig
()

Get the basename terminator.

protected DescriptorHandler

Returns:

a handler.
getDescriptorHandler
(File
the source directory.
srcDir
)

Deprecated as a consequence of DescriptorHandler being deprecated.
Get a descriptionHandler.
protected File

Returns:

the destination directory into which EJB jars are to be written
getDestDir
()

Get the destination directory.

protected String

Returns:

The "basename" which will be used to name the completed JAR file
getJarBaseName
(String
String representing the file name of an EJB descriptor to be processed
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 Location

Returns:

the task's location instance.
getLocation
()

Get the build file location associated with this element's task.

protected File

Returns:

the manifest file or null if the manifest file does not exist
getManifestFile
(String
the prefix where to llook for the manifest file based on the naming convention.
prefix
)

Get the manifest file to use for building the generic jar.

protected String

Returns:

Public ID of the DTD specified in the EJB descriptor.
getPublicId
()

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

protected Task

Returns:

the Task instance this tool is associated with.
getTask
()

Get the task for this tool.

public String

Returns:

the prefix.
getVendorDDPrefix
(String
the base name to use.
baseName
,
String
the file name to use.
descriptorFileName
)

Get the prefix for vendor deployment descriptors.

pack-priv File

Returns:

File
getVendorOutputJarFile
(String
the basename to use.
baseName
)

Get the vendor specific name of the Jar that will be output.

protected void
log(String
the message to be logged.
message
,
int
the severity of this message.
level
)

Log a message to the Ant output.

protected boolean

Returns:

boolean indicating whether or not the jarFile is up to date
needToRebuild
(Hashtable<String, File>
Hashtable of EJB classes (and other) files that will be added to the completed JAR file
ejbFiles
,
File
JAR file which will contain all of the EJB classes (and other) files
jarFile
)

This method checks the timestamp on each file listed in the ejbFiles and compares them to the timestamp on the jarFile .

protected Hashtable<String, File>

Returns:

Hashtable of EJB class (and other) files to be added to the completed JAR file
parseEjbFiles
(String
String representing the file name of an EJB descriptor to be processed
descriptorFileName
,
SAXParser
SAXParser which may be used to parse the XML descriptor
saxParser
)

This method returns a list of EJB files found when the specified EJB descriptor is parsed and processed.

public void
processDescriptor(String
the name of the deployment descriptor
descriptorFileName
,
SAXParser
a SAX parser which can be used to parse the deployment descriptor.
saxParser
)

Implements org.apache.tools.ant.taskdefs.optional.ejb.EJBDeploymentTool.processDescriptor.

Process a deployment descriptor, generating the necessary vendor specific deployment files..
protected void
registerKnownDTDs(DescriptorHandler
no used in this class.
handler
)

Deprecated as a consequence of DescriptorHandler being deprecated.
Register the locations of all known DTDs.
public void
setClasspath(Path
the classpath to be used for this build.
classpath
)

Set the classpath to be used for this compilation.

public void
setDestdir(File
the destination directory.
inDir
)

Set the destination directory; required.

public void
setGenericJarSuffix(String
the string to use as the suffix.
inString
)

Set the suffix for the generated jar file.

public void
setTask(Task
the Task to which this deployment tool is associated.
task
)

Implements org.apache.tools.ant.taskdefs.optional.ejb.EJBDeploymentTool.setTask.

Set the task which owns this tool
protected boolean

Returns:

true if the name of the generated jar is coming from the basejarname attribute
usingBaseJarName
()

Indicate if this build is using the base jar name.

public void
validateConfigured()

Implements org.apache.tools.ant.taskdefs.optional.ejb.EJBDeploymentTool.validateConfigured.

Called to validate that the tool parameters have been configured.
protected void
writeJar(String
the base name to use.
baseName
,
File
the jar file to write to.
jarfile
,
Hashtable<String, File>
the files to write to the jar.
files
,
String
the id to use.
publicId
)

Method used to encapsulate the writing of the JAR file.

Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

addedfilesback to summary
private Set<String> addedfiles

Set of files have been loaded into the EJB jar

ANALYZER_CLASS_FULLback to summary
public static final String ANALYZER_CLASS_FULL

The analyzer class for the super analyzer

ANALYZER_CLASS_SUPERback to summary
public static final String ANALYZER_CLASS_SUPER

The analyzer class for the super analyzer

ANALYZER_FULLback to summary
public static final String ANALYZER_FULL

A dependency analyzer name to find all related classes

ANALYZER_NONEback to summary
public static final String ANALYZER_NONE

A dependency analyzer name for no analyzer

ANALYZER_SUPERback to summary
public static final String ANALYZER_SUPER

A dependency analyzer name to find ancestor classes

classpathback to summary
private Path classpath

The classpath to use with this deployment tool. This is appended to any paths from the ejbjar task itself.

classpathLoaderback to summary
private ClassLoader classpathLoader

The classloader generated from the given classpath to load the super classes and super interfaces.

configback to summary
private EjbJar.Config config

The configuration from the containing task. This config combined with the settings of the individual attributes here constitues the complete config for this deployment tool.

DEFAULT_ANALYZERback to summary
public static final String DEFAULT_ANALYZER

The default analyzer

DEFAULT_BUFFER_SIZEback to summary
public static final int DEFAULT_BUFFER_SIZE

The default buffer byte size to use for IO

dependencyAnalyzerback to summary
private DependencyAnalyzer dependencyAnalyzer

Dependency analyzer used to collect class dependencies

destDirback to summary
private File destDir

Stores a handle to the directory to put the Jar files in

EJB_DDback to summary
protected static final String EJB_DD

Name for EJB Deployment descriptor within EJB jars

genericJarSuffixback to summary
private String genericJarSuffix

Instance variable that stores the suffix for the generated jarfile.

handlerback to summary
private DescriptorHandler handler

Deprecated

as a consequence of DescriptorHandler being deprecated. See corresponding docs for further information.

Handler used to parse the EJB XML descriptor

JAR_COMPRESS_LEVELback to summary
public static final int JAR_COMPRESS_LEVEL

The level to use for compression

MANIFESTback to summary
protected static final String MANIFEST

The standard MANIFEST file

META_DIRback to summary
protected static final String META_DIR

The standard META-INF directory in jar files

taskback to summary
private Task task

The task to which this tool belongs. This is used to access services provided by the ant core, such as logging.

Constructor Detail

GenericDeploymentToolback to summary
public GenericDeploymentTool()

Method Detail

addFileToJarback to summary
protected 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:JarOutputStream

A JarOutputStream into which to write the jar entry.

inputFile:File

A File from which to read the contents the file being added.

logicalFilename:String

A String representing the name, including all relevant path information, that should be stored for the entry being added.

Exceptions
BuildException:
if there is a problem.
addSupportClassesback to summary
protected void addSupportClasses(Hashtable<String, File> ejbFiles)

Adds any classes the user specifies using support nested elements to the ejbFiles Hashtable.

Parameters
ejbFiles:Hashtable<String, File>

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

addVendorFilesback to summary
protected void addVendorFiles(Hashtable<String, File> ejbFiles, String ddPrefix)

Add any vendor specific files which should be included in the EJB Jar.

Parameters
ejbFiles:Hashtable<String, File>

a hashtable entryname -> file.

ddPrefix:String

a prefix to use.

checkAndAddDependantsback to summary
protected void checkAndAddDependants(Hashtable<String, File> checkEntries) throws BuildException

Add all available classes, that depend on Remote, Home, Bean, PK

Parameters
checkEntries:Hashtable<String, File>

files, that are extracted from the deployment descriptor

Exceptions
BuildException:
if there is a problem.
checkConfigurationback to summary
protected 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

String representing the file name of an EJB descriptor to be processed

saxParser:SAXParser

SAXParser which may be used to parse the XML descriptor

Exceptions
BuildException:
if there is a problem.
configureback to summary
public void configure(EjbJar.Config config)

Implements org.apache.tools.ant.taskdefs.optional.ejb.EJBDeploymentTool.configure.

Configure this tool for use in the ejbjar task.

Parameters
config:EjbJar.Config

the configuration from the surrounding ejbjar task.

Annotations
@Override
createAnalyzerback to summary
private void createAnalyzer()
createClasspathback to summary
public Path createClasspath()

Add the classpath for the user classes

Returns:Path

a Path instance to be configured by Ant.

getClassLoaderForBuildback to summary
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.

Returns:ClassLoader

a classloader.

getCombinedClasspathback to summary
protected Path getCombinedClasspath()

Get the classpath by combining the one from the surrounding task, if any and the one from this tool.

Returns:Path

the combined classpath

getConfigback to summary
protected EjbJar.Config getConfig()

Get the basename terminator.

Returns:EjbJar.Config

an ejbjar task configuration

getDescriptorHandlerback to summary
protected DescriptorHandler getDescriptorHandler(File srcDir)

Deprecated

as a consequence of DescriptorHandler being deprecated. See corresponding docs for further information.

Get a descriptionHandler.

Parameters
srcDir:File

the source directory.

Returns:DescriptorHandler

a handler.

getDestDirback to summary
protected File getDestDir()

Get the destination directory.

Returns:File

the destination directory into which EJB jars are to be written

getJarBaseNameback to summary
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

String representing the file name of an EJB descriptor to be processed

Returns:String

The "basename" which will be used to name the completed JAR file

getLocationback to summary
protected Location getLocation()

Get the build file location associated with this element's task.

Returns:Location

the task's location instance.

getManifestFileback to summary
protected File getManifestFile(String prefix)

Get 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:String

the prefix where to llook for the manifest file based on the naming convention.

Returns:File

the manifest file or null if the manifest file does not exist

getPublicIdback to summary
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:String

Public ID of the DTD specified in the EJB descriptor.

getTaskback to summary
protected Task getTask()

Get the task for this tool.

Returns:Task

the Task instance this tool is associated with.

getVendorDDPrefixback to summary
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

Parameters
baseName:String

the base name to use.

descriptorFileName:String

the file name to use.

Returns:String

the prefix.

getVendorOutputJarFileback to summary
pack-priv File getVendorOutputJarFile(String baseName)

Get the vendor specific name of the Jar that will be output. The modification date of this jar will be checked against the dependent bean classes.

Parameters
baseName:String

the basename to use.

Returns:File

File

logback to summary
protected void log(String message, int level)

Log a message to the Ant output.

Parameters
message:String

the message to be logged.

level:int

the severity of this message.

needToRebuildback to summary
protected boolean needToRebuild(Hashtable<String, File> 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<String, File>

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

jarFile:File

JAR file which will contain all of the EJB classes (and other) files

Returns:boolean

boolean indicating whether or not the jarFile is up to date

parseEjbFilesback to summary
protected 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

String representing the file name of an EJB descriptor to be processed

saxParser:SAXParser

SAXParser which may be used to parse the XML descriptor

Returns:Hashtable<String, File>

Hashtable of EJB class (and other) files to be added to the completed JAR file

Exceptions
IOException:
An IOException from the parser, possibly from a the byte stream or character stream
SAXException:
Any SAX exception, possibly wrapping another exception
processDescriptorback to summary
public void processDescriptor(String descriptorFileName, SAXParser saxParser)

Implements org.apache.tools.ant.taskdefs.optional.ejb.EJBDeploymentTool.processDescriptor.

Doc from org.apache.tools.ant.taskdefs.optional.ejb.EJBDeploymentTool.processDescriptor.

Process a deployment descriptor, generating the necessary vendor specific deployment files..

Parameters
descriptorFileName:String

the name of the deployment descriptor

saxParser:SAXParser

a SAX parser which can be used to parse the deployment descriptor.

Annotations
@Override
registerKnownDTDsback to summary
protected void registerKnownDTDs(DescriptorHandler handler)

Deprecated

as a consequence of DescriptorHandler being deprecated. See corresponding docs for further information.

Register 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:DescriptorHandler

no used in this class.

setClasspathback to summary
public void setClasspath(Path classpath)

Set the classpath to be used for this compilation.

Parameters
classpath:Path

the classpath to be used for this build.

setDestdirback to summary
public void setDestdir(File inDir)

Set the destination directory; required.

Parameters
inDir:File

the destination directory.

setGenericJarSuffixback to summary
public void setGenericJarSuffix(String inString)

Set the suffix for the generated jar file.

Parameters
inString:String

the string to use as the suffix.

setTaskback to summary
public void setTask(Task task)

Implements org.apache.tools.ant.taskdefs.optional.ejb.EJBDeploymentTool.setTask.

Set the task which owns this tool

Parameters
task:Task

the Task to which this deployment tool is associated.

Annotations
@Override
usingBaseJarNameback to summary
protected boolean usingBaseJarName()

Indicate if this build is using the base jar name.

Returns:boolean

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

validateConfiguredback to summary
public void validateConfigured() throws BuildException

Implements org.apache.tools.ant.taskdefs.optional.ejb.EJBDeploymentTool.validateConfigured.

Called to validate that the tool parameters have been configured.

Annotations
@Override
Exceptions
BuildException:
If the Deployment Tool's configuration isn't valid
writeJarback to summary
protected void writeJar(String baseName, File jarfile, Hashtable<String, File> files, String publicId) throws 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
baseName:String

the base name to use.

jarfile:File

the jar file to write to.

files:Hashtable<String, File>

the files to write to the jar.

publicId:String

the id to use.

Exceptions
BuildException:
if there is a problem.