org.apache.tools.ant.taskdefs.optional.ejb

Class WebsphereDeploymentTool

public class WebsphereDeploymentTool extends GenericDeploymentTool

Websphere deployment tool that augments the ejbjar task. Searches for the websphere specific deployment descriptors and adds them to the final ejb jar file. Websphere has two specific descriptors for session beans: and another two for container managed entity beans: In terms of WebSphere, the generation of container code and stubs is called deployment. This step can be performed by the websphere element as part of the jar generation process. If the switch ejbdeploy is on, the ejbdeploy tool from the websphere toolset is called for every ejb-jar. Unfortunately, this step only works, if you use the ibm jdk. Otherwise, the rmic (called by ejbdeploy) throws a ClassFormatError. Be sure to switch ejbdeploy off, if run ant with sun jdk.
Nested Class Summary
static classWebsphereDeploymentTool.DBVendor
Enumerated attribute with the values for the database vendor types
Field Summary
static StringPUBLICID_EJB11
static StringPUBLICID_EJB20
protected static StringSCHEMA_DIR
protected static StringWAS_BND
protected static StringWAS_CMP_MAP
protected static StringWAS_CMP_SCHEMA
protected static StringWAS_EXT
Method Summary
protected voidaddVendorFiles(Hashtable ejbFiles, String baseName)
Add any vendor specific files which should be included in the EJB Jar.
PathcreateWASClasspath()
Get the classpath to the websphere classpaths
protected ClassLoadergetClassLoaderFromJar(File classjar)
Helper method invoked by isRebuildRequired to get a ClassLoader for a Jar File passed to it.
protected DescriptorHandlergetDescriptorHandler(File srcDir)
protected StringgetOptions()
Gets the options for the EJB Deploy operation
protected DescriptorHandlergetWebsphereDescriptorHandler(File srcDir)
protected booleanisRebuildRequired(File genericJarFile, File websphereJarFile)
Helper method to check to see if a websphere EBJ1.1 jar needs to be rebuilt using ejbdeploy.
voidsetCodegen(boolean codegen)
Flag, default false, to only generate the deployment code, do not run RMIC or Javac
voidsetDbname(String dbName)
Sets the name of the Database to create; optional.
voidsetDbschema(String dbSchema)
Sets the name of the schema to create; optional.
voidsetDbvendor(WebsphereDeploymentTool.DBVendor dbvendor)
Sets the DB Vendor for the Entity Bean mapping ; optional.
voidsetEjbdeploy(boolean ejbdeploy)
Decide, wether ejbdeploy should be called or not; optional, default true.
voidsetEJBdtd(String inString)
Setter used to store the location of the Sun's Generic EJB DTD.
voidsetKeepgeneric(boolean inValue)
This controls whether the generic file used as input to ejbdeploy is retained; optional, default false.
voidsetNewCMP(boolean newCMP)
Set the value of the newCMP scheme.
voidsetNoinform(boolean noinform)
Flag to disable informational messages; optional, default false.
voidsetNovalidate(boolean novalidate)
Flag to disable the validation steps; optional, default false.
voidsetNowarn(boolean nowarn)
Flag to disable warning and informational messages; optional, default false.
voidsetOldCMP(boolean oldCMP)
Set the value of the oldCMP scheme.
voidsetQuiet(boolean quiet)
Flag, default true, to only output error messages.
voidsetRebuild(boolean rebuild)
Set the rebuild flag to false to only update changes in the jar rather than rerunning ejbdeploy; optional, default true.
voidsetRmicoptions(String options)
Set the rmic options.
voidsetSuffix(String inString)
String value appended to the basename of the deployment descriptor to create the filename of the WebLogic EJB jar file.
voidsetTempdir(String tempdir)
The directory, where ejbdeploy will write temporary files; optional, defaults to '_ejbdeploy_temp'.
voidsetTrace(boolean trace)
Flag to enable internal tracing when set, optional, default false.
voidsetUse35(boolean attr)
Flag to use the WebSphere 3.5 compatible mapping rules ; optional, default false.
voidsetWASClasspath(Path wasClasspath)
voidvalidateConfigured()
Called to validate that the tool parameters have been configured.
protected voidwriteJar(String baseName, File jarFile, Hashtable files, String publicId)
Method used to encapsulate the writing of the JAR file.

Field Detail

PUBLICID_EJB11

public static final String PUBLICID_EJB11

PUBLICID_EJB20

public static final String PUBLICID_EJB20

SCHEMA_DIR

protected static final String SCHEMA_DIR

WAS_BND

protected static final String WAS_BND

WAS_CMP_MAP

protected static final String WAS_CMP_MAP

WAS_CMP_SCHEMA

protected static final String WAS_CMP_SCHEMA

WAS_EXT

protected static final String WAS_EXT

Method Detail

addVendorFiles

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

createWASClasspath

public Path createWASClasspath()
Get the classpath to the websphere classpaths

getClassLoaderFromJar

protected ClassLoader getClassLoaderFromJar(File classjar)
Helper method invoked by isRebuildRequired to get a ClassLoader for a Jar File passed to it.

Parameters: classjar java.io.File representing jar file to get classes from.

getDescriptorHandler

protected DescriptorHandler getDescriptorHandler(File srcDir)

getOptions

protected String getOptions()
Gets the options for the EJB Deploy operation

Returns: String

getWebsphereDescriptorHandler

protected DescriptorHandler getWebsphereDescriptorHandler(File srcDir)

isRebuildRequired

protected boolean isRebuildRequired(File genericJarFile, File websphereJarFile)
Helper method to check to see if a websphere EBJ1.1 jar needs to be rebuilt using ejbdeploy. Called from writeJar it sees if the "Bean" classes are the only thing that needs to be updated and either updates the Jar with the Bean classfile or returns true, saying that the whole websphere jar needs to be regened with ejbdeploy. This allows faster build times for working developers.

The way websphere ejbdeploy works is it creates wrappers for the publicly defined methods as they are exposed in the remote interface. If the actual bean changes without changing the the method signatures then only the bean classfile needs to be updated and the rest of the websphere jar file can remain the same. If the Interfaces, ie. the method signatures change or if the xml deployment descriptors changed, the whole jar needs to be rebuilt with ejbdeploy. This is not strictly true for the xml files. If the JNDI name changes then the jar doesnt have to be rebuild, but if the resources references change then it does. At this point the websphere jar gets rebuilt if the xml files change at all.

Parameters: genericJarFile java.io.File The generic jar file. websphereJarFile java.io.File The websphere jar file to check to see if it needs to be rebuilt.

setCodegen

public void setCodegen(boolean codegen)
Flag, default false, to only generate the deployment code, do not run RMIC or Javac

Parameters: codegen option

setDbname

public void setDbname(String dbName)
Sets the name of the Database to create; optional.

Parameters: dbName name of the database

setDbschema

public void setDbschema(String dbSchema)
Sets the name of the schema to create; optional.

Parameters: dbSchema name of the schema

setDbvendor

public void setDbvendor(WebsphereDeploymentTool.DBVendor dbvendor)
Sets the DB Vendor for the Entity Bean mapping ; optional. Valid options are for example: This is also used to determine the name of the Map.mapxmi and Schema.dbxmi files, for example Account-DB2UDBWIN_V71-Map.mapxmi and Account-DB2UDBWIN_V71-Schema.dbxmi.

setEjbdeploy

public void setEjbdeploy(boolean ejbdeploy)
Decide, wether ejbdeploy should be called or not; optional, default true.

Parameters: ejbdeploy

setEJBdtd

public void setEJBdtd(String inString)
Setter used to store the location of the Sun's Generic EJB DTD. This can be a file on the system or a resource on the classpath.

Parameters: inString the string to use as the DTD location.

setKeepgeneric

public void setKeepgeneric(boolean inValue)
This controls whether the generic file used as input to ejbdeploy is retained; optional, default false.

Parameters: inValue either 'true' or 'false'.

setNewCMP

public void setNewCMP(boolean newCMP)
Set the value of the newCMP scheme. The old CMP scheme locates the websphere CMP descriptor based on the naming convention where the websphere CMP file is expected to be named with the bean name as the prefix. Under this scheme the name of the CMP descriptor does not match the name actually used in the main websphere EJB descriptor. Also, descriptors which contain multiple CMP references could not be used.

setNoinform

public void setNoinform(boolean noinform)
Flag to disable informational messages; optional, default false.

Parameters: noinform if true disables informational messages

setNovalidate

public void setNovalidate(boolean novalidate)
Flag to disable the validation steps; optional, default false.

Parameters: novalidate option

setNowarn

public void setNowarn(boolean nowarn)
Flag to disable warning and informational messages; optional, default false.

Parameters: nowarn option

setOldCMP

public void setOldCMP(boolean oldCMP)
Set the value of the oldCMP scheme. This is an antonym for newCMP

UNKNOWN: ignore="true"

setQuiet

public void setQuiet(boolean quiet)
Flag, default true, to only output error messages.

Parameters: quiet option

setRebuild

public void setRebuild(boolean rebuild)
Set the rebuild flag to false to only update changes in the jar rather than rerunning ejbdeploy; optional, default true.

setRmicoptions

public void setRmicoptions(String options)
Set the rmic options.

Parameters: options

setSuffix

public void setSuffix(String inString)
String value appended to the basename of the deployment descriptor to create the filename of the WebLogic EJB jar file. Optional, default '.jar'.

Parameters: inString the string to use as the suffix.

setTempdir

public void setTempdir(String tempdir)
The directory, where ejbdeploy will write temporary files; optional, defaults to '_ejbdeploy_temp'.

setTrace

public void setTrace(boolean trace)
Flag to enable internal tracing when set, optional, default false.

Parameters: trace

setUse35

public void setUse35(boolean attr)
Flag to use the WebSphere 3.5 compatible mapping rules ; optional, default false.

Parameters: attr

setWASClasspath

public void setWASClasspath(Path wasClasspath)

validateConfigured

public void validateConfigured()
Called to validate that the tool parameters have been configured.

writeJar

protected void writeJar(String baseName, File jarFile, Hashtable files, String publicId)
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.
Copyright