IPlanetEjbcTaskpublic class IPlanetEjbcTask extends org.apache.tools.ant.Task Compiles EJB stubs and skeletons for the iPlanet Application Server.
The EJBs to be processed are specified by the EJB 1.1 standard XML
descriptor, and additional attributes are obtained from the iPlanet Application
Server-specific XML descriptor. Since the XML descriptors can include
multiple EJBs, this is a convenient way of specifying many EJBs in a single
Ant task. The following attributes are allowed:
- ejbdescriptor -- Standard EJB 1.1 XML descriptor (typically
titled "ejb-jar.xml"). This attribute is
required.
- iasdescriptor -- EJB XML descriptor for iPlanet Application
Server (typically titled "ias-ejb-jar.xml).
This attribute is required.
- dest -- The is the base directory where the RMI stubs and
skeletons are written. In addition, the class files
for each bean (home interface, remote interface, and
EJB implementation) must be found in this directory.
This attribute is required.
- classpath -- The classpath used when generating EJB stubs and
skeletons. This is an optional attribute (if
omitted, the classpath specified when Ant was
started will be used). Nested "classpath"
elements may also be used.
- keepgenerated -- Indicates whether or not the Java source
files which are generated by ejbc will be
saved or automatically deleted. If "yes",
the source files will be retained. This is
an optional attribute (if omitted, it
defaults to "no").
- debug -- Indicates whether or not the ejbc utility should
log additional debugging statements to the standard
output. If "yes", the additional debugging statements
will be generated (if omitted, it defaults to "no").
- iashome -- May be used to specify the "home" directory for
this iPlanet Application Server installation. This
is used to find the ejbc utility if it isn't
included in the user's system path. This is an
optional attribute (if specified, it should refer
to the
[install-location]/iplanet/ias6/ias
directory). If omitted, the ejbc utility
must be on the user's system path.
For each EJB specified, this task will locate the three classes that comprise
the EJB. If these class files cannot be located in the dest
directory, the task will fail. The task will also attempt to locate the EJB
stubs and skeletons in this directory. If found, the timestamps on the
stubs and skeletons will be checked to ensure they are up to date. Only if
these files cannot be found or if they are out of date will ejbc be called
to generate new stubs and skeletons. |
Fields Summary |
---|
private File | ejbdescriptor | private File | iasdescriptor | private File | dest | private org.apache.tools.ant.types.Path | classpath | private boolean | keepgenerated | private boolean | debug | private File | iashome |
Methods Summary |
---|
private void | checkConfiguration()Verifies that the user selections are valid.
if (ejbdescriptor == null) {
String msg = "The standard EJB descriptor must be specified using "
+ "the \"ejbdescriptor\" attribute.";
throw new BuildException(msg, getLocation());
}
if ((!ejbdescriptor.exists()) || (!ejbdescriptor.isFile())) {
String msg = "The standard EJB descriptor (" + ejbdescriptor
+ ") was not found or isn't a file.";
throw new BuildException(msg, getLocation());
}
if (iasdescriptor == null) {
String msg = "The iAS-speific XML descriptor must be specified using"
+ " the \"iasdescriptor\" attribute.";
throw new BuildException(msg, getLocation());
}
if ((!iasdescriptor.exists()) || (!iasdescriptor.isFile())) {
String msg = "The iAS-specific XML descriptor (" + iasdescriptor
+ ") was not found or isn't a file.";
throw new BuildException(msg, getLocation());
}
if (dest == null) {
String msg = "The destination directory must be specified using "
+ "the \"dest\" attribute.";
throw new BuildException(msg, getLocation());
}
if ((!dest.exists()) || (!dest.isDirectory())) {
String msg = "The destination directory (" + dest + ") was not "
+ "found or isn't a directory.";
throw new BuildException(msg, getLocation());
}
if ((iashome != null) && (!iashome.isDirectory())) {
String msg = "If \"iashome\" is specified, it must be a valid "
+ "directory (it was set to " + iashome + ").";
throw new BuildException(msg, getLocation());
}
| public org.apache.tools.ant.types.Path | createClasspath()Adds to the classpath used when compiling the EJB stubs and skeletons.
if (classpath == null) {
classpath = new Path(getProject());
}
return classpath.createPath();
| public void | execute()Does the work.
checkConfiguration();
executeEjbc(getParser());
| private void | executeEjbc(javax.xml.parsers.SAXParser saxParser)Executes the EJBc utility using the SAXParser provided.
IPlanetEjbc ejbc = new IPlanetEjbc(ejbdescriptor,
iasdescriptor,
dest,
getClasspath().toString(),
saxParser);
ejbc.setRetainSource(keepgenerated);
ejbc.setDebugOutput(debug);
if (iashome != null) {
ejbc.setIasHomeDir(iashome);
}
try {
ejbc.execute();
} catch (IOException e) {
String msg = "An IOException occurred while trying to read the XML "
+ "descriptor file: " + e.getMessage();
throw new BuildException(msg, e, getLocation());
} catch (SAXException e) {
String msg = "A SAXException occurred while trying to read the XML "
+ "descriptor file: " + e.getMessage();
throw new BuildException(msg, e, getLocation());
} catch (IPlanetEjbc.EjbcException e) {
String msg = "An exception occurred while trying to run the ejbc "
+ "utility: " + e.getMessage();
throw new BuildException(msg, e, getLocation());
}
| private org.apache.tools.ant.types.Path | getClasspath()Returns the CLASSPATH to be used when calling EJBc. If no user CLASSPATH
is specified, the System classpath is returned instead.
Path cp = null;
if (classpath == null) {
cp = (new Path(getProject())).concatSystemClasspath("last");
} else {
cp = classpath.concatSystemClasspath("ignore");
}
return cp;
| private javax.xml.parsers.SAXParser | getParser()Returns a SAXParser that may be used to process the XML descriptors.
SAXParser saxParser = null;
try {
SAXParserFactory saxParserFactory = SAXParserFactory.newInstance();
saxParserFactory.setValidating(true);
saxParser = saxParserFactory.newSAXParser();
} catch (SAXException e) {
String msg = "Unable to create a SAXParser: " + e.getMessage();
throw new BuildException(msg, e, getLocation());
} catch (ParserConfigurationException e) {
String msg = "Unable to create a SAXParser: " + e.getMessage();
throw new BuildException(msg, e, getLocation());
}
return saxParser;
| public void | setClasspath(org.apache.tools.ant.types.Path classpath)Sets the classpath to be used when compiling the EJB stubs and skeletons.
if (this.classpath == null) {
this.classpath = classpath;
} else {
this.classpath.append(classpath);
}
| public void | setDebug(boolean debug)If true, debugging output will be generated when ejbc is
executed.
this.debug = debug;
| public void | setDest(java.io.File dest)Sets the destination directory where the EJB source classes must exist
and where the stubs and skeletons will be written. The destination
directory must exist before this task is executed.
this.dest = dest;
| public void | setEjbdescriptor(java.io.File ejbdescriptor)Sets the location of the standard XML EJB descriptor. Typically, this
file is named "ejb-jar.xml".
this.ejbdescriptor = ejbdescriptor;
| public void | setIasdescriptor(java.io.File iasdescriptor)Sets the location of the iAS-specific XML EJB descriptor. Typically,
this file is named "ias-ejb-jar.xml".
this.iasdescriptor = iasdescriptor;
| public void | setIashome(java.io.File iashome)May be used to specify the "home" directory for this iAS installation.
The directory specified should typically be
[install-location]/iplanet/ias6/ias .
this.iashome = iashome;
| public void | setKeepgenerated(boolean keepgenerated)If true, the Java source files which are generated by ejbc will be saved .
this.keepgenerated = keepgenerated;
|
|