New blgenclient task to generate client jar for Borland EJBs Submitted by: Beno�t MOUSSAUD <benoit.moussaud@criltelecom.com> git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268929 13f79535-47bb-0310-9956-ffa450edef68master
@@ -0,0 +1,100 @@ | |||
<html> | |||
<head> | |||
<meta http-equiv="Content-Language" content="en-us"> | |||
<title>Ant User Manual</title> | |||
</head> | |||
<body> | |||
<h2><a name="log">BorlandDeploy</a>Tool</h2> | |||
<h3>Description</h3> | |||
<p>The BorlandDeployTool is a vendor specifc nested element for the Ejbjar optionaltask. | |||
<p>BorlandDeploymentTool is dedicated to the Borland Application Server 4.5. It | |||
generates and compiles the stubs and skeletons for all ejb described into the | |||
Deployement Descriptor, builds the jar file including the support files and | |||
verify whether the produced jar is valid or not. | |||
<h3>Borland element</h3> | |||
<table border="1" cellpadding="2" cellspacing="0"> | |||
<tr> | |||
<td valign="top" width="63"><b>Attribute</b></td> | |||
<td valign="top" width="915"><b>Description</b></td> | |||
<td align="center" valign="top" width="62"><b>Required</b></td> | |||
</tr> | |||
<tr> | |||
<td valign="top" width="63">destdir</td> | |||
<td valign="top" width="915">The base directory into which the generated borland | |||
ready jar files are deposited</td> | |||
<td align="center" valign="middle" width="62">yes</td> | |||
</tr> | |||
<tr> | |||
<td valign="top" width="63">debug</td> | |||
<td valign="top" width="915">If true, turn on the debug mode for each borland | |||
tools (java2iiop, iastool ...) default = false</td> | |||
<td align="center" valign="middle" width="62">no</td> | |||
</tr> | |||
<tr> | |||
<td valign="top" width="63">verify</td> | |||
<td valign="top" width="915">If true, turn on the verification at the end | |||
of the jar production (default = false)</td> | |||
<td align="center" valign="middle" width="62">no</td> | |||
</tr> | |||
<tr> | |||
<td valign="top" width="63">verifyargs</td> | |||
<td valign="top" width="915">extra parameter for verify command</td> | |||
<td align="center" valign="middle" width="62">no</td> | |||
</tr> | |||
<tr> | |||
<td valign="top" width="63">suffix</td> | |||
<td valign="top" width="915">String value appended to the basename of the | |||
deployment descriptor to create the filename of the Borland EJB jar file.</td> | |||
<td align="center" valign="middle" width="62">No, defaults to '-ejb.jar'.</td> | |||
</tr> | |||
<tr> | |||
<td valign="top" width="63">basdtd</td> | |||
<td valign="top" width="915"><b>Deprecated</b>. Defines the location of the | |||
weblogic-ejb-jar DTD which covers the Borland specific deployment descriptors. | |||
This should not be necessary if you have borland in your classpath. If you | |||
do not, you should use a nested <dtd> element, described above</td> | |||
<td align="center" valign="middle" width="62">no</td> | |||
</tr> | |||
<tr> | |||
<td valign="top" width="63">ejbdtd</td> | |||
<td valign="top" width="915"><b>Deprecated</b>. Defines the location of the | |||
ejb-jar DTD in the weblogic class hierarchy. This should not be necessary | |||
if you have weblogic in your classpath. If you do not, you should use a | |||
nested <dtd> element, described above. </td> | |||
<td align="center" valign="middle" width="62">no</td> | |||
</tr> | |||
<tr> | |||
<td valign="top" width="63">generateclient </td> | |||
<td valign="top" width="915">If true, turn on the generation of the corresponding | |||
ejbjar (default = false)</td> | |||
<td align="center" valign="middle" width="62">no</td> | |||
</tr> | |||
</table> | |||
<h3>Examples</h3> | |||
<p>The following build.xml snippit is an example of how to use Borland element | |||
into the ejbjar task | |||
<pre> <ejbjar srcdir="${build.classes}" basejarname="vsmp" descriptordir="${rsc.dir}/hrmanager"> | |||
<borland destdir="lib" verify="on" generateclient="on"> | |||
<classpath refid="classpath" /> | |||
</borland> | |||
<include name="**\ejb-jar.xml"/> | |||
<support dir="${build.classes}"> | |||
<include name="demo\*.class"/> | |||
<include name="demo\helper\*.class"/> | |||
</support> | |||
</ejbjar></pre> | |||
<pre>The borland element will generate into the lib dir an ejb jar file using the deployment descriptor placed into the ${rsc.dir}/hrmanager directory. | |||
The verify phase is turned on and the generate client phase as well. | |||
</pre> | |||
<h3> </h3> | |||
<p align="center">Copyright © 2000,2001 Apache Software Foundation. All rights | |||
Reserved.</p> | |||
</body> | |||
</html> | |||
@@ -0,0 +1,56 @@ | |||
<html> | |||
<head> | |||
<meta http-equiv="Content-Language" content="en-us"> | |||
<title>Ant User Manual</title> | |||
</head> | |||
<body> | |||
<h2><a name="log">BorlandGenerateClient</a></h2> | |||
<h3>Description</h3> | |||
<p>The BorlandGenerateClient is a task dedicated to Borland Application Server | |||
v 4.5. It offers to generate the client jar file corresponding to an ejb jar | |||
file. | |||
<h3>Parameters</h3> | |||
<table border="1" cellpadding="2" cellspacing="0"> | |||
<tr> | |||
<td valign="top" width="63"><b>Attribute</b></td> | |||
<td valign="top" width="915"><b>Description</b></td> | |||
<td align="center" valign="top" width="62"><b>Required</b></td> | |||
</tr> | |||
<tr> | |||
<td valign="top" width="63">ejbjar</td> | |||
<td valign="top" width="915">ejb jar file</td> | |||
<td align="center" valign="middle" width="62">yes</td> | |||
</tr> | |||
<tr> | |||
<td valign="top" width="63">debug</td> | |||
<td valign="top" width="915">If true, turn on the debug mode for each borland | |||
tools (java2iiop, iastool ...) default = false</td> | |||
<td align="center" valign="middle" width="62">no</td> | |||
</tr> | |||
<tr> | |||
<td valign="top" width="63">clientjar</td> | |||
<td valign="top" width="915">client jar file name. If missing the client jar | |||
file name is build using the ejbjar file name: ejbjar = hellobean-ejb.jar | |||
=> hellobean-ejbclient.jar</td> | |||
<td align="center" valign="middle" width="62">no</td> | |||
</tr> | |||
</table> | |||
<h3>Examples</h3> | |||
<p>The following build.xml snippit is an example of how to use Borland element | |||
into the ejbjar task | |||
<pre> .... | |||
<generateclient ejbjar="lib/secutest-ejb.jar" clientjar="lib/client.jar" debug="true"/> | |||
.... | |||
</pre> | |||
<pre> </pre> | |||
<p align="center">Copyright © 2000,2001 Apache Software Foundation. All rights | |||
Reserved.</p> | |||
</body> | |||
</html> | |||
@@ -35,12 +35,16 @@ to support additional EJB Servers. | |||
<hr> | |||
<h2><a name="ejbtasks">EJB Tasks</a></h2> | |||
<table border="1" cellpadding="5"> | |||
<tr><td>Task</td><td>Application Servers</td></tr> | |||
<tr><td><a href="#ddcreator">ddcreator</a></td><td>Weblogic 4.5.1</td></tr> | |||
<tr><td><a href="#ejbc">ejbc</a></td><td>Weblogic 4.5.1</td></tr> | |||
<tr><td><a href="#wlrun">wlrun</a></td><td>Weblogic 4.5.1, 5.1 & 6.0</td></tr> | |||
<tr><td><a href="#wlstop">wlstop</a></td><td>Weblogic 4.5.1, 5.1 & 6.0</td></tr> | |||
<tr><td><a href="#ejbjar">ejbjar</a></td><td>Weblogic 5.1 & 6.0</td></tr> | |||
<tr><td>Task</td><td colspan="2">Application Servers</td></tr> | |||
<tr><td><a href="BorlandGenerateClient.html">blgenclient</a></td><td colspan="2">Borland Application Server 4.5</td></tr> | |||
<tr><td><a href="#ddcreator">ddcreator</a></td><td colspan="2">Weblogic 4.5.1</td></tr> | |||
<tr><td><a href="#ejbc">ejbc</a></td><td colspan="2">Weblogic 4.5.1</td></tr> | |||
<tr><td rowspan="3"><a href="#ejbjar">ejbjar</a></td><td colspan="2" align="center">Nested Elements</td></tr> | |||
<tr><td><a href="#ejbjar_weblogic">weblogic</a></td><td>Weblogic 5.1 & 6.0</td></tr> | |||
<tr><td><a href="BorlandEJBTasks.html">borland</a></td><td>Borland Application Server 4.5</td></tr> | |||
<tr><td><a href="#wlrun">wlrun</a></td><td colspan="2">Weblogic 4.5.1, 5.1 & 6.0</td></tr> | |||
<tr><td><a href="#wlstop">wlstop</a></td><td colspan="2">Weblogic 4.5.1, 5.1 & 6.0</td></tr> | |||
</table> | |||
<hr> | |||
@@ -558,6 +562,7 @@ Each vendor-specific nested element controls the generation of a deployable jar | |||
specific to that vendor's EJB container. The parameters for each supported | |||
deployment element are detailed here. | |||
<a name="ejbjar_weblogic"></a> | |||
<h3>Weblogic element</h3> | |||
<p>The weblogic element is used to control the weblogic.ejbc compiler for | |||
@@ -94,6 +94,7 @@ sound=org.apache.tools.ant.taskdefs.optional.sound.SoundTask | |||
junitreport=org.apache.tools.ant.taskdefs.optional.junit.XMLResultAggregator | |||
vsslabel=org.apache.tools.ant.taskdefs.optional.vss.MSVSSLABEL | |||
vsshistory=org.apache.tools.ant.taskdefs.optional.vss.MSVSSHISTORY | |||
blgenclient=org.apache.tools.ant.taskdefs.optional.ejb.BorlandGenerateClient | |||
# deprecated ant tasks (kept for back compatibility) | |||
javadoc2=org.apache.tools.ant.taskdefs.Javadoc | |||
@@ -52,6 +52,7 @@ | |||
* <http://www.apache.org/>. | |||
*/ | |||
package org.apache.tools.ant.taskdefs.optional.ejb; | |||
import java.io.*; | |||
@@ -73,7 +74,7 @@ import org.xml.sax.*; | |||
/** | |||
* BorlandDeploymentTool is dedicated to the Borland Application Server 4.5 | |||
* This task generates and compilesthe stubs and skeletons for all ejb described into the | |||
* This task generates and compiles the stubs and skeletons for all ejb described into the | |||
* Deployement Descriptor, builds the jar file including the support files and verify | |||
* whether the produced jar is valid or not. | |||
* The supported options are: | |||
@@ -83,6 +84,7 @@ import org.xml.sax.*; | |||
* <li>verifyargs (String) : add optional argument to verify command (see vbj com.inprise.ejb.util.Verify)</li> | |||
* <li>ejbdtd (String) : location of the SUN DTD </li> | |||
* <li>basdtd (String) : location of the BAS DTD </li> | |||
* <li>generatelclient (boolean) : turn on the client jar file generation </li> | |||
* </ul> | |||
* | |||
*<PRE> | |||
@@ -98,6 +100,7 @@ import org.xml.sax.*; | |||
* </support> | |||
* </ejbjar> | |||
*</PRE> | |||
* @author <a href="mailto:benoit.moussaud@criltelecom.com">Benoit Moussaud</a> | |||
* | |||
*/ | |||
public class BorlandDeploymentTool extends GenericDeploymentTool | |||
@@ -125,7 +128,7 @@ public class BorlandDeploymentTool extends GenericDeploymentTool | |||
protected static final String VERIFY = "com.inprise.ejb.util.Verify"; | |||
/** Instance variable that stores the suffix for the borland jarfile. */ | |||
private String jarSuffix = ".jar"; | |||
private String jarSuffix = "-ejb.jar"; | |||
/** Instance variable that stores the location of the borland DTD file. */ | |||
private String borlandDTD; | |||
@@ -137,6 +140,8 @@ public class BorlandDeploymentTool extends GenericDeploymentTool | |||
/** Instance variable that determines whether the debug mode is on */ | |||
private boolean java2iiopdebug = false; | |||
/** Instance variable that determines whetger the client jar file is generated */ | |||
private boolean generateclient = false; | |||
/** Instance variable that determines whether it is necessary to verify the produced jar */ | |||
private boolean verify = true; | |||
private String verifyArgs = ""; | |||
@@ -156,7 +161,6 @@ public class BorlandDeploymentTool extends GenericDeploymentTool | |||
} | |||
/** | |||
* Setter used to store the suffix for the generated borland jar file. | |||
* @param inString the string to use as the suffix. | |||
@@ -168,9 +172,9 @@ public class BorlandDeploymentTool extends GenericDeploymentTool | |||
/** | |||
* sets some additional args to send to verify command | |||
* @param args addtions command line parameters | |||
*/ | |||
public void setVerifyArgs(String args) | |||
{ | |||
public void setVerifyArgs(String args) { | |||
this.verifyArgs = args; | |||
} | |||
@@ -193,28 +197,35 @@ public class BorlandDeploymentTool extends GenericDeploymentTool | |||
this.ejb11DTD = inString; | |||
} | |||
/** | |||
* setter used to store whether the task will include the generate client task. | |||
* (see : BorlandGenerateClient task) | |||
*/ | |||
public void setGenerateclient(boolean b) { | |||
this.generateclient = b; | |||
} | |||
protected void registerKnownDTDs(DescriptorHandler handler) { | |||
handler.registerDTD(PUBLICID_EJB11, DEFAULT_BAS45_EJB11_DTD_LOCATION); | |||
} | |||
protected DescriptorHandler getBorlandDescriptorHandler(final File srcDir) { | |||
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); | |||
} | |||
} | |||
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); | |||
@@ -232,35 +243,30 @@ public class BorlandDeploymentTool extends GenericDeploymentTool | |||
protected void addVendorFiles(Hashtable ejbFiles, String baseName) { | |||
File borlandDD = new File(getConfig().descriptorDir,META_DIR+BAS_DD); | |||
if (borlandDD.exists()) | |||
{ | |||
if (borlandDD.exists()) { | |||
log("Borland specific file found "+ borlandDD, Project.MSG_VERBOSE); | |||
ejbFiles.put(META_DIR + BAS_DD, borlandDD); | |||
} | |||
else | |||
{ | |||
else { | |||
log("Unable to locate borland deployment descriptor. It was expected to be in " + | |||
borlandDD.getPath(), Project.MSG_WARN); | |||
return; | |||
} | |||
} | |||
/** | |||
* 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. | |||
*/ | |||
File getVendorOutputJarFile(String baseName) | |||
{ | |||
return new File(getDestDir(), baseName + jarSuffix); | |||
File getVendorOutputJarFile(String baseName) { | |||
return new File(getDestDir(), baseName + jarSuffix); | |||
} | |||
/** | |||
* Verify the produced jar file by invoking the Borland verify tool | |||
* @param sourceJar java.io.File representing the produced jar file | |||
*/ | |||
private void verifyBorlandJar(File sourceJar) | |||
{ | |||
private void verifyBorlandJar(File sourceJar) { | |||
org.apache.tools.ant.taskdefs.Java javaTask = null; | |||
log("verify "+sourceJar,Project.MSG_INFO); | |||
try { | |||
@@ -283,14 +289,39 @@ public class BorlandDeploymentTool extends GenericDeploymentTool | |||
log("Calling "+VERIFY+" for " + sourceJar.toString(), Project.MSG_VERBOSE); | |||
javaTask.execute(); | |||
} | |||
catch (Exception e) | |||
{ | |||
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); | |||
} | |||
} | |||
/** | |||
* Generate the client jar corresponding to the jar file passed as paremeter | |||
* the method uses the BorlandGenerateClient task. | |||
* @param sourceJar java.io.File representing the produced jar file | |||
*/ | |||
private void generateClient(File sourceJar) { | |||
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 { | |||
String args = verifyArgs; | |||
args += " "+sourceJar.getPath(); | |||
gentask = (BorlandGenerateClient) getTask().getProject().createTask("internal_bas_generateclient"); | |||
gentask.setEjbjar(sourceJar); | |||
gentask.setDebug(java2iiopdebug); | |||
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); | |||
} | |||
} | |||
/** | |||
@@ -299,16 +330,17 @@ public class BorlandDeploymentTool extends GenericDeploymentTool | |||
* @param ithomes : iterator on home class | |||
* @param files : file list , updated by the adding generated files | |||
*/ | |||
private void buildBorlandStubs(Iterator ithomes,Hashtable files ) | |||
{ | |||
private void buildBorlandStubs(Iterator ithomes,Hashtable files ) { | |||
org.apache.tools.ant.taskdefs.ExecTask execTask = null; | |||
File java2iiopOut = new File("java2iiop.log"); | |||
try | |||
{ | |||
//File java2iiopOut = new File("java2iiop.log"); | |||
File java2iiopOut = null; | |||
try { | |||
java2iiopOut = File.createTempFile("java2iiop","log"); | |||
log(" iiop log file : "+ java2iiopOut ,Project.MSG_DEBUG); | |||
execTask = (ExecTask) getTask().getProject().createTask("exec"); | |||
execTask.setOutput(java2iiopOut); | |||
if ( java2iiopdebug ) | |||
{ | |||
if ( java2iiopdebug ) { | |||
execTask.createArg().setValue("-VBJdebug"); | |||
} // end of if () | |||
@@ -319,14 +351,15 @@ public class BorlandDeploymentTool extends GenericDeploymentTool | |||
execTask.createArg().setPath(getCombinedClasspath()); | |||
//list file | |||
execTask.createArg().setValue("-list_files"); | |||
//no TIE classes | |||
execTask.createArg().setValue("-no_tie"); | |||
//root dir | |||
execTask.createArg().setValue("-root_dir"); | |||
execTask.createArg().setValue(getConfig().srcDir.getAbsolutePath()); | |||
//compiling order | |||
execTask.createArg().setValue("-compile"); | |||
//add the home class | |||
while ( ithomes.hasNext()) | |||
{ | |||
while ( ithomes.hasNext()) { | |||
execTask.createArg().setValue(ithomes.next().toString()); | |||
} // end of while () | |||
log("Calling java2iiop",Project.MSG_VERBOSE); | |||
@@ -338,15 +371,12 @@ public class BorlandDeploymentTool extends GenericDeploymentTool | |||
throw new BuildException(msg, e); | |||
} | |||
try | |||
{ | |||
try { | |||
FileReader fr = new FileReader(java2iiopOut); | |||
LineNumberReader lnr = new LineNumberReader(fr); | |||
String javafile; | |||
while ( ( javafile = lnr.readLine()) != null) | |||
{ | |||
if ( javafile.endsWith(".java") ) | |||
{ | |||
while ( ( javafile = lnr.readLine()) != null) { | |||
if ( javafile.endsWith(".java") ) { | |||
String classfile = toClassFile(javafile); | |||
String key = classfile.substring(getConfig().srcDir.getAbsolutePath().length()+1); | |||
@@ -357,11 +387,13 @@ public class BorlandDeploymentTool extends GenericDeploymentTool | |||
} // end of while () | |||
lnr.close(); | |||
} | |||
catch(Exception e) | |||
{ | |||
catch(Exception e) { | |||
String msg = "Exception while parsing java2iiop output. Details: " + e.toString(); | |||
throw new BuildException(msg, e); | |||
} | |||
//delete the output , only if all is succesfull | |||
java2iiopOut.delete(); | |||
} | |||
/** | |||
@@ -369,16 +401,14 @@ public class BorlandDeploymentTool extends GenericDeploymentTool | |||
* filenames/java.io.Files in the Hashtable stored on the instance variable | |||
* ejbFiles. | |||
*/ | |||
protected void writeJar(String baseName, File jarFile, Hashtable files, | |||
String publicId) throws BuildException { | |||
protected void writeJar(String baseName, File jarFile, Hashtable files, String publicId) | |||
throws BuildException { | |||
//build the home classes list. | |||
Vector homes = new Vector(); | |||
Iterator it = files.keySet().iterator(); | |||
while ( it.hasNext()) | |||
{ | |||
while ( it.hasNext()) { | |||
String clazz = (String) it.next(); | |||
if ( clazz.endsWith("Home.class") ) | |||
{ | |||
if ( clazz.endsWith("Home.class") ) { | |||
//remove .class extension | |||
String home = toClass(clazz); | |||
homes.add(home); | |||
@@ -390,19 +420,20 @@ public class BorlandDeploymentTool extends GenericDeploymentTool | |||
super.writeJar(baseName, jarFile, files, publicId); | |||
if ( verify ) | |||
{ | |||
if ( verify ) { | |||
verifyBorlandJar(jarFile); | |||
} // end of if () | |||
if ( generateclient) { | |||
generateClient(jarFile); | |||
} // end of if () | |||
} | |||
/** | |||
* convert a class file name : A/B/C/toto.class | |||
* into a class name: A.B.C.toto | |||
*/ | |||
protected String toClass(String filename) | |||
{ | |||
private String toClass(String filename) { | |||
//remove the .class | |||
String classname = filename.substring(0,filename.lastIndexOf(".class")); | |||
classname = classname.replace('\\','.'); | |||
@@ -413,8 +444,7 @@ public class BorlandDeploymentTool extends GenericDeploymentTool | |||
* convert a file name : A/B/C/toto.java | |||
* into a class name: A/B/C/toto.class | |||
*/ | |||
protected String toClassFile(String filename) | |||
{ | |||
private String toClassFile(String filename) { | |||
//remove the .class | |||
String classfile = filename.substring(0,filename.lastIndexOf(".java")); | |||
classfile = classfile+".class"; | |||
@@ -0,0 +1,172 @@ | |||
/* | |||
* The Apache Software License, Version 1.1 | |||
* | |||
* Copyright (c) 2000 The Apache Software Foundation. All rights | |||
* reserved. | |||
* | |||
* Redistribution and use in source and binary forms, with or without | |||
* modification, are permitted provided that the following conditions | |||
* are met: | |||
* | |||
* 1. Redistributions of source code must retain the above copyright | |||
* notice, this list of conditions and the following disclaimer. | |||
* | |||
* 2. Redistributions in binary form must reproduce the above copyright | |||
* notice, this list of conditions and the following disclaimer in | |||
* the documentation and/or other materials provided with the | |||
* distribution. | |||
* | |||
* 3. The end-user documentation included with the redistribution, if | |||
* any, must include the following acknowlegement: | |||
* "This product includes software developed by the | |||
* Apache Software Foundation (http://www.apache.org/)." | |||
* Alternately, this acknowlegement may appear in the software itself, | |||
* if and wherever such third-party acknowlegements normally appear. | |||
* | |||
* 4. The names "The Jakarta Project", "Ant", and "Apache Software | |||
* Foundation" must not be used to endorse or promote products derived | |||
* from this software without prior written permission. For written | |||
* permission, please contact apache@apache.org. | |||
* | |||
* 5. Products derived from this software may not be called "Apache" | |||
* nor may "Apache" appear in their names without prior written | |||
* permission of the Apache Group. | |||
* | |||
* THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESSED OR IMPLIED | |||
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES | |||
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | |||
* DISCLAIMED. IN NO EVENT SHALL THE APACHE SOFTWARE FOUNDATION OR | |||
* ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | |||
* SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | |||
* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF | |||
* USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND | |||
* ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, | |||
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT | |||
* OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF | |||
* SUCH DAMAGE. | |||
* ==================================================================== | |||
* | |||
* This software consists of voluntary contributions made by many | |||
* individuals on behalf of the Apache Software Foundation. For more | |||
* information on the Apache Software Foundation, please see | |||
* <http://www.apache.org/>. | |||
*/ | |||
package org.apache.tools.ant.taskdefs.optional.ejb; | |||
import java.io.*; | |||
import java.io.FileReader; | |||
import java.io.LineNumberReader; | |||
import java.io.StringReader; | |||
import java.net.*; | |||
import java.util.*; | |||
import java.util.Iterator; | |||
import java.util.jar.*; | |||
import javax.xml.parsers.*; | |||
import org.apache.tools.ant.*; | |||
import org.apache.tools.ant.taskdefs.ExecTask; | |||
import org.apache.tools.ant.taskdefs.Java; | |||
import org.apache.tools.ant.types.*; | |||
import org.apache.tools.ant.types.Commandline.Argument; | |||
import org.xml.sax.*; | |||
/** | |||
* BorlandGenerateClient is dedicated to the Borland Application Server 4.5 | |||
* This task generates the client jar using as input the ejb jar file. | |||
* | |||
* @author <a href="mailto:benoit.moussaud@criltelecom.com">Benoit Moussaud</a> | |||
* | |||
*/ | |||
public class BorlandGenerateClient extends Task | |||
{ | |||
/** debug the generateclient task */ | |||
boolean debug = false; | |||
/** hold the ejbjar file name */ | |||
File ejbjarfile = null; | |||
/** hold the client jar file name */ | |||
File clientjarfile = null; | |||
public void setDebug(boolean debug) | |||
{ | |||
this.debug = debug; | |||
} | |||
public void setEjbjar(File ejbfile) | |||
{ | |||
ejbjarfile = ejbfile; | |||
} | |||
public void setClientjar(File clientjar) | |||
{ | |||
clientjarfile = clientjar; | |||
} | |||
/** | |||
* Do the work. | |||
* | |||
* The work is actually done by creating a separate JVM to run a java task. | |||
* | |||
* @exception BuildException if someting goes wrong with the build | |||
*/ | |||
public void execute() throws BuildException | |||
{ | |||
try | |||
{ | |||
if ( ejbjarfile == null || | |||
ejbjarfile.isDirectory()) | |||
{ | |||
throw new BuildException("invalid ejb jar file."); | |||
} // end of if () | |||
if ( clientjarfile == null || | |||
clientjarfile.isDirectory()) | |||
{ | |||
log("invalid or missing client jar file.",Project.MSG_VERBOSE); | |||
String ejbjarname = ejbjarfile.getAbsolutePath(); | |||
//clientname = ejbjarfile+client.jar | |||
String clientname = ejbjarname.substring(0,ejbjarname.lastIndexOf(".")); | |||
clientname = clientname + "client.jar"; | |||
clientjarfile = new File(clientname); | |||
} // end of if () | |||
log("client jar file is " + clientjarfile); | |||
org.apache.tools.ant.taskdefs.ExecTask execTask = null; | |||
execTask = (ExecTask) getProject().createTask("exec"); | |||
execTask.setDir(new File(".")); | |||
execTask.setExecutable("iastool"); | |||
execTask.createArg().setValue("generateclient"); | |||
if ( debug ) | |||
{ | |||
execTask.createArg().setValue("-trace"); | |||
} // end of if () | |||
// | |||
execTask.createArg().setValue("-short"); | |||
execTask.createArg().setValue("-jarfile"); | |||
// ejb jar file | |||
execTask.createArg().setValue(ejbjarfile.getAbsolutePath()); | |||
//client jar file | |||
execTask.createArg().setValue("-single"); | |||
execTask.createArg().setValue("-clientjarfile"); | |||
execTask.createArg().setValue(clientjarfile.getAbsolutePath()); | |||
log("Calling java2iiop",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); | |||
} | |||
} | |||
} |