You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@ant.apache.org by Tim Fennell <tf...@rcn.com> on 2000/07/24 03:15:47 UTC
[PATCH] Added flat output directory support to EjbJar.java
This patch adds the ability to output all EJB jarfiles to a single directory through a new attribute 'flatdestdir'. Attribute
defaults to false (maintains current behaviour). Set it to true, and all jars will be created directly in the destination dir.
WARNING: If you use this attribute, and have multiple jars called the same thing, they will overwrite each other!
This patch has been requested by several people, and seems like a good idea. Someone feel like committing for me?
Also added comments in a couple of places they were missing, and tidied up comments in a couple of other places.
-t
---------------------------Begin Patch-----------------------------
Index: EjbJar.java
===================================================================
RCS file: /home/cvspublic/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/EjbJar.java,v
retrieving revision 1.1
diff -u -r1.1 EjbJar.java
--- EjbJar.java 2000/07/14 13:50:27 1.1
+++ EjbJar.java 2000/07/24 01:11:31
@@ -250,6 +250,12 @@
/** Stores a handle to the directory to put the Jar files in */
private File destdir = null;
+ /**
+ * Instance variable that determines whether to use a package structure
+ * of a flat directory as the destination for the jar files.
+ */
+ private boolean flatdestdir = false;
+
/** Instance variable that determines whether to generate weblogic jars. */
private boolean generateweblogic = false;
@@ -283,6 +289,14 @@
}
/**
+ * Setter used to store the value of flatdestdir.
+ * @param inValue a string, either 'true' or 'false'.
+ */
+ public void setFlatdestdir(String inValue) {
+ this.flatdestdir = Boolean.valueOf(inValue).booleanValue();
+ }
+
+ /**
* Setter used to store the suffix for the generated jar file.
* @param inString the string to use as the suffix.
*/
@@ -415,7 +429,12 @@
/**
- *
+ * Helper method invoked by execute() for each WebLogic jar to be built.
+ * Encapsulates the logic of constructing a java task for calling
+ * weblogic.ejbc and executing it.
+ * @param sourceJar java.io.File representing the source (EJB1.1) jarfile.
+ * @param destJar java.io.File representing the destination, WebLogic
+ * jarfile.
*/
public void buildWeblogicJar(File sourceJar, File destJar) {
org.apache.tools.ant.taskdefs.Java javaTask = null;
@@ -505,8 +524,8 @@
baseName = files[index].substring(0, endBaseName);
/* Parse the ejb deployment descriptor. While it may not
- * look like much, passing 'this' in the above method allows
- * the parser to call us back when it finds interesting things.
+ * look like much, we use a SAXParser and an inner class to
+ * get hold of all the classfile names for the descriptor.
*/
handler = new DescriptorHandler();
saxParser.parse(new InputSource
@@ -516,9 +535,8 @@
ejbFiles = handler.getFiles();
- /* Now that we've parsed the deployment descriptor we have the
- * bean name, so we can figure out all the .xml filenames and
- * add them to the set of files for the jar.
+ /* Now try to locate all of the deployment descriptors for the
+ * jar, and if they exist, add them to the list of files.
*/
// First the regular deployment descriptor
@@ -546,8 +564,15 @@
ejbFiles.put(EjbJar.META_DIR + EjbJar.WL_CMP_DD,
weblogicDD);
}
+
+ // Lastly create File object for the Jar files. If we are using
+ // a flat destination dir, then we need to redefine baseName!
+ if (this.flatdestdir) {
+ int startName = baseName.lastIndexOf(File.separator);
+ int endName = baseName.length();
+ baseName = baseName.substring(startName, endName);
+ }
- // Lastly for the jarfiles
jarfile = new File(this.destdir,
baseName
+ this.genericjarsuffix);