Section 9.6. Developing Enterprise JavaBeans


9.6. Developing Enterprise JavaBeans

Ant provides a number of optional tasks for developing EJBs. Generally, these tasks are specific to the particular vendor's EJB Server. Currently, these tasks support these servers:

  • Borland Application Server 4.5

  • IBM WebSphere 4.0

  • iPlanet Application Server 6.0

  • JBoss 2.1 and above EJB servers

  • JOnAS 2.4.x and 2.5 Open Source EJB server

  • Weblogic 4.5.1 through to 7.0 EJB servers

The Ant EJB tasks and the servers they target appear in Table 9-14.

Table 9-14. The Ant EJB tasks

Task

Does this

Application servers

blgenclient

Specifies you want to create a client .jar file corresponding to an EJB .jar file

Borland Application Server 4.5 and 5.x

ddcreator

Specifies you want to compile Weblogic text-based deployment descriptors into an EJB deployment descriptor

Weblogic 4.5.1

ejbc

Lets you run Weblogic's ejbc tool

Weblogic 4.5.1

ejbjar

Supports creation of EJB .jar files (EJB 1.1 & 2.0)

Borland Application Server 4.5 and 5.x, iPlanet Application Server 6.0, JBoss, JOnAS 2.4.x and 2.5, Weblogic 5.1 to 7.0, and IBM WebSphere 4.0

iplanet-ejbc

Supports compilation of EJB stubs and skeletons for iPlanet Application Server 6.0

iPlanet Application Server 6.0

wlrun

Lets you start a Weblogic server

Weblogic 4.5.1 to 7.0

wlstop

Lets you stop a Weblogic server

Weblogic 4.5.1 to 7.0


9.6.1. JARing Files

The largest and most general of the EJB tasks is the ejbjar task. This task works by scanning directories; for each deployment descriptor found, ejbjar will parse it to determine the necessary .class files which implement the bean. These files are assembled along with the deployment descriptors into a well-formed EJB .jar file. (Any support files which should be included in the created .jar file can be added with the support nested element.) For each class included in the .jar file, ejbjar will scan for any super classes or super interfaces, which will be added to the generated .jar file. The attributes of this task appear in Table 9-15.

Table 9-15. The Ant ejbjar task's attribute

Attribute

Description

Required

Default

basejarname

Specifies the base name you want used for the generated .jar files.

No

 

classpath

Specifies the classpath you wnt used when resolving classes that are to be added to the .jar.

No

 

cmpversion

Specifies the CMP version. Possible values are 1.0 or 2.0.

No

1.0

dependency

Specifies which classes and interfaces are added to the .jar.

No

 

descriptordir

Specifies the directory under which the task shoulc scan for EJB deployment descriptors.

No

 

destdir

Specifies the directory into which you want generated JAR files to be placed.

Yes, unless you use vendor-specific deployment elements.

 

flatdestdir

Specifies you want to store all generated JARs in the root of the destdir, rather than the location specified by the deployment descriptor. Set to true/false.

No

 

genericjarsuffix

Specifies a string that you want appended to the deployment descriptor in order to create the filename of a generic EJB JAR file.

No

-generic.jar

naming

Specifies the naming convention you want to use to name generated EJB jars.

No

 

srcdir

Specifies the base directory containing the .class files that make up the generated bean.

Yes

 


You can nest classpath elements to set the classpath in the ejbjar task, and you can use nested dtd elements to specify the local location of DTDs to be used when parsing the EJB deployment descriptor (see Table 9-2 for the dtd element's attributes).

You can use nested support elements to specify additional .class files to be included in the generated .jar files. The support element is a fileset, so it can reference a fileset declared elsewhere or it can be defined with the appropriate include and exclude nested elements. The ejbjar task supports vendor-specific nested elements, which let you use the vendors' deployment tools.

Vendor-specific nested elements provide support for various vendor deployment tools. (If no nested vendor-specific deployment elements are present, the task will create a generic EJB .jar file.) For each nested deployment element, the vendor-specific deployment tool is run to generate a .jar file for deployment to that vendor's EJB server. Here are the legal vendor-specific nested elements:


borland

For Borland Application Server 4.5 and 5.x


iPlanet

For iPlanet Application Server 6.0


jboss

For JBoss


jonas

For JOnAS 2.4.x and 2.5


weblogic

For Weblogic 5.1 to 7.0


websphere

For IBM WebSphere 4.0

These vendor-specific elements can become involved. For example, the attributes of the weblogic element, used to control the weblogic.ejbc compiler for generating Weblogic EJB .jar files, appear in Table 9-16.

Table 9-16. The weblogic element's attribute

Attribute

Description

Required

Default

args

Specifies any additional arguments you want to pass to the weblogic.ejbc tool.

No

 

classpath

Specifies the classpath that should be used when the task runs the weblogic.ejbc tool.

No

 

compiler

Specifies a different compiler to be used for compiling the generated Java files.

No

 

destdir

Specifies the directory where the generated JAR files should be stored.

Yes

 

ejbcclass

Specifies the classname of the ejbc compiler. When used with Version 7, this attribute should be set to "weblogic.ejbc" to avoid a deprecation warning.

No

 

genericjarsuffix

Specifies the suffix used for the generic JAR file. This JAR file is generated as an intermediate step in building the weblogic deployment JAR.

No

-generic.jar

jvmargs

Specifies any additional arguments you want passed to the JVM running the weblogic.ejbc tool.

No

 

jvmdebuglevel

Specifies the debug level for messages. Set to 16 to avoid warnings about EJB Home and Remotes in the classpath.

No

 

keepgenerated

Specifies if Weblogic will preserve the Java files it generates.

No

false

keepgeneric

Specifies if you want the generic file used for input to ejbc to be preserved.

No

false

newCMP

Specifies ejbjar should parse the Weblogic deployment descriptor to find the CMP descriptors. Set to true/false.

No

false

noEJBC

Specifies you don't want Weblogic's ejbc to be run on the EJB .jar file.

No

 

outputdir

Specifies this directory as the output directory instead of a .jar file.

No

 

rebuild

Specifies if weblogic.ejbc should always be used to build the .jar file.

No

TRue

suffix

Specifies the string that should be added to the deployment descriptor to create the WebLogic JAR filename.

No

.jar

wlclasspath

Specifies the classpath for the Weblogic classes to avoid a warning when the home and remote interfaces of a bean are on the classpath used by weblogic.ejbc.

No

 


The weblogic nested element supports nested classpath and wlclasspath nested elementsthe wlclasspath element holds the classpath used by the Weblogic Server as detailed by the wlclasspath attribute in Table 9-16, and it takes the same attributes and nested elements as classpath. The weblogic element supports nested sysproperty elements to allow Java system properties to be set.

Investigating them all would take us many pages deep into the mechanics of these six EJB servers, and far from Ant. If you're interested, you can find the details for using various vendor-specific tools in the Ant EJB Tasks User Manual at ${ant-home}/docs/manual/OptionalTasks/ejb.html.



    Ant. The Definitive Guide
    Ant: The Definitive Guide, 2nd Edition
    ISBN: 0596006098
    EAN: 2147483647
    Year: 2003
    Pages: 115
    Authors: Steve Holzner

    Similar book on Amazon

    flylib.com © 2008-2017.
    If you may any questions please contact us: flylib@qtcs.net