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

Class WeblogicDeploymentTool

public class WeblogicDeploymentTool extends GenericDeploymentTool

The weblogic element is used to control the weblogic.ejbc compiler for generating weblogic EJB jars. Prior to Ant 1.3, the method of locating CMP descriptors was to use the ejbjar naming convention. So if your ejb-jar was called, Customer-ejb-jar.xml, your weblogic descriptor was called Customer- weblogic-ejb-jar.xml and your CMP descriptor had to be Customer-weblogic-cmp- rdbms-jar.xml. In addition, the <type-storage> element in the weblogic descriptor had to be set to the standard name META-INF/weblogic-cmp-rdbms- jar.xml, as that is where the CMP descriptor was mapped to in the generated jar.
Field Summary
protected static StringCOMPILER_EJB11
protected static StringCOMPILER_EJB20
protected static StringDEFAULT_COMPILER
protected static StringDEFAULT_WL51_DTD_LOCATION
protected static StringDEFAULT_WL51_EJB11_DTD_LOCATION
protected static StringDEFAULT_WL60_51_DTD_LOCATION
protected static StringDEFAULT_WL60_DTD_LOCATION
protected static StringDEFAULT_WL60_EJB11_DTD_LOCATION
protected static StringDEFAULT_WL60_EJB20_DTD_LOCATION
protected static StringDEFAULT_WL70_DTD_LOCATION
static StringPUBLICID_EJB11
static StringPUBLICID_EJB20
static StringPUBLICID_WEBLOGIC_EJB510
static StringPUBLICID_WEBLOGIC_EJB600
static StringPUBLICID_WEBLOGIC_EJB700
protected static StringWL_CMP_DD
protected static StringWL_DD
Method Summary
voidaddSysproperty(Environment.Variable sysp)
Add a nested sysproperty element.
protected voidaddVendorFiles(Hashtable ejbFiles, String ddPrefix)
Add any vendor specific files which should be included in the EJB Jar.
PathcreateWLClasspath()
Get the classpath to the weblogic classpaths
protected ClassLoadergetClassLoaderFromJar(File classjar)
Helper method invoked by isRebuildRequired to get a ClassLoader for a Jar File passed to it.
StringgetEjbcClass()
Get the ejbc compiler class
IntegergetJvmDebugLevel()
protected DescriptorHandlergetWeblogicDescriptorHandler(File srcDir)
protected booleanisRebuildRequired(File genericJarFile, File weblogicJarFile)
Helper method to check to see if a weblogic EBJ1.1 jar needs to be rebuilt using ejbc.
protected voidregisterKnownDTDs(DescriptorHandler handler)
voidsetArgs(String args)
Any optional extra arguments pass to the weblogic.ejbc tool.
voidsetCompiler(String compiler)
The compiler (switch -compiler) to use; optional.
voidsetEjbcClass(String ejbcClass)
Set the classname of the ejbc compiler; optional Normally ejbjar determines the appropriate class based on the DTD used for the EJB.
voidsetEJBdtd(String inString)
Deprecated.
voidsetJvmargs(String args)
Set any additional arguments to pass to the weblogic JVM; optional.
voidsetJvmDebugLevel(Integer jvmDebugLevel)
Sets the weblogic.StdoutSeverityLevel to use when running the JVM that executes ejbc; optional.
voidsetKeepgenerated(String inValue)
Controls whether weblogic will keep the generated Java files used to build the class files added to the jar.
voidsetKeepgeneric(boolean inValue)
controls whether the generic file used as input to ejbc is retained; defaults to false
voidsetNewCMP(boolean newCMP)
If this is set to true, the new method for locating CMP descriptors will be used; optional, default false.
voidsetNoEJBC(boolean noEJBC)
Do not EJBC the jar after it has been put together; optional, default false
voidsetOldCMP(boolean oldCMP)
Set the value of the oldCMP scheme.
voidsetOutputDir(File outputDir)
If set ejbc will use this directory as the output destination rather than a jar file.
voidsetRebuild(boolean rebuild)
Set the rebuild flag to false to only update changes in the jar rather than rerunning ejbc; optional, default true.
voidsetSuffix(String inString)
Setter used to store the suffix for the generated weblogic jar file.
voidsetWeblogicdtd(String inString)
Deprecated.
voidsetWLClasspath(Path wlClasspath)
Optional classpath to WL6.0.
voidsetWLdtd(String inString)
Deprecated.
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

COMPILER_EJB11

protected static final String COMPILER_EJB11

COMPILER_EJB20

protected static final String COMPILER_EJB20

DEFAULT_COMPILER

protected static final String DEFAULT_COMPILER

DEFAULT_WL51_DTD_LOCATION

protected static final String DEFAULT_WL51_DTD_LOCATION

DEFAULT_WL51_EJB11_DTD_LOCATION

protected static final String DEFAULT_WL51_EJB11_DTD_LOCATION

DEFAULT_WL60_51_DTD_LOCATION

protected static final String DEFAULT_WL60_51_DTD_LOCATION

DEFAULT_WL60_DTD_LOCATION

protected static final String DEFAULT_WL60_DTD_LOCATION

DEFAULT_WL60_EJB11_DTD_LOCATION

protected static final String DEFAULT_WL60_EJB11_DTD_LOCATION

DEFAULT_WL60_EJB20_DTD_LOCATION

protected static final String DEFAULT_WL60_EJB20_DTD_LOCATION

DEFAULT_WL70_DTD_LOCATION

protected static final String DEFAULT_WL70_DTD_LOCATION

PUBLICID_EJB11

public static final String PUBLICID_EJB11

PUBLICID_EJB20

public static final String PUBLICID_EJB20

PUBLICID_WEBLOGIC_EJB510

public static final String PUBLICID_WEBLOGIC_EJB510

PUBLICID_WEBLOGIC_EJB600

public static final String PUBLICID_WEBLOGIC_EJB600

PUBLICID_WEBLOGIC_EJB700

public static final String PUBLICID_WEBLOGIC_EJB700

WL_CMP_DD

protected static final String WL_CMP_DD

WL_DD

protected static final String WL_DD

Method Detail

addSysproperty

public void addSysproperty(Environment.Variable sysp)
Add a nested sysproperty element.

addVendorFiles

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

createWLClasspath

public Path createWLClasspath()
Get the classpath to the weblogic 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.

getEjbcClass

public String getEjbcClass()
Get the ejbc compiler class

getJvmDebugLevel

public Integer getJvmDebugLevel()

getWeblogicDescriptorHandler

protected DescriptorHandler getWeblogicDescriptorHandler(File srcDir)

isRebuildRequired

protected boolean isRebuildRequired(File genericJarFile, File weblogicJarFile)
Helper method to check to see if a weblogic EBJ1.1 jar needs to be rebuilt using ejbc. 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 weblogic jar needs to be regened with ejbc. This allows faster build times for working developers.

The way weblogic ejbc 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 weblogic 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 ejbc. 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 weblogic jar gets rebuilt if the xml files change at all.

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

registerKnownDTDs

protected void registerKnownDTDs(DescriptorHandler handler)

setArgs

public void setArgs(String args)
Any optional extra arguments pass to the weblogic.ejbc tool.

setCompiler

public void setCompiler(String compiler)
The compiler (switch -compiler) to use; optional. This allows for the selection of a different compiler to be used for the compilation of the generated Java files. This could be set, for example, to Jikes to compile with the Jikes compiler. If this is not set and the build.compiler property is set to jikes, the Jikes compiler will be used. If this is not desired, the value "default" may be given to use the default compiler

setEjbcClass

public void setEjbcClass(String ejbcClass)
Set the classname of the ejbc compiler; optional Normally ejbjar determines the appropriate class based on the DTD used for the EJB. The EJB 2.0 compiler featured in weblogic 6 has, however, been deprecated in version 7. When using with version 7 this attribute should be set to "weblogic.ejbc" to avoid the deprecation warning.

setEJBdtd

public void setEJBdtd(String inString)
Deprecated. Defines the location of Sun's EJB DTD in the weblogic class hierarchy. Should not be needed, and the nested <dtd> element is recommended when it is.

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

setJvmargs

public void setJvmargs(String args)
Set any additional arguments to pass to the weblogic JVM; optional.

Parameters: args the arguments to be passed to the JVM

setJvmDebugLevel

public void setJvmDebugLevel(Integer jvmDebugLevel)
Sets the weblogic.StdoutSeverityLevel to use when running the JVM that executes ejbc; optional. Set to 16 to avoid the warnings about EJB Home and Remotes being in the classpath

setKeepgenerated

public void setKeepgenerated(String inValue)
Controls whether weblogic will keep the generated Java files used to build the class files added to the jar. This can be useful when debugging; default is false.

Parameters: inValue either 'true' or 'false'

setKeepgeneric

public void setKeepgeneric(boolean inValue)
controls whether the generic file used as input to ejbc is retained; defaults to false

Parameters: inValue true for keep generic

setNewCMP

public void setNewCMP(boolean newCMP)
If this is set to true, the new method for locating CMP descriptors will be used; optional, default false.

The old CMP scheme locates the weblogic CMP descriptor based on the naming convention where the weblogic 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 weblogic EJB descriptor. Also, descriptors which contain multiple CMP references could not be used.

setNoEJBC

public void setNoEJBC(boolean noEJBC)
Do not EJBC the jar after it has been put together; optional, default false

setOldCMP

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

UNKNOWN: ignore="true'

setOutputDir

public void setOutputDir(File outputDir)
If set ejbc will use this directory as the output destination rather than a jar file. This allows for the generation of "exploded" jars.

setRebuild

public void setRebuild(boolean rebuild)
Set the rebuild flag to false to only update changes in the jar rather than rerunning ejbc; optional, default true. This flag controls whether weblogic.ejbc is always invoked to build the jar file. In certain circumstances, such as when only a bean class has been changed, the jar can be generated by merely replacing the changed classes and not rerunning ejbc. Setting this to false will reduce the time to run ejbjar.

setSuffix

public void setSuffix(String inString)
Setter used to store the suffix for the generated weblogic jar file.

Parameters: inString the string to use as the suffix.

setWeblogicdtd

public void setWeblogicdtd(String inString)
Deprecated. Defines the location of the ejb-jar DTD in the weblogic class hierarchy. Should not be needed, and the nested <dtd> element is recommended when it is.

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

setWLClasspath

public void setWLClasspath(Path wlClasspath)
Optional classpath to WL6.0. Weblogic 6.0 will give a warning if the home and remote interfaces of a bean are on the system classpath used to run weblogic.ejbc. In that case, the standard weblogic classes should be set with this attribute (or equivalent nested element) and the home and remote interfaces located with the standard classpath attribute

setWLdtd

public void setWLdtd(String inString)
Deprecated. Defines the location of weblogic DTD in the weblogic class hierarchy. Should not be needed, and the nested <dtd> element is recommended when it is.

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

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 B) 2000-2007 Apache Software Foundation. All Rights Reserved.