conor 01/03/13 17:22:23
Modified: src/main/org/apache/tools/ant/taskdefs/optional/ejb
DescriptorHandler.java EjbJar.java
GenericDeploymentTool.java
WeblogicDeploymentTool.java
Log:
Support setting of the ejbc compiler class.
I also added some code to determine the compiler to use based on the publicID
of the DTD referenced in the descriptor.
Submitted by: Ted Kandell [EMAIL PROTECTED]
Revision Changes Path
1.7 +27 -4
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java
Index: DescriptorHandler.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/DescriptorHandler.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- DescriptorHandler.java 2001/02/18 13:44:42 1.6
+++ DescriptorHandler.java 2001/03/14 01:22:21 1.7
@@ -61,6 +61,8 @@
import org.xml.sax.SAXException;
import org.xml.sax.AttributeList;
+import org.apache.tools.ant.*;
+
/**
* Inner class used by EjbJar to facilitate the parsing of deployment
* descriptors and the capture of appropriate information. Extends
@@ -70,6 +72,10 @@
* list can then be accessed through the getFiles() method.
*/
public class DescriptorHandler extends org.xml.sax.HandlerBase {
+ private Task owningTask;
+
+ private String publicId = null;
+
/**
* Bunch of constants used for storing entries in a hashtable, and for
* constructing the filenames of various parts of the ejb jar.
@@ -111,7 +117,8 @@
*/
private File srcDir;
- public DescriptorHandler(File srcDir) {
+ public DescriptorHandler(Task task, File srcDir) {
+ this.owningTask = task;
this.srcDir = srcDir;
}
@@ -122,22 +129,28 @@
File fileDTD = new File(location);
if (fileDTD.exists()) {
- fileDTDs.put(publicId, fileDTD);
+ if (publicId != null) {
+ fileDTDs.put(publicId, fileDTD);
+ }
return;
}
if (getClass().getResource(location) != null) {
- resourceDTDs.put(publicId, location);
+ if (publicId != null) {
+ resourceDTDs.put(publicId, location);
+ }
}
}
public InputSource resolveEntity(String publicId, String systemId)
throws SAXException
{
+ this.publicId = publicId;
File dtdFile = (File) fileDTDs.get(publicId);
if (dtdFile != null) {
try {
+ owningTask.log("Resolved " + publicId + " to local file " +
dtdFile, Project.MSG_VERBOSE);
return new InputSource(new FileInputStream(dtdFile));
} catch( FileNotFoundException ex ) {
// ignore
@@ -148,10 +161,14 @@
if (dtdResourceName != null) {
InputStream is =
this.getClass().getResourceAsStream(dtdResourceName);
if( is != null ) {
+ owningTask.log("Resolved " + publicId + " to local resource
" + dtdResourceName, Project.MSG_VERBOSE);
return new InputSource(is);
}
}
+ owningTask.log("Could not resolve ( publicId: " + publicId + ",
systemId: " + systemId + ") to a local entity",
+ Project.MSG_INFO);
+
return null;
}
@@ -162,7 +179,13 @@
return (ejbFiles == null) ? new Hashtable() : ejbFiles;
}
-
+ /**
+ * Get the publicId of the DTD
+ */
+ public String getPublicId() {
+ return publicId;
+ }
+
/**
* SAX parser call-back method that is used to initialize the values of
some
* instance variables to ensure safe operation.
1.15 +2 -2
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/EjbJar.java
Index: EjbJar.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/EjbJar.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- EjbJar.java 2001/02/13 12:31:59 1.14
+++ EjbJar.java 2001/03/14 01:22:22 1.15
@@ -104,8 +104,8 @@
public class EjbJar extends MatchingTask {
public static class DTDLocation {
- private String publicId;
- private String location;
+ private String publicId = null;
+ private String location = null;
public void setPublicId(String publicId) {
this.publicId = publicId;
1.15 +4 -3
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java
Index: GenericDeploymentTool.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java,v
retrieving revision 1.14
retrieving revision 1.15
diff -u -r1.14 -r1.15
--- GenericDeploymentTool.java 2001/02/13 12:31:59 1.14
+++ GenericDeploymentTool.java 2001/03/14 01:22:22 1.15
@@ -270,7 +270,7 @@
}
protected DescriptorHandler getDescriptorHandler(File srcDir) {
- return new DescriptorHandler(srcDir);
+ return new DescriptorHandler(task, srcDir);
}
public void processDescriptor(String descriptorFileName, SAXParser
saxParser) {
@@ -380,7 +380,7 @@
Project.MSG_INFO);
// Use helper method to write the jarfile
- writeJar(baseName, jarFile, ejbFiles);
+ writeJar(baseName, jarFile, ejbFiles, handler.getPublicId());
}
else {
@@ -438,7 +438,8 @@
* filenames/java.io.Files in the Hashtable stored on the instance
variable
* ejbFiles.
*/
- protected void writeJar(String baseName, File jarfile, Hashtable files)
throws BuildException{
+ protected void writeJar(String baseName, File jarfile, Hashtable files,
+ String publicId) throws BuildException{
JarOutputStream jarStream = null;
try {
1.20 +64 -18
jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java
Index: WeblogicDeploymentTool.java
===================================================================
RCS file:
/home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/WeblogicDeploymentTool.java,v
retrieving revision 1.19
retrieving revision 1.20
diff -u -r1.19 -r1.20
--- WeblogicDeploymentTool.java 2001/03/02 15:58:51 1.19
+++ WeblogicDeploymentTool.java 2001/03/14 01:22:22 1.20
@@ -71,10 +71,11 @@
= "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN";
public static final String PUBLICID_EJB20
= "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN";
-
- public static final String PUBLICID_WEBLOGIC_EJB
+ public static final String PUBLICID_WEBLOGIC_EJB510
= "-//BEA Systems, Inc.//DTD WebLogic 5.1.0 EJB//EN";
-
+ public static final String PUBLICID_WEBLOGIC_EJB600
+ = "-//BEA Systems, Inc.//DTD WebLogic 6.0.0 EJB//EN";
+
protected static final String DEFAULT_WL51_EJB11_DTD_LOCATION
= "/weblogic/ejb/deployment/xml/ejb-jar.dtd";
protected static final String DEFAULT_WL60_EJB11_DTD_LOCATION
@@ -82,12 +83,19 @@
protected static final String DEFAULT_WL60_EJB20_DTD_LOCATION
= "/weblogic/ejb20/dd/xml/ejb20-jar.dtd";
- protected static final String DEFAULT_WL_DTD_LOCATION
+ protected static final String DEFAULT_WL51_DTD_LOCATION
= "/weblogic/ejb/deployment/xml/weblogic-ejb-jar.dtd";
+ protected static final String DEFAULT_WL60_51_DTD_LOCATION
+ = "/weblogic/ejb20/dd/xml/weblogic510-ejb-jar.dtd";
+ protected static final String DEFAULT_WL60_DTD_LOCATION
+ = "/weblogic/ejb20/dd/xml/weblogic600-ejb-jar.dtd";
protected static final String WL_DD = "weblogic-ejb-jar.xml";
protected static final String WL_CMP_DD = "weblogic-cmp-rdbms-jar.xml";
+ protected static final String COMPILER_EJB11 = "weblogic.ejbc";
+ protected static final String COMPILER_EJB20 = "weblogic.ejbc20";
+
/** Instance variable that stores the suffix for the weblogic jarfile. */
private String jarSuffix = ".jar";
@@ -98,9 +106,11 @@
private String ejb11DTD;
/** Instance variable that determines whether generic ejb jars are kept.
*/
-
private boolean keepgenerated = false;
+ /** Instance variable that stores the fully qualified classname of the
weblogic EJBC compiler */
+ private String ejbcClass = null;
+
private String additionalArgs = "";
private boolean keepGeneric = false;
@@ -179,8 +189,24 @@
this.additionalArgs = args;
}
+ /**
+ * Set the classname of the ejbc compiler
+ */
+ public void setEjbcClass(String ejbcClass)
+ {
+ this.ejbcClass = ejbcClass;
+ }
/**
+ * Get the ejbc compiler class
+ */
+ public String getEjbcClass()
+ {
+ return ejbcClass;
+ }
+
+
+ /**
* Setter used to store the location of the ejb-jar DTD. This can be a
file on the system
* or a resource on the classpath.
* @param inString the string to use as the DTD location.
@@ -231,7 +257,7 @@
protected DescriptorHandler getDescriptorHandler(File srcDir) {
- DescriptorHandler handler = new DescriptorHandler(srcDir);
+ DescriptorHandler handler = new DescriptorHandler(getTask(), srcDir);
// register all the DTDs, both the ones that are known and
// any supplied by the user
handler.registerDTD(PUBLICID_EJB11, DEFAULT_WL51_EJB11_DTD_LOCATION);
@@ -239,10 +265,10 @@
handler.registerDTD(PUBLICID_EJB11, ejb11DTD);
handler.registerDTD(PUBLICID_EJB20, DEFAULT_WL60_EJB20_DTD_LOCATION);
-
for (Iterator i = getConfig().dtdLocations.iterator(); i.hasNext();)
{
EjbJar.DTDLocation dtdLocation = (EjbJar.DTDLocation)i.next();
- handler.registerDTD(dtdLocation.getPublicId(),
dtdLocation.getLocation());
+ handler.registerDTD(dtdLocation.getPublicId(),
+ dtdLocation.getLocation());
}
return handler;
@@ -250,7 +276,7 @@
protected DescriptorHandler getWeblogicDescriptorHandler(final File
srcDir) {
DescriptorHandler handler =
- new DescriptorHandler(srcDir) {
+ new DescriptorHandler(getTask(), srcDir) {
protected void processElement() {
if (currentElement.equals("type-storage")) {
// Get the filename of vendor specific descriptor
@@ -265,8 +291,11 @@
}
};
- handler.registerDTD(PUBLICID_WEBLOGIC_EJB,
- weblogicDTD == null ? DEFAULT_WL_DTD_LOCATION :
weblogicDTD);
+ handler.registerDTD(PUBLICID_WEBLOGIC_EJB510,
DEFAULT_WL51_DTD_LOCATION);
+ handler.registerDTD(PUBLICID_WEBLOGIC_EJB510,
DEFAULT_WL60_51_DTD_LOCATION);
+ handler.registerDTD(PUBLICID_WEBLOGIC_EJB600,
DEFAULT_WL60_DTD_LOCATION);
+ handler.registerDTD(PUBLICID_WEBLOGIC_EJB510, weblogicDTD);
+ handler.registerDTD(PUBLICID_WEBLOGIC_EJB600, weblogicDTD);
for (Iterator i = getConfig().dtdLocations.iterator(); i.hasNext();)
{
EjbJar.DTDLocation dtdLocation = (EjbJar.DTDLocation)i.next();
@@ -354,9 +383,11 @@
* @param destJar java.io.File representing the destination, WebLogic
* jarfile.
*/
- private void buildWeblogicJar(File sourceJar, File destJar) {
+ private void buildWeblogicJar(File sourceJar, File destJar, String
publicId) {
org.apache.tools.ant.taskdefs.Java javaTask = null;
+ String ejbcClassName = ejbcClass;
+
try {
String args = additionalArgs;
if (keepgenerated) {
@@ -371,7 +402,21 @@
javaTask = (Java) getTask().getProject().createTask("java");
javaTask.setTaskName("ejbc");
- javaTask.setClassname("weblogic.ejbc");
+ if (ejbcClassName == null) {
+ // try to determine it from publicId
+ if (PUBLICID_EJB11.equals(publicId)) {
+ ejbcClassName = COMPILER_EJB11;
+ }
+ else if (PUBLICID_EJB20.equals(publicId)) {
+ ejbcClassName = COMPILER_EJB20;
+ }
+ else {
+ log("Unrecognized publicId " + publicId + " - using EJB
1.1 compiler", Project.MSG_WARN);
+ ejbcClassName = COMPILER_EJB11;
+ }
+ }
+
+ javaTask.setClassname(ejbcClassName);
Commandline.Argument arguments = javaTask.createArg();
arguments.setLine(args);
Path classpath = wlClasspath;
@@ -388,14 +433,14 @@
}
- log("Calling weblogic.ejbc for " + sourceJar.toString(),
+ log("Calling " + ejbcClassName + " for " + sourceJar.toString(),
Project.MSG_VERBOSE);
javaTask.execute();
}
catch (Exception e) {
// Have to catch this because of the semantics of calling main()
- String msg = "Exception while calling ejbc. Details: " +
e.toString();
+ String msg = "Exception while calling " + ejbcClassName + ".
Details: " + e.toString();
throw new BuildException(msg, e);
}
}
@@ -405,14 +450,15 @@
* filenames/java.io.Files in the Hashtable stored on the instance
variable
* ejbFiles.
*/
- protected void writeJar(String baseName, File jarFile, Hashtable files)
throws BuildException {
+ protected void writeJar(String baseName, File jarFile, Hashtable files,
+ String publicId) throws BuildException {
// need to create a generic jar first.
File genericJarFile = super.getVendorOutputJarFile(baseName);
- super.writeJar(baseName, genericJarFile, files);
+ super.writeJar(baseName, genericJarFile, files, publicId);
if (alwaysRebuild || isRebuildRequired(genericJarFile, jarFile))
{
- buildWeblogicJar(genericJarFile, jarFile);
+ buildWeblogicJar(genericJarFile, jarFile, publicId);
}
if (!keepGeneric) {
log("deleting generic jar " + genericJarFile.toString(),
---------------------------------------------------------------------
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]