Fields Summary |
---|
public static final String | PUBLICID_BORLAND_EJBBorland 1.1 ejb id |
protected static final String | DEFAULT_BAS45_EJB11_DTD_LOCATION |
protected static final String | DEFAULT_BAS_DTD_LOCATION |
protected static final String | BAS_DD |
protected static final String | BES_DD |
protected static final String | JAVA2IIOPJava2iiop executable |
protected static final String | VERIFYVerify class |
private String | jarSuffixInstance variable that stores the suffix for the borland jarfile. |
private String | borlandDTDInstance variable that stores the location of the borland DTD file. |
private boolean | java2iiopdebugInstance variable that determines whether the debug mode is on |
private String | java2iioparamsstore additional param for java2iiop command used to build EJB Stubs |
private boolean | generateclientInstance variable that determines whether the client jar file is generated |
static final int | BESBorland Enterprise Server = version 5 |
static final int | BASBorland Application Server or Inprise Application Server = version 4 |
private int | versionborland appserver version 4 or 5 |
private boolean | verifyInstance variable that determines whether it is necessary to verify the
produced jar |
private String | verifyArgs |
private Hashtable | genfiles |
Methods Summary |
---|
protected void | addVendorFiles(java.util.Hashtable ejbFiles, java.lang.String ddPrefix)Add any vendor specific files which should be included in the
EJB Jar.
//choose the right vendor DD
if (!(version == BES || version == BAS)) {
throw new BuildException("version " + version + " is not supported");
}
String dd = (version == BES ? BES_DD : BAS_DD);
log("vendor file : " + ddPrefix + dd, Project.MSG_DEBUG);
File borlandDD = new File(getConfig().descriptorDir, ddPrefix + dd);
if (borlandDD.exists()) {
log("Borland specific file found " + borlandDD, Project.MSG_VERBOSE);
ejbFiles.put(META_DIR + dd , borlandDD);
} else {
log("Unable to locate borland deployment descriptor. "
+ "It was expected to be in "
+ borlandDD.getPath(), Project.MSG_WARN);
return;
}
|
private void | buildBorlandStubs(java.util.Iterator ithomes)Generate stubs & skeleton for each home found into the DD
Add all the generate class file into the ejb files
Execute execTask = null;
execTask = new Execute(this);
Project project = getTask().getProject();
execTask.setAntRun(project);
execTask.setWorkingDirectory(project.getBaseDir());
Commandline commandline = new Commandline();
commandline.setExecutable(JAVA2IIOP);
//debug ?
if (java2iiopdebug) {
commandline.createArgument().setValue("-VBJdebug");
}
//set the classpath
commandline.createArgument().setValue("-VBJclasspath");
commandline.createArgument().setPath(getCombinedClasspath());
//list file
commandline.createArgument().setValue("-list_files");
//no TIE classes
commandline.createArgument().setValue("-no_tie");
if (java2iioparams != null) {
log("additional " + java2iioparams + " to java2iiop ", 0);
commandline.createArgument().setValue(java2iioparams);
}
//root dir
commandline.createArgument().setValue("-root_dir");
commandline.createArgument().setValue(getConfig().srcDir.getAbsolutePath());
//compiling order
commandline.createArgument().setValue("-compile");
//add the home class
while (ithomes.hasNext()) {
commandline.createArgument().setValue(ithomes.next().toString());
}
try {
log("Calling java2iiop", Project.MSG_VERBOSE);
log(commandline.describeCommand(), Project.MSG_DEBUG);
execTask.setCommandline(commandline.getCommandline());
int result = execTask.execute();
if (Execute.isFailure(result)) {
String msg = "Failed executing java2iiop (ret code is "
+ result + ")";
throw new BuildException(msg, getTask().getLocation());
}
} catch (java.io.IOException e) {
log("java2iiop exception :" + e.getMessage(), Project.MSG_ERR);
throw new BuildException(e, getTask().getLocation());
}
|
private void | generateClient(java.io.File sourceJar)Generate the client jar corresponding to the jar file passed as parameter
the method uses the BorlandGenerateClient task.
getTask().getProject().addTaskDefinition("internal_bas_generateclient",
org.apache.tools.ant.taskdefs.optional.ejb.BorlandGenerateClient.class);
org.apache.tools.ant.taskdefs.optional.ejb.BorlandGenerateClient gentask = null;
log("generate client for " + sourceJar, Project.MSG_INFO);
try {
Project project = getTask().getProject();
gentask
= (BorlandGenerateClient) project.createTask("internal_bas_generateclient");
gentask.setEjbjar(sourceJar);
gentask.setDebug(java2iiopdebug);
Path classpath = getCombinedClasspath();
if (classpath != null) {
gentask.setClasspath(classpath);
}
gentask.setVersion(version);
gentask.setTaskName("generate client");
gentask.execute();
} catch (Exception e) {
//TO DO : delete the file if it is not a valid file.
String msg = "Exception while calling " + VERIFY + " Details: "
+ e.toString();
throw new BuildException(msg, e);
}
|
protected DescriptorHandler | getBorlandDescriptorHandler(java.io.File srcDir)Get the borland descriptor handler.
DescriptorHandler handler =
new DescriptorHandler(getTask(), srcDir) {
protected void processElement() {
if (currentElement.equals("type-storage")) {
// Get the filename of vendor specific descriptor
String fileNameWithMETA = currentText;
//trim the META_INF\ off of the file name
String fileName
= fileNameWithMETA.substring(META_DIR.length(),
fileNameWithMETA.length());
File descriptorFile = new File(srcDir, fileName);
ejbFiles.put(fileNameWithMETA, descriptorFile);
}
}
};
handler.registerDTD(PUBLICID_BORLAND_EJB,
borlandDTD == null ? DEFAULT_BAS_DTD_LOCATION : borlandDTD);
for (Iterator i = getConfig().dtdLocations.iterator(); i.hasNext();) {
EjbJar.DTDLocation dtdLocation = (EjbJar.DTDLocation) i.next();
handler.registerDTD(dtdLocation.getPublicId(), dtdLocation.getLocation());
}
return handler;
|
java.io.File | getVendorOutputJarFile(java.lang.String baseName)Get the vendor specific name of the Jar that will be output. The modification date
of this jar will be checked against the dependent bean classes.
return new File(getDestDir(), baseName + jarSuffix);
|
public void | setBASdtd(java.lang.String inString)Setter used to store the location of the borland DTD. This can be a file on the system
or a resource on the classpath.
this.borlandDTD = inString;
|
public void | setDebug(boolean debug)set the debug mode for java2iiop (default false)
this.java2iiopdebug = debug;
|
public void | setGenerateclient(boolean b)setter used to store whether the task will include the generate client task.
(see : BorlandGenerateClient task)
this.generateclient = b;
|
public void | setJava2iiopParams(java.lang.String params)If filled, the params are added to the java2iiop command.
(ex: -no_warn_missing_define)
this.java2iioparams = params;
|
public void | setProcessErrorStream(java.io.InputStream is)Set the error stream of the process.
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String s = reader.readLine();
if (s != null) {
log("[java2iiop] " + s, Project.MSG_ERR);
}
|
public void | setProcessInputStream(java.io.OutputStream param1){@inheritDoc}.
|
public void | setProcessOutputStream(java.io.InputStream is)Set the output stream of the process.
try {
BufferedReader reader = new BufferedReader(new InputStreamReader(is));
String javafile;
while ((javafile = reader.readLine()) != null) {
if (javafile.endsWith(".java")) {
String classfile = toClassFile(javafile);
String key = classfile.substring(
getConfig().srcDir.getAbsolutePath().length() + 1);
genfiles.put(key, new File(classfile));
}
}
reader.close();
} catch (Exception e) {
String msg = "Exception while parsing java2iiop output. Details: " + e.toString();
throw new BuildException(msg, e);
}
|
public void | setSuffix(java.lang.String inString)Setter used to store the suffix for the generated borland jar file.
this.jarSuffix = inString;
|
public void | setVerify(boolean verify)set the verify mode for the produced jar (default true)
this.verify = verify;
|
public void | setVerifyArgs(java.lang.String args)sets some additional args to send to verify command
this.verifyArgs = args;
|
public void | setVersion(int version)setter used to store the borland appserver version [4 or 5]
this.version = version;
|
public void | start(){@inheritDoc}.
|
public void | stop(){@inheritDoc}.
|
private java.lang.String | toClass(java.lang.String filename)convert a class file name : A/B/C/toto.class
into a class name: A.B.C.toto
//remove the .class
String classname = filename.substring(0, filename.lastIndexOf(".class"));
classname = classname.replace('\\", '.");
return classname;
|
private java.lang.String | toClassFile(java.lang.String filename)convert a file name : A/B/C/toto.java
into a class name: A/B/C/toto.class
//remove the .class
String classfile = filename.substring(0, filename.lastIndexOf(".java"));
classfile = classfile + ".class";
return classfile;
|
private void | verifyBorlandJar(java.io.File sourceJar)Verify the produced jar file by invoking the Borland verify tool
if (version == BAS) {
verifyBorlandJarV4(sourceJar);
return;
}
if (version == BES) {
verifyBorlandJarV5(sourceJar);
return;
}
log("verify jar skipped because the version is invalid ["
+ version + "]", Project.MSG_WARN);
|
private void | verifyBorlandJarV4(java.io.File sourceJar)Verify the produced jar file by invoking the Borland verify tool
org.apache.tools.ant.taskdefs.Java javaTask = null;
log("verify BAS " + sourceJar, Project.MSG_INFO);
try {
String args = verifyArgs;
args += " " + sourceJar.getPath();
javaTask = new Java(getTask());
javaTask.setTaskName("verify");
javaTask.setClassname(VERIFY);
Commandline.Argument arguments = javaTask.createArg();
arguments.setLine(args);
Path classpath = getCombinedClasspath();
if (classpath != null) {
javaTask.setClasspath(classpath);
javaTask.setFork(true);
}
log("Calling " + VERIFY + " for " + sourceJar.toString(),
Project.MSG_VERBOSE);
javaTask.execute();
} catch (Exception e) {
//TO DO : delete the file if it is not a valid file.
String msg = "Exception while calling " + VERIFY + " Details: "
+ e.toString();
throw new BuildException(msg, e);
}
|
private void | verifyBorlandJarV5(java.io.File sourceJar)Verify the produced jar file by invoking the Borland iastool tool
log("verify BES " + sourceJar, Project.MSG_INFO);
try {
ExecTask execTask = null;
execTask = new ExecTask(getTask());
execTask.setDir(new File("."));
execTask.setExecutable("iastool");
//classpath
if (getCombinedClasspath() != null) {
execTask.createArg().setValue("-VBJclasspath");
execTask.createArg().setValue(getCombinedClasspath().toString());
}
if (java2iiopdebug) {
execTask.createArg().setValue("-debug");
}
execTask.createArg().setValue("-verify");
execTask.createArg().setValue("-src");
// ejb jar file to verify
execTask.createArg().setValue(sourceJar.getPath());
log("Calling iastool", Project.MSG_VERBOSE);
execTask.execute();
} catch (Exception e) {
// Have to catch this because of the semantics of calling main()
String msg = "Exception while calling generateclient Details: "
+ e.toString();
throw new BuildException(msg, e);
}
|
protected void | writeJar(java.lang.String baseName, java.io.File jarFile, java.util.Hashtable files, java.lang.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.
//build the home classes list.
Vector homes = new Vector();
Iterator it = files.keySet().iterator();
while (it.hasNext()) {
String clazz = (String) it.next();
if (clazz.endsWith("Home.class")) {
//remove .class extension
String home = toClass(clazz);
homes.add(home);
log(" Home " + home, Project.MSG_VERBOSE);
}
}
buildBorlandStubs(homes.iterator());
//add the gen files to the collection
files.putAll(genfiles);
super.writeJar(baseName, jarFile, files, publicId);
if (verify) {
verifyBorlandJar(jarFile);
}
if (generateclient) {
generateClient(jarFile);
}
|