Class EjbJar
java.lang.Object
org.apache.tools.ant.ProjectComponent
org.apache.tools.ant.Task
org.apache.tools.ant.taskdefs.MatchingTask
org.apache.tools.ant.taskdefs.optional.ejb.EjbJar
- All Implemented Interfaces:
Cloneable, SelectorContainer
Provides automated EJB JAR file creation.
Extends the MatchingTask class provided in the default ant distribution to provide a directory scanning EJB jarfile generator.
The task works by taking the deployment descriptors one at a time and parsing them to locate the names of the classes which should be placed in the jar. The classnames are translated to java.io.Files by replacing periods with File.separatorChar and resolving the generated filename as a relative path under the srcDir attribute. All necessary files are then assembled into a jarfile. One jarfile is constructed for each deployment descriptor found.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classCMP versions supported valid CMP versions are 1.0 and 2.0static classInner class used to record information about the location of a local DTDstatic classAn EnumeratedAttribute class for handling different EJB jar naming schemes -
Field Summary
Fields inherited from class MatchingTask
filesetFields inherited from class ProjectComponent
description, location, project -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected voidaddDeploymentTool(EJBDeploymentTool deploymentTool) Add a deployment tool to the list of deployment tools that will be processedAdds a deployment tool for Borland server.Adds to the classpath used to locate the super classes and interfaces of the classes that will make up the EJB JAR.Create a DTD location record.Adds a deployment tool for iPlanet Application Server.Adds a deployment tool for JBoss server.Adds a deployment tool for JOnAS server.Create a orion nested element used to configure a deployment tool for Orion server.Adds a fileset for support elements.Adds a deployment tool for WebLogic server.Adds a deployment tool for WebLogic when using the TOPLink Object-Relational mapping.Adds a deployment tool for WebSphere 4.0 server.voidexecute()Invoked by Ant after the task is prepared, when it is ready to execute this task.Gets the CMP version.Gets the destination directory.voidsetBasejarname(String inValue) Set the base name of the EJB JAR that is to be created if it is not to be determined from the name of the deployment descriptor files.voidsetBasenameterminator(String inValue) The string which terminates the bean name.voidsetClasspath(Path classpath) Set the classpath to use when resolving classes for inclusion in the jar.voidsetCmpversion(EjbJar.CMPVersion version) Sets the CMP version.voidsetDependency(String analyzer) Set the analyzer to use when adding in dependencies to the JAR.voidsetDescriptordir(File inDir) Set the descriptor directory.voidsetDestdir(File inDir) Set the destination directory.voidsetFlatdestdir(boolean inValue) Controls whether the destination JARs are written out in the destination directory with the same hierarchical structure from which the deployment descriptors have been read.voidsetGenericjarsuffix(String inString) Set the suffix for the generated jar file.voidsetManifest(File manifest) Set the Manifest file to use when jarring.voidsetNaming(EjbJar.NamingScheme namingScheme) Set the naming scheme used to determine the name of the generated jars from the deployment descriptorvoidSets the source directory, which is the directory that contains the classes that will be added to the EJB jar.Methods inherited from class MatchingTask
add, addAnd, addContains, addContainsRegexp, addCustom, addDate, addDepend, addDepth, addDifferent, addFilename, addMajority, addModified, addNone, addNot, addOr, addPresent, addSelector, addSize, addType, appendSelector, createExclude, createExcludesFile, createInclude, createIncludesFile, createPatternSet, getDirectoryScanner, getImplicitFileSet, getSelectors, hasSelectors, selectorCount, selectorElements, setCaseSensitive, setDefaultexcludes, setExcludes, setExcludesfile, setFollowSymlinks, setIncludes, setIncludesfile, setProject, XsetIgnore, XsetItemsModifier and TypeMethodDescriptionvoidadd(FileSelector selector) add an arbitrary selectorvoidaddAnd(AndSelector selector) add an "And" selector entry on the selector listvoidaddContains(ContainsSelector selector) add a contains selector entry on the selector listvoidaddContainsRegexp(ContainsRegexpSelector selector) add a regular expression selector entry on the selector listvoidaddCustom(ExtendSelector selector) add an extended selector entry on the selector listvoidaddDate(DateSelector selector) add a selector date entry on the selector listvoidaddDepend(DependSelector selector) add a depends selector entry on the selector listvoidaddDepth(DepthSelector selector) add a depth selector entry on the selector listvoidaddDifferent(DifferentSelector selector) add a type selector entry on the type listvoidaddFilename(FilenameSelector selector) add a selector filename entry on the selector listvoidaddMajority(MajoritySelector selector) add a majority selector entry on the selector listvoidaddModified(ModifiedSelector selector) add the modified selectorvoidaddNone(NoneSelector selector) add a "None" selector entry on the selector listvoidaddNot(NotSelector selector) add a "Not" selector entry on the selector listvoidaddOr(OrSelector selector) add an "Or" selector entry on the selector listvoidaddPresent(PresentSelector selector) add a present selector entry on the selector listvoidaddSelector(SelectSelector selector) add a "Select" selector entry on the selector listvoidaddSize(SizeSelector selector) add a selector size entry on the selector listvoidaddType(TypeSelector selector) add a type selector entry on the type listvoidappendSelector(FileSelector selector) Add a new selector into this container.add a name entry on the exclude listadd a name entry on the include files listadd a name entry on the include listadd a name entry on the include files listadd a set of patternsprotected DirectoryScannergetDirectoryScanner(File baseDir) Returns the directory scanner needed to access the files to process.protected final FileSetAccessor for the implicit fileset.Returns the set of selectors as an array.booleanIndicates whether there are any selectors here.intGives the count of the number of selectors in this containerReturns an enumerator for accessing the set of selectors.voidsetCaseSensitive(boolean isCaseSensitive) Sets case sensitivity of the file systemvoidsetDefaultexcludes(boolean useDefaultExcludes) Sets whether default exclusions should be used or not.voidsetExcludes(String excludes) Sets the set of exclude patterns.voidsetExcludesfile(File excludesfile) Sets the name of the file containing the includes patterns.voidsetFollowSymlinks(boolean followSymlinks) Sets whether or not symbolic links or Windows junctions should be followed.voidsetIncludes(String includes) Sets the set of include patterns.voidsetIncludesfile(File includesfile) Sets the name of the file containing the includes patterns.voidsetProject(Project project) Sets the project object of this component.voidXsetIgnore(String ignoreString) List of filenames and directory names to not include.voidSet this to be the items in the base directory that you want to be included.Methods inherited from class Task
bindToOwner, getOwningTarget, getRuntimeConfigurableWrapper, getTaskName, getTaskType, getWrapper, handleErrorFlush, handleErrorOutput, handleFlush, handleInput, handleOutput, init, isInvalid, log, log, log, log, maybeConfigure, perform, reconfigure, setOwningTarget, setRuntimeConfigurableWrapper, setTaskName, setTaskTypeModifier and TypeMethodDescriptionfinal voidbindToOwner(Task owner) Bind a task to another; use this when configuring a newly created task to do work on behalf of another.Returns the container target of this task.Returns the wrapper used for runtime configuration.Returns the name to use in logging messages.Return the type of task.protected RuntimeConfigurableReturn the runtime configurable structure for this task.protected voidhandleErrorFlush(String output) Handles an error line by logging it with the WARN priority.protected voidhandleErrorOutput(String output) Handles an error output by logging it with the WARN priority.protected voidhandleFlush(String output) Handles output by logging it with the INFO priority.protected inthandleInput(byte[] buffer, int offset, int length) Handle an input request by this task.protected voidhandleOutput(String output) Handles output by logging it with the INFO priority.voidinit()Called by the project to let the task initialize properly.protected final booleanHas this task been marked invalid?voidLogs a message with the default (INFO) priority.voidLogs a message with the given priority.voidLogs a message with the given priority.voidLogs a message with the given priority.voidConfigures this task - if it hasn't been done already.final voidperform()Performs this task if it's still valid, or gets a replacement version and performs that otherwise.voidForce the task to be reconfigured from its RuntimeConfigurable.voidsetOwningTarget(Target target) Sets the target container of this task.voidSets the wrapper to be used for runtime configuration.voidsetTaskName(String name) Sets the name to use in logging messages.voidsetTaskType(String type) Sets the name with which the task has been invoked.Methods inherited from class ProjectComponent
clone, getDescription, getLocation, getProject, setDescription, setLocationModifier and TypeMethodDescriptionclone()Returns the description of the current action.Returns the file/location where this task was defined.Returns the project to which this component belongs.voidsetDescription(String desc) Sets a description of the current action.voidsetLocation(Location location) Sets the file/location where this task was defined.
-
Constructor Details
-
EjbJar
public EjbJar()
-
-
Method Details
-
addDeploymentTool
Add a deployment tool to the list of deployment tools that will be processed- Parameters:
deploymentTool- a deployment tool instance to which descriptors will be passed for processing.
-
createOrion
Create a orion nested element used to configure a deployment tool for Orion server.- Returns:
- the deployment tool instance to be configured.
- Since:
- Ant 1.10.2
-
createWeblogic
Adds a deployment tool for WebLogic server.- Returns:
- the deployment tool instance to be configured.
-
createWebsphere
Adds a deployment tool for WebSphere 4.0 server.- Returns:
- the deployment tool instance to be configured.
-
createBorland
Adds a deployment tool for Borland server.- Returns:
- the deployment tool instance to be configured.
-
createIplanet
Adds a deployment tool for iPlanet Application Server.- Returns:
- the deployment tool instance to be configured.
-
createJboss
Adds a deployment tool for JBoss server.- Returns:
- the deployment tool instance to be configured.
-
createJonas
Adds a deployment tool for JOnAS server.- Returns:
- the deployment tool instance to be configured.
-
createWeblogictoplink
Adds a deployment tool for WebLogic when using the TOPLink Object-Relational mapping.- Returns:
- the deployment tool instance to be configured.
-
createClasspath
Adds to the classpath used to locate the super classes and interfaces of the classes that will make up the EJB JAR.- Returns:
- the path to be configured.
-
createDTD
Create a DTD location record. This stores the location of a DTD. The DTD is identified by its public Id. The location may either be a file location or a resource location.- Returns:
- the DTD location object to be configured by Ant
-
createSupport
Adds a fileset for support elements.- Returns:
- a fileset which can be populated with support files.
-
setManifest
Set the Manifest file to use when jarring. As of EJB 1.1, manifest files are no longer used to configure the EJB. However, they still have a vital importance if the EJB is intended to be packaged in an EAR file. By adding "Class-Path" settings to a Manifest file, the EJB can look for classes inside the EAR file itself, allowing for easier deployment. This is outlined in the J2EE specification, and all J2EE components are meant to support it.- Parameters:
manifest- the manifest to be used in the EJB jar
-
setSrcdir
Sets the source directory, which is the directory that contains the classes that will be added to the EJB jar. Typically this will include the home and remote interfaces and the bean class.- Parameters:
inDir- the source directory.
-
setDescriptordir
Set the descriptor directory. The descriptor directory contains the EJB deployment descriptors. These are XML files that declare the properties of a bean in a particular deployment scenario. Such properties include, for example, the transactional nature of the bean and the security access control to the bean's methods.- Parameters:
inDir- the directory containing the deployment descriptors.
-
setDependency
Set the analyzer to use when adding in dependencies to the JAR.- Parameters:
analyzer- the name of the dependency analyzer or a class.
-
setBasejarname
Set the base name of the EJB JAR that is to be created if it is not to be determined from the name of the deployment descriptor files.- Parameters:
inValue- the basename that will be used when writing the jar file containing the EJB
-
setNaming
Set the naming scheme used to determine the name of the generated jars from the deployment descriptor- Parameters:
namingScheme- the naming scheme to be used
-
getDestdir
Gets the destination directory.- Returns:
- destination directory
- Since:
- ant 1.6
-
setDestdir
Set the destination directory. The EJB jar files will be written into this directory. The jar files that exist in this directory are also used when determining if the contents of the jar file have changed. Note that this parameter is only used if no deployment tools are specified. Typically each deployment tool will specify its own destination directory.- Parameters:
inDir- the destination directory in which to generate jars
-
getCmpversion
-
setCmpversion
Sets the CMP version. Must be either1.0or2.0. Default is1.0. Initially, only the JBoss implementation does something specific for CMP 2.0.- Parameters:
version- CMP version.- Since:
- ant 1.6
-
setClasspath
Set the classpath to use when resolving classes for inclusion in the jar.- Parameters:
classpath- the classpath to use.
-
setFlatdestdir
public void setFlatdestdir(boolean inValue) Controls whether the destination JARs are written out in the destination directory with the same hierarchical structure from which the deployment descriptors have been read. If this is set to true the generated EJB jars are written into the root of the destination directory, otherwise they are written out in the same relative position as the deployment descriptors in the descriptor directory.- Parameters:
inValue- the new value of the flatdestdir flag.
-
setGenericjarsuffix
Set the suffix for the generated jar file. When generic jars are generated, they have a suffix which is appended to the the bean name to create the name of the jar file. Note that this suffix includes the extension fo te jar file and should therefore end with an appropriate extension such as .jar or .ear- Parameters:
inString- the string to use as the suffix.
-
setBasenameterminator
The string which terminates the bean name. The convention used by this task is that bean descriptors are named as the BeanName with some suffix. The baseNameTerminator string separates the bean name and the suffix and is used to determine the bean name.- Parameters:
inValue- a string which marks the end of the basename.
-
execute
Invoked by Ant after the task is prepared, when it is ready to execute this task. This will configure all of the nested deployment tools to allow them to process the jar. If no deployment tools have been configured a generic tool is created to handle the jar. A parser is configured and then each descriptor found is passed to all the deployment tool elements for processing.- Overrides:
executein classTask- Throws:
BuildException- thrown whenever a problem is encountered that cannot be recovered from, to signal to ant that a major problem occurred within this task.
-