ant-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From co...@apache.org
Subject cvs commit: jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb JonasDeploymentTool.java
Date Fri, 21 Jun 2002 16:30:46 GMT
conor       2002/06/21 09:30:46

  Modified:    .        Tag: ANT_15_BRANCH WHATSNEW
               docs/manual/OptionalTasks Tag: ANT_15_BRANCH ejb.html
               src/main/org/apache/tools/ant/taskdefs/optional/ejb Tag:
                        ANT_15_BRANCH JonasDeploymentTool.java
  Log:
  Update to ejbjar to support Jonas 2.5
  
  Submitted By:	Mathieu Peltier <Mathieu.Peltier@inrialpes.fr>
  
  Revision  Changes    Path
  No                   revision
  
  
  No                   revision
  
  
  1.263.2.50 +2 -0      jakarta-ant/WHATSNEW
  
  Index: WHATSNEW
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/WHATSNEW,v
  retrieving revision 1.263.2.49
  retrieving revision 1.263.2.50
  diff -u -w -u -r1.263.2.49 -r1.263.2.50
  --- WHATSNEW	19 Jun 2002 15:46:09 -0000	1.263.2.49
  +++ WHATSNEW	21 Jun 2002 16:30:45 -0000	1.263.2.50
  @@ -69,6 +69,8 @@
     Added an outputdir attribute to allow the destination to be a
     directory into which the exploded jar is written.
   
  +* ejbjar now supports Borland Enterprise Server 5 and Jonas 2.5
  +
   Changes from Ant 1.5beta1 to Ant 1.5beta2
   =========================================
   
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.23.2.7  +122 -143  jakarta-ant/docs/manual/OptionalTasks/ejb.html
  
  Index: ejb.html
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/docs/manual/OptionalTasks/ejb.html,v
  retrieving revision 1.23.2.6
  retrieving revision 1.23.2.7
  diff -u -w -u -r1.23.2.6 -r1.23.2.7
  --- ejb.html	20 Jun 2002 16:45:00 -0000	1.23.2.6
  +++ ejb.html	21 Jun 2002 16:30:45 -0000	1.23.2.7
  @@ -49,7 +49,7 @@
     <li><a href="http://www.bea.com" target="_top">Weblogic</a>
      4.5.1 through to 7.0 EJB servers</li>
     <li><a href="http://www.objectweb.org/jonas/" target="_top">JOnAS</a>
  -   2.4 Open Source EJB server</li>
  +   2.4.x and 2.5 Open Source EJB server</li>
     <li><a href="http://www.ibm.com/websphere">IBM WebSphere</a> 4.0</li>
   </ul>
     Over time we expect further optional tasks  to support additional EJB Servers.
  @@ -67,7 +67,7 @@
    <tr><td><a href="BorlandEJBTasks.html">borland</a></td><td>Borland Application Server 4.5</td></tr>
    <tr><td><a href="#ejbjar_iplanet">iPlanet</a></td><td>iPlanet Application Server 6.0</td></tr>
    <tr><td><a href="#ejbjar_jboss">jboss</a></td><td>JBoss</td></tr>
  - <tr><td><a href="#ejbjar_jonas">jonas</a></td><td>JOnAS 2.4</td></tr>
  + <tr><td><a href="#ejbjar_jonas">jonas</a></td><td>JOnAS 2.4.x and 2.5</td></tr>
    <tr><td><a href="#ejbjar_weblogic">weblogic</a></td><td>Weblogic 5.1 to 7.0</td></tr>
    <tr><td><a href="#ejbjar_websphere">websphere</a></td><td>IBM WebSphere 4.0</td></tr>
    <tr><td><a href="#wlrun">wlrun</a></td><td colspan="2">Weblogic 4.5.1 to 7.0</td></tr>
  @@ -533,7 +533,7 @@
     <li>Weblogic 5.1/6.0 session/entity beans using the weblogic.ejbc tool</li>
     <li>IBM WebSphere 4.0</li>
     <li>TOPLink for WebLogic 2.5.1-enabled entity beans</li>
  -  <li><a href="http://www.objectweb.org/jonas/">JOnAS</a> 2.4 Open Source EJB server</li>
  +  <li><a href="http://www.objectweb.org/jonas/">JOnAS</a> 2.4.x and 2.5 Open Source EJB server</li>
   </ul>
   
   
  @@ -1513,35 +1513,40 @@
               &lt;dtd publicId="-//Sun Microsystems, Inc.//DTD iAS Enterprise JavaBeans 1.0//EN"
                    location="${ias.home}/APPS/IASEjb_jar_1_0.dtd"/>
       &lt;/ejbjar></pre>
  -<h3><a name="ejbjar_jonas">
  -<h3>JOnAS (Java Open Application Server) element</h3>
  -</a>
  -</h3>
  -<p>The &lt;jonas&gt; nested element is used to build JOnAS-specific stubs
  -and skeletons thanks to the GenIC specific tool, and construct a JAR file
  -which may be deployed to the JOnAS Application Server. The build process
  -will always determine if the EJB stubs/skeletons and the EJB-JAR file are
  -up to date, and it will do the minimum amount of work required. </p>
   
  -<p>Like the WebLogic element, a naming convention for the EJB descriptors
  - is most commonly used to specify the name for the completed JAR file.  For
  - example, if the EJB descriptor ejb/Account.xml (or ejb/Account-ejb-jar.xml )
  - is found in the descriptor directory, the jonas element will search for a
  - JOnAS-specific EJB descriptor file named ejb/Account-jonas-ejb-jar.xml
  - (if it isn't found, the task will fail) and a JAR file named ejb/Account.jar
  - will be written in the destination directory. Note that when the EJB
  - descriptors are added to the JAR file, they are automatically  renamed
  - META-INF/ejb-jar.xml and META-INF/jonas-ejb-jar.xml.<br><br>
  - But if you prefer, you can use JOnAS convention naming and keep your
  - XML file name : ejb/Account.xml and ejb/jonas-Account.xml, a JAR file named
  - ejb/Account.jar will be written in the destination directory.
  +<h3><a name="ejbjar_jonas">JOnAS (Java Open Application Server) element</a></h3>
   
  - </p>
  -<p>Of course, this naming behaviour can be modified by specifying attributes
  - in the ejbjar task (for example, basejarname, basenameterminator, and flatdestdir)
  +<p>The &lt;jonas&gt; nested element is used to build JOnAS-specific stubs and
  +skeletons thanks to the <code>GenIC</code> specific tool, and construct a JAR
  +file which may be deployed to the JOnAS Application Server. The build process
  +will always determine if the EJB stubs/skeletons and the EJB-JAR file are up to
  +date, and it will do the minimum amount of work required.</p>
  +
  +<p>Like the WebLogic element, a naming convention for the EJB descriptors is
  +most commonly used to specify the name for the completed JAR file. For example,
  +if the EJB descriptor <code>ejb/Account-ejb-jar.xml</code> is found in the
  +descriptor directory, the &lt;jonas&gt; element will search for a JOnAS-specific
  +EJB descriptor file named <code>ejb/Account-jonas-ejb-jar.xml</code> and a JAR
  +file named <code>ejb/Account.jar</code> will be written in the destination
  +directory. But the &lt;jonas&gt; element can also use the JOnAS naming
  +convention. With the same example as below, the EJB descriptor can also be named
  +<code>ejb/Account.xml</code> (no base name terminator here) in the descriptor
  +directory. Then the &lt;jonas&gt; element will search for a JOnAS-specific EJB
  +descriptor file called <code>ejb/jonas-Account.xml</code>. This convention do
  +not follow strictly the ejb-jar naming convention recommendation but is
  +supported for backward compatibility with previous version of JOnAS.</p>
  +
  +<p>Note that when the EJB descriptors are added to the JAR file, they are
  +automatically renamed <code>META-INF/ejb-jar.xml</code> and
  +<code>META-INF/jonas-ejb-jar.xml</code>.</p>
  +
  +<p>Of course, this naming behavior can be modified by specifying attributes in
  +the ejbjar task (for example, basejarname, basenameterminator, and flatdestdir)
    as well as the iplanet element (for example, suffix).  Refer to the appropriate
    documentation for more details.</p>
  +
   <h3> Parameters:</h3>
  +
   <table border="1" cellspacing="0" cellpadding="2">
     <tbody>
       <tr>
  @@ -1553,147 +1558,120 @@
         <td valign="Top">destdir</td>
         <td valign="Top">The base directory into which the generated JAR files
    will be written. Each JAR file is written in directories which correspond
  - to their location within the "descriptordir" namespace.</td>
  +      to their location within the "<code>descriptordir</code>" namespace.</td>
         <td align="Center" valign="Top">Yes</td>
       </tr>
       <tr>
  -      <td valign="Top">jonasroot<br>
  -      </td>
  -      <td valign="Top">The root directory for JOnAS. <br>
  -      </td>
  -      <td valign="Top">
  -      <div align="Center">Yes<br>
  -      </div>
  -      </td>
  +      <td valign="Top">jonasroot</td>
  +      <td valign="Top">The root directory for JOnAS.</td>
  +      <td valign="Top" align="Center">Yes</td>
       </tr>
       <tr>
  -      <td valign="Top">workdir<br>
  -      </td>
  -      <td valign="Top">The work directory to use. Specify where to place
  -the generated files, before to add to the jar. The directory should be empty.
  -If omitted, it defaults to a temporary directory.<br>
  -      </td>
  -      <td valign="Top">
  -      <div align="Center">No<br>
  -      </div>
  -      </td>
  +      <td valign="Top">classpath</td>
  +      <td valign="Top">The classpath used when generating EJB stubs and
  +      skeletons. If omitted, the classpath specified in the "ejbjar" parent
  +      task will be used. If specified, the classpath elements will be prepended
  +      to the classpath specified in the parent "ejbjar" task (see also the ORB
  +      attribute documentation below). Note that nested "classpath" elements may
  +      also be used.</td>
  +      <td valign="Top" align="Center">No</td>
       </tr>
       <tr>
  -      <td valign="Top">cleanworkdir<br>
  -      </td>
  -      <td valign="Top">Clean the working directory after work.
  -         If omitted, it defaults to false, but your jar will contain
  -         wrong files if you don't clean the workdir yourself.<br>
  -         Temporary working directory is always cleaned.<br>
  -      </td>
  -      <td valign="Top">
  -      <div align="Center">No<br>
  -      </div>
  -      </td>
  +      <td valign="Top">keepgenerated</td>
  +      <td valign="Top"><code>true</code> if the intermediate Java
  +      source files generated by GenIC must be deleted or not. If
  +      omitted, it defaults to <code>false</code>.</td>
  +      <td align="Center" valign="Top">No</td>
       </tr>
       <tr>
  -      <td valign="Top">classpath</td>
  -      <td valign="Top">The classpath used when generating EJB stubs and skeletons.
  -      If omitted, the classpath specified in the "ejbjar" parent task will
  -      be used. If specified, the classpath elements will be prepended to the
  -      classpath specified in the parent "ejbjar" task (see also the ORB
  -      attribute documentation below). Note that nested "classpath" elements
  -      may also be used.</td>
  +      <td valign="Top">nocompil</td>
  +      <td valign="Top"><code>true</code> if the generated source files
  +      must not be compiled via the java and rmi compilers. If omitted,
  +      it defaults to <code>false</code>.</td>
         <td align="Center" valign="Top">No</td>
       </tr>
       <tr>
  -      <td valign="Top">keepgenerated</td>
  -      <td valign="Top">Indicates whether or not the Java source files which
  - are generated by GenIC will be saved or automatically deleted. If "yes", the
  -source files will be retained.  If omitted, it defaults to "no". </td>
  +      <td valign="Top">novalidation</td>
  +      <td valign="Top"><code>true</code> if the XML deployment descriptors must
  +      be parsed without validation. If omitted, it defaults to <code>false</code>.</td>
         <td align="Center" valign="Top">No</td>
       </tr>
     <tr>
  -    <td valign="top">keepgeneric</td>
  -    <td valign="top">This controls whether the generic file used as input to
  -                     GenIC is retained.</td>
  -    <td valign="top" align="center">No, defaults to false</td>
  +      <td valign="Top">javac</td>
  +      <td valign="Top">Java compiler to use. If omitted, it defaults
  +      to the value of <code>build.compiler</code> property.</td>
  +      <td align="Center" valign="Top">No</td>
  +    </tr>
  +    <tr>
  +      <td valign="Top">javacopts</td>
  +      <td valign="Top">Options to pass to the java compiler.</td>
  +      <td align="Center" valign="Top">No</td>
  +    </tr>
  +    <tr>
  +      <td valign="Top">rmicopts</td>
  +      <td valign="Top">Options to pass to the rmi compiler.</td>
  +      <td align="Center" valign="Top">No</td>
     </tr>
     <tr>
       <td valign="top">secpropag</td>
  -    <td valign="top">Modify the RMI Skel. and Stub. to implement the
  -                     implicit propagation of the security context (note that
  -                     the transactional context is always provided).
  -                     </td>
  -    <td valign="top" align="center">No, defaults to false.</td>
  +      <td valign="top"><code>true</code> if the RMI Skel. and
  +      Stub. must be modified to implement the implicit propagation of
  +      the security context (the transactional context is always
  +      provided). If omitted, it defaults to <code>false</code>.</td>
  +      <td valign="top" align="center">No</td>
     </tr>
       <tr>
  -      <td valign="Top">orb<br>
  -      </td>
  -      <td>Choose your ORB : RMI, JEREMIE, DAVID, ... If omitted, it defaults
  -to the one present in classpath. If specified, the corresponding JOnAS JAR is
  -automatically added to the classpath. <br>
  -      </td>
  +      <td valign="Top">verbose</td>
  +      <td valign="Top">Indicates whether or not to use -verbose switch. If
  +      omitted, it defaults to <code>false</code>.</td>
  +      <td align="Center" valign="Top">No</td>
  +    </tr>
  +      <td valign="Top">additionalargs</td>
  +      <td valign="Top">Add additional args to GenIC.</td>
         <td align="Center" valign="Top">No</td>
       </tr>
       <tr>
  -      <td valign="Top">noGENIC<br>
  -      </td>
  -      <td valign="Top">If this attribute is set to true, JOnAS's GenIC will
  - not be run on the EJB jar. Use this if you prefer to
  - run GenIC at deployment time.</td>
  -      <td>
  -      <div align="Center">No</div>
  -      </td>
  +      <td valign="Top">keepgeneric</td>
  +      <td valign="Top"><code>true</code> if the generic JAR file used as input
  +      to GenIC must be retained. If omitted, it defaults to <code>false</code>.</td>
  +      <td align="Center" valign="Top">No</td>
       </tr>
       <tr>
         <td valign="Top">suffix</td>
  -      <td>String value appended to the JAR filename when creating each JAR.
  -  If omitted, it defaults to ".jar". </td>
  +      <td>String value appended to the JAR filename when creating each JAR.  If
  +      omitted, it defaults to ".jar". </td>
         <td align="Center" valign="Top">No</td>
       </tr>
       <tr>
  -      <td valign="Top">verbose<br>
  -      </td>
  -      <td valign="Top">Indicates whether or not to use -verbose switch. If
  -omitted, it defaults to "no".</td>
  -      <td valign="Top">
  -      <div align="Center">No<br>
  -      </div>
  -      </td>
  +      <td valign="Top">orb</td>
  +      <td>Choose your ORB : RMI, JEREMIE, DAVID. If omitted, it defaults to the
  +      one present in classpath. If specified, the corresponding JOnAS JAR is
  +      automatically added to the classpath.</td>
  +      <td align="Center" valign="Top">No</td>
       </tr>
       <tr>
  -      <td valign="Top">compiler<br>
  -      </td>
  -      <td valign="Top">This allows for the selection of a different compiler
  -                      to be used for the compilation of the generated Java
  -                      files. This could be set, for example, to Jikes to
  -                     compile with the Jikes compiler. If this is not set
  -                    and the <code>build.compiler</code> property is set
  -                    to jikes, the Jikes compiler will be used. If this
  -                   is not desired, the value "<code>default</code>"
  -                 may be given to use the default compiler<br>
  -      </td>
  -      <td valign="Top">
  -      <div align="Center">No<br>
  -      </div>
  -      </td>
  +      <td valign="Top">nogenic</td>
  +      <td valign="Top">If this attribute is set to <code>true</code>,
  +      JOnAS's GenIC will not be run on the EJB JAR. Use this if you
  +      prefer to run GenIC at deployment time. If omitted, it defaults
  +      to <code>false</code>.</td>
  +      <td align="Center" valign="Top">No</td>
       </tr>
       <tr>
  -      <td valign="Top">args<br>
  -      </td>
  -      <td valign="Top">Add additional args to GenIC.<br>
  -      </td>
  -      <td valign="Top">
  -      <div align="Center">No<br>
  -      </div>
  -      </td>
  -    </tr>
     </tbody>
   </table>
  +
   <p>As noted above, the jonas element supports additional &lt;classpath&gt;
    nested elements. </p>
  +
   <h3>Examples</h3>
  -<p>This example shows ejbjar being used to generate deployment jars using
  - a  JOnAS EJB container. This example requires the naming standard to be
  - used for  the deployment descriptors. Using this format will create a ejb
  - jar file for each variation of &nbsp;'*-jar.xml' that is found in the
  -deployment  descriptor  directory.&nbsp;</p>
  +
  +<p>This example shows ejbjar being used to generate deployment jars using a
  +JOnAS EJB container. This example requires the naming standard to be used for
  +the deployment descriptors. Using this format will create a EJB JAR file for
  +each variation of &nbsp;'*-jar.xml' that is found in the deployment descriptor
  +directory.&nbsp;</p>
  +
   <pre>
         &lt;ejbjar srcdir="${build.classes}"
                 descriptordir="${descriptor.dir}"&gt;
  @@ -1707,11 +1685,12 @@
           &lt;/support&gt;
         &lt;/ejbjar&gt;
   </pre>
  -<p></p>
  +
   <p>This example shows ejbjar being used to generate a single deployment jar
     using a JOnAS EJB container. This example does require the deployment
  -  descriptors to use the naming standard. This will create only one ejb jar
  - file - 'TheEJBJar.jar'.</p>
  +descriptors to use the naming standard. This will create only one ejb jar file -
  +'TheEJBJar.jar'.</p>
  +
   <pre>
         &lt;ejbjar srcdir="${build.classes}"
                 descriptordir="${descriptor.dir}"
  
  
  
  No                   revision
  
  
  No                   revision
  
  
  1.3.2.1   +838 -645  jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java
  
  Index: JonasDeploymentTool.java
  ===================================================================
  RCS file: /home/cvs/jakarta-ant/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java,v
  retrieving revision 1.3
  retrieving revision 1.3.2.1
  diff -u -w -u -r1.3 -r1.3.2.1
  --- JonasDeploymentTool.java	14 Apr 2002 11:16:18 -0000	1.3
  +++ JonasDeploymentTool.java	21 Jun 2002 16:30:46 -0000	1.3.2.1
  @@ -57,589 +57,782 @@
   import org.apache.tools.ant.Project;
   import org.apache.tools.ant.types.Path;
   import org.apache.tools.ant.taskdefs.Java;
  -import org.apache.tools.ant.util.FileUtils;
  +import org.apache.tools.ant.AntClassLoader;
  +import org.apache.tools.ant.taskdefs.Java;
   
   import java.io.File;
   import java.io.IOException;
   import java.util.Hashtable;
  +import java.util.Enumeration;
  +
  +import javax.xml.parsers.SAXParser;
   
   /**
    * The deployment tool to add the jonas specific deployment descriptors to the
  - * ejb jar file. JONAS only requires one additional file jonas-ejb-jar.xml.
  + * ejb JAR file. JONAS only requires one additional file jonas-ejb-jar.xml.
    *
  - * @author <a href="cmorvan@ingenosya.com">Cyrille Morvan</a> , <a
  - *      href="http://www.ingenosya.com">Ingenosya France</a>
  + * @author <a href="mailto:cmorvan@ingenosya.com">Cyrille Morvan</a> , <a
  + * href="http://www.ingenosya.com">Ingenosya France</a>, <a
  + * href="mailto:mathieu.peltier@inrialpes.fr">Mathieu Peltier</a>
    * @version 1.0
    * @see EjbJar#createJonas
    */
   public class JonasDeploymentTool extends GenericDeploymentTool {
   
  +    /** Public Id of the standard deployment descriptor DTD. */
  +    protected static final String EJB_JAR_1_1_PUBLIC_ID = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN";
  +    protected static final String EJB_JAR_2_0_PUBLIC_ID = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN";
  +
  +    /** Public Id of the JOnAS-specific deployment descriptor DTD. */
  +    protected static final String JONAS_EJB_JAR_2_4_PUBLIC_ID = "-//ObjectWeb//DTD JOnAS 2.4//EN";
  +    protected static final String JONAS_EJB_JAR_2_5_PUBLIC_ID = "-//ObjectWeb//DTD JOnAS 2.5//EN";
  +
  +    /** RMI ORB. */
  +    protected static final String RMI_ORB = "RMI";
  +
  +    /** JEREMIE ORB. */
  +    protected static final String JEREMIE_ORB = "JEREMIE";
  +
  +    /** DAVID ORB. */
  +    protected static final String DAVID_ORB = "DAVID";
  +
  +    /**
  +     * Name of the standard deployment descriptor DTD (these files are stored in
  +     * the ${JONAS_ROOT}/xml directory).
  +     */
  +    protected static final String EJB_JAR_1_1_DTD = "ejb-jar_1_1.dtd";
  +    protected static final String EJB_JAR_2_0_DTD = "ejb-jar_2_0.dtd";
  +
  +    /**
  +     * Name of the JOnAS-specific deployment descriptor DTD (these files are
  +     * stored in the ${JONAS_ROOT}/xml directory).
  +     */
  +    protected static final String JONAS_EJB_JAR_2_4_DTD = "jonas-ejb-jar_2_4.dtd";
  +    protected static final String JONAS_EJB_JAR_2_5_DTD = "jonas-ejb-jar_2_5.dtd";
  +
  +    /** Default JOnAS deployment descriptor name. */
       protected static final String JONAS_DD = "jonas-ejb-jar.xml";
   
  +    /** GenIC class name (JOnAS 2.5) */
       protected static final String GENIC_CLASS =
  +	"org.objectweb.jonas_ejb.genic.GenIC";
  +
  +    /** Old GenIC class name (JOnAS 2.4.x). */
  +    protected static final String OLD_GENIC_CLASS_1 =
           "org.objectweb.jonas_ejb.tools.GenWholeIC";
   
  -    protected static final String OLD_GENIC_CLASS =
  +    /** Old GenIC class name. */
  +    protected static final String OLD_GENIC_CLASS_2 =
           "org.objectweb.jonas_ejb.tools.GenIC";
   
  -    protected static final String DEFAULT_ORB = "RMI";
  -
  -    /** Instance variable that stores the suffix for the jonas jarfile. */
  -    private String jarSuffix = ".jar";
  +    /**
  +     * Filename of the standard EJB descriptor (which is passed to this class
  +     * from the parent "ejbjar" task). This file is relative to the directory
  +     * specified by the "srcdir" attribute in the ejbjar task.
  +     */
  +    private String descriptorName;
   
       /**
  -     * Instance variable that stores the fully qualified classname of the
  -     * JOnAS GenIC compiler.
  +     * Filename of the JOnAS-specific EJB descriptor (which is passed to this
  +     * class from the parent "ejbjar" task). This file is relative to the
  +     * directory specified by the "srcdir" attribute in the ejbjar task.
        */
  -    private String genicClass;
  +    private String jonasDescriptorName;
   
  -    private String additionalArgs = "";
  +    /* ------------- */
  +    /* GenIC options */
  +    /* ------------- */
   
       /**
  -     * Instance variable that determines do not delete intermediate generated
  -     * source files
  +     * Temporary output directory used by GenIC.
  +     */
  +    private File outputdir;
  +
  +    /**
  +     * <code>true</code> if the intermediate Java source files generated by
  +     * GenIC must be deleted or not. The default is <code>false</code>
        */
       private boolean keepgenerated = false;
   
  -    /** as websphere and WebLogic taskes */
  -    private boolean keepGeneric = false;
  +    /**
  +     * <code>true</code> if the generated source files must not be compiled via
  +     * the java and rmi compilers. The default is <code>false</code>.
  +     */
  +    private boolean nocompil = false;
   
  -    /** Instance variable that determines the JOnAS Root directory */
  -    private File jonasroot;
  +    /**
  +     * <code>true</code> if the XML deployment descriptors must be parsed
  +     * without validation. The default is <code>false</code>.
  +     */
  +    private boolean novalidation = false;
  +
  +    /**
  +     * Java compiler to use. The default is the value of
  +     * <code>build.compiler</code> property.
  +     */
  +    private String javac;
  +
  +    /** Options to pass to the java compiler. */
  +    private String javacopts;
   
  -    /** Instance variable that determines if we could -secpropag */
  +    /** Options to pass to the rmi compiler. */
  +    private String rmicopts;
  +
  +    /**
  +     * <code>true</code> if the RMI Skel. and Stub. must be modified to
  +     * implement the implicit propagation of the security context (the
  +     * transactional context is always provided). The default is
  +     * <code>false</code>.
  +     */
       private boolean secpropag = false;
   
  -    /** Instance variable that determines the ouput directory */
  -    private File ouputdirectory;
  +    /**
  +     * <code>true</code> if the GenIC call must be verbose. The default
  +     * is <code>false</code>. 
  +     */
  +    private boolean verbose = false;
   
  -    /** Instance variable that determines the path to the compiler to use */
  -    private String compiler;
  +    /** Additional args to send to GenIC. */
  +    private String additionalargs;
   
  -    /** Instance variable that determines if GenIC is verbose */
  -    private boolean verbose;
  +    /* ------------- */
  +    /* other options */
  +    /* ------------- */
   
  -    /** Instance variable that determines the ORB to use (RMI, JEREMIE, DAVID) */
  -    private String orb;
  +    /** JOnAS root directory. */
  +    private File jonasroot;
   
  -    /** clean the working directory after work * */
  -    private boolean cleanWorkDir = false;
  +    /**
  +     * <code>true</code> if the generic JAR file used as input to GenIC must be
  +     * retained. The default is <code>false</code>.
  +     */    
  +    private boolean keepgeneric = false;
   
  -    private boolean noGENIC = false;
  +    /** Stores the suffix for the JOnAS JAR file. The default is '.jar'. */
  +    private String suffix = ".jar";
   
  +    /**
  +     *  ORB to use (RMI, JEREMIE or DAVID). If omitted, it defaults to the one
  +     *  present in classpath. If specified, the corresponding JOnAS JAR is
  +     *  automatically added to the classpath.
  +     */
  +    private String orb;
   
  -    /** set the name of the GenIC compiler class.  */
  -    public void setGenicClass(final String inGenicClass) {
  -        genicClass = inGenicClass;
  -    }
  +    /** <code>true</code> if GenIC must not be run on the EJB JAR. The default is <code>false</code>. */    
  +    private boolean nogenic = false;
   
  +    /* -------------------- */
  +    /* GenIC options setter */
  +    /* -------------------- */
   
       /**
  -     * Set the ORB to construct classpath.
  +     * Set the {@link #keepgenerated} flag.
        *
  -     * @param inValue RMI, JEREMIE, DAVID,...
  +     * @param aBoolean <code>true</code> if the flag must be set.
        */
  -    public void setOrb(final String inValue) {
  -        orb = inValue;
  +    public void setKeepgenerated(boolean aBoolean) {
  +        keepgenerated = aBoolean;
       }
   
  -
  -    /** The compiler (switch <code>-javac</code>) to use.  */
  -    public void setCompiler(final String inCompiler) {
  -        compiler = inCompiler;
  +    /**
  +     * Set the {@link #additionalargs}.
  +     *
  +     * @param aString additional args.
  +     */
  +    public void setAdditionalargs(String aString) {
  +        additionalargs = aString;
       }
   
  -
       /**
  -     * Setter used to store the value of keepGeneric
  +     * Set the {@link #nocompil} flag.
        *
  -     * @param inValue a string, either 'true' or 'false'.
  +     * @param aBoolean <code>true</code> if the flag must be set.
        */
  -    public void setKeepgeneric(boolean inValue) {
  -        this.keepGeneric = inValue;
  +    public void setNocompil(boolean aBoolean) {
  +        nocompil = aBoolean;
       }
   
  -
       /**
  -     * GenIC verbose or not
  +     * Set the {@link #novalidation} flag.
        *
  -     * @param inValue either 'true' or 'false'
  +     * @param aBoolean <code>true</code> if the flag must be set.
        */
  -    public void setVerbose(final boolean inValue) {
  -        verbose = inValue;
  +    public void setNovalidation(boolean aBoolean) {
  +        novalidation = aBoolean;
       }
   
  -
       /**
  -     * GenIC run or not.
  +     * Set the java compiler {@link #javac} to use.
        *
  -     * @param inValue run or not
  +     * @param aString the java compiler.
        */
  -    public void setNoGENIC(final boolean inValue) {
  -        noGENIC = inValue;
  +    public void setJavac(String aString) {
  +        javac = aString;
       }
   
  -
       /**
  -     * Sets whether -keepgenerated is passed to GenIC (that is, the .java
  -     * source files are kept).
  +     * Set the options to pass to the java compiler.
        *
  -     * @param inValue either 'true' or 'false'
  +     * @param aString the options.
        */
  -    public void setKeepgenerated(final boolean inValue) {
  -        keepgenerated = inValue;
  +    public void setJavacopts(String aString) {
  +        javacopts = aString;
       }
   
  -
       /**
  -     * set the jonas root directory (-Dinstall.root=).
  +     * Set the options to pass to the rmi compiler.
        *
  -     * @throws BuildException if the file doesn't exist.
  +     * @param aString the options.
        */
  -    public void setJonasroot(final File inValue) {
  -        jonasroot = inValue;
  +    public void setRmicopts(String aString) {
  +        rmicopts = aString;
       }
   
  -
       /**
  -     * Modify the RMI Skeleton and Stub to implement the implicit propagation
  -     * of the transactionnal context and security context. For JOnAS 2.4 and
  -     * next.
  +     * Set the {@link #secpropag} flag.
  +     *
  +     * @param aBoolean <code>true</code> if the flag must be set.
        */
  -    public void setSecpropag(final boolean inValue) {
  -        secpropag = inValue;
  +    public void setSecpropag(boolean aBoolean) {
  +        secpropag = aBoolean;
       }
   
  -
       /**
  -     * set the output directory (-d ...). <br>
  -     * It's the GenIC working directory. It's not the DestDir, which is the
  -     * 'jar' destination directory.
  +     * Set the {@link #verbose} flag.
        *
  -     * @param inValue a file
  +     * @param aBoolean <code>true</code> if the flag must be set.
        */
  -    public void setOuputdir(final File inValue) {
  -        ouputdirectory = inValue;
  +    public void setVerbose(boolean aBoolean) {
  +        verbose = aBoolean;
       }
   
  +    /* -------------------- */
  +    /* other options setter */
  +    /* -------------------- */
   
       /**
  -     * set the output directory (-d ...). Same as setOuputdir(). <br>
  -     * But do not override setDestDir()
  +     * Set the JOnAS root directory.
  +     * 
  +     * @param aFile the JOnAS root directory.
        */
  -    public void setWorkdir(final File inValue) {
  -        setOuputdir(inValue);
  +    public void setJonasroot(File aFile) {
  +        jonasroot = aFile;
       }
   
  +    /**
  +     * Set the {@link #keepgeneric} flag.
  +     *
  +     * @param aBoolean <code>true</code> if the flag must be set.
  +     */
  +    public void setKeepgeneric(boolean aBoolean) {
  +        keepgeneric = aBoolean;
  +    }
   
       /**
  -     * Clean the specified Work dir after work.
  +     * Set the {@link #jarsuffix}.
        *
  -     * @param inValue true : clean ; false : not clean
  +     * @param aString the string to use as the suffix.
        */
  -    public void setCleanworkdir(final boolean inValue) {
  -        cleanWorkDir = inValue;
  +    public void setJarsuffix(String aString) {
  +        suffix = aString;
       }
   
  +    /**
  +     * Set the {@link #orb} to construct classpath.
  +     *
  +     * @param aString 'RMI', 'JEREMIE', or 'DAVID'.
  +     */
  +    public void setOrb(String aString) {
  +        orb = aString;
  +    }
   
       /**
  -     * Setter used to store the suffix for the generated JOnAS jar file.
  +     * Set the {@link #nogenic} flag.
        *
  -     * @param inString the string to use as the suffix.
  +     * @param aBoolean <code>true</code> if the flag must be set.
        */
  -    public void setSuffix(String inString) {
  -        this.jarSuffix = inString;
  +    public void setNogenic(boolean aBoolean) {
  +        nogenic = aBoolean;
  +    }
  +
  +    /* ------------- */
  +    /* other methods */
  +    /* ------------- */
  +
  +    public void processDescriptor(String aDescriptorName, SAXParser saxParser) {
  +	
  +        descriptorName = aDescriptorName;
  + 
  +        log("JOnAS Deployment Tool processing: " + descriptorName,
  +            Project.MSG_VERBOSE);
  +
  +        super.processDescriptor(descriptorName, saxParser);
  +
  +	if ( outputdir != null ) {
  +	    // the method deleteOnExit() do not work because the directory is not empty	     
  +	    log("Deleting temp output directory '" + outputdir + "'.", Project.MSG_VERBOSE);
  +	    deleteAllFiles(outputdir);
  +	}
       }
   
  +    protected void writeJar(String baseName, File jarfile, Hashtable ejbFiles, String publicId) 
  +	throws BuildException {
  +
  +	// create the generic jar first
  +	File genericJarFile = super.getVendorOutputJarFile(baseName);	
  +	super.writeJar(baseName, genericJarFile, ejbFiles, publicId);
  +	     
  +	// GenIC call on generic jar
  +	addGenICGeneratedFiles(genericJarFile, ejbFiles);
   
  -    /** sets some additional args to send to GenIC.  */
  -    public void setArgs(final String inArgs) {
  -        additionalArgs = inArgs;
  +	// create the real jar
  +	super.writeJar(baseName, getVendorOutputJarFile(baseName), ejbFiles, publicId);
  +
  +	if ( !keepgeneric ) {
  +	    log("Deleting generic JAR " + genericJarFile.toString(), Project.MSG_VERBOSE);
  +	    genericJarFile.delete();	     
  +	}
       }
   
  +    protected void addVendorFiles(Hashtable ejbFiles, String ddPrefix) {
   
  -    /**
  -     * Add any vendor specific files which should be included in the EJB Jar.
  -     *
  -     * @param aDdPrefix MyDirectories/MyEjb- or MyDirectories/
  -     */
  -    protected void addVendorFiles(final Hashtable someEjbFiles,
  -                                        final String aDdPrefix) {
  -        // Use Ant Naming convention
  -        File aJonasDD
  -             = new File(getConfig().descriptorDir, aDdPrefix + JONAS_DD);
  +	// JOnAS-specific descriptor deployment
  +	jonasDescriptorName = getJonasDescriptorName();
  +        File jonasDD = new File(getConfig().descriptorDir, jonasDescriptorName);
   
  -        if (aJonasDD.exists()) {
  -            someEjbFiles.put(META_DIR + JONAS_DD, aJonasDD);
  +        if ( jonasDD.exists() ) {
  +            ejbFiles.put(META_DIR + JONAS_DD, jonasDD);
           } else {
  -            // try with JOnAS Naming convention
  -            if (!addJonasVendorFiles(someEjbFiles, aDdPrefix)) {
  -                log("Unable to locate JOnAS deployment descriptor. It was "
  -                     + "expected to be in " + aJonasDD.getPath()
  -                     + ". Alternatively, please use JOnAS naming convention.",
  -                    Project.MSG_WARN);
  -            }
  +            log("Unable to locate the JOnAS deployment descriptor. It was expected to be in: "
  +                + jonasDD.getPath() + ".", Project.MSG_WARN);
           }
       }
   
  +    protected File getVendorOutputJarFile(String baseName) {
  +        return new File(getDestDir(), baseName + suffix);
  +    }
   
       /**
  -     * try to add JOnAS specific file, using JOnAS naming convention. For
  -     * example : jonas-Account.xml or jonas-ejb-jar.xml
  +     * Determines the name of the JOnAS-specific EJB descriptor using the
  +     * specified standard EJB descriptor name. In general, the standard
  +     * descriptor will be named "[basename]-ejb-jar.xml", and this method will
  +     * return "[basename]-jonas-ejb-jar.xml" or "jonas-[basename].xml"
        *
  -     * @param aDdPrefix MyDirectories/MyEjb- or MyDirectories/
  -     * @return true if Ok
  +     * @return The name of the JOnAS-specific EJB descriptor file.
        */
  -    private boolean addJonasVendorFiles(final Hashtable someEjbFiles,
  -                                              final String aDdPrefix) {
  -        // replace \ by /, remove the last letter ( a dash - )
  -        final String aCanonicalDD
  -             = aDdPrefix.replace('\\', '/').substring(0, aDdPrefix.length() - 1);
  -        final int index = aCanonicalDD.lastIndexOf('/') + 1;
  -        String anEjbJarName = aCanonicalDD.substring(index);
  +    private String getJonasDescriptorName() {
  +
  +        // descriptorName = <path><basename><basenameterminator><remainder>
  +        // examples = /org/objectweb/fooAppli/foo/Foo-ejb-jar.xml
  +        // examples = /org/objectweb/fooAppli/foo/Foo.xml (JOnAS convention)
   
  -        if ("ejb".equals(anEjbJarName)) {
  -            anEjbJarName = "ejb-jar";
  +        String jonasDescriptorName; // JOnAS-specific DD
  +        boolean jonasConvention = false; // true if the JOnAS convention is used for the DD
  +        String path;            // Directory path of the EJB descriptor
  +        String fileName;        // EJB descriptor file name
  +        String baseName;        // Filename appearing before name terminator
  +        String remainder;       // Filename appearing after the name terminator
  + 
  +        int startOfFileName = descriptorName.lastIndexOf(File.separatorChar);
  +        if ( startOfFileName != -1 ) {
  +            // extract path info
  +            path = descriptorName.substring(0, startOfFileName+1);
  +            fileName = descriptorName.substring(startOfFileName+1);
  +        } else {
  +            // descriptorName is just a file without path
  +            path = "";
  +            fileName = descriptorName;
           }
  -        final String aNewDdPrefix =
  -            aDdPrefix.substring(0, index) + "jonas-" + anEjbJarName + ".xml";
  -        File aConventionNamingJonasDD
  -             = new File(getConfig().descriptorDir, aNewDdPrefix);
   
  -        log("look for jonas specific file using jonas naming convention "
  -             + aConventionNamingJonasDD,
  -            Project.MSG_VERBOSE);
  +        if ( fileName.startsWith(EJB_DD) )
  +            return path + JONAS_DD;
  +
  +        int endOfBaseName = descriptorName.indexOf(getConfig().baseNameTerminator, startOfFileName);
  + 
  +        /*
  +         * Check for the odd case where the terminator and/or filename
  +         * extension aren't found.  These will ensure "jonas-" appears at the
  +         * end of the name and before the '.' (if present).
  +         */
  +        if ( endOfBaseName < 0 ) { 
  +            // baseNameTerminator not found: the descriptor use the
  +            // JOnAS naming convention, ie [Foo.xml,jonas-Foo.xml] and
  +            // not [Foo<baseNameTerminator>-ejb-jar.xml,
  +            // Foo<baseNameTerminator>-jonas-ejb-jar.xml].
  +            endOfBaseName = descriptorName.lastIndexOf('.') - 1;
  +            if (endOfBaseName < 0) {
  +                // no . found
  +                endOfBaseName = descriptorName.length() - 1;
  +            }
   
  -        if (aConventionNamingJonasDD.exists()) {
  -            someEjbFiles.put(META_DIR + JONAS_DD, aConventionNamingJonasDD);
  -            return true;
  +            jonasConvention = true;
  +        }
  +
  +        baseName = descriptorName.substring(startOfFileName + 1, endOfBaseName + 1);
  +        remainder = descriptorName.substring(endOfBaseName + 1);
  + 
  +        if ( jonasConvention ) {
  +            jonasDescriptorName = path + "jonas-" + baseName + ".xml";
           } else {
  -            return false;
  +            jonasDescriptorName = path + baseName + "jonas-" + remainder;
           }
  + 
  +        log("Standard EJB descriptor name: " + descriptorName, Project.MSG_VERBOSE);
  +        log("JOnAS-specific descriptor name: " + jonasDescriptorName, Project.MSG_VERBOSE);
  + 
  +        return jonasDescriptorName;
       }
   
  -    // include javadoc
  -    // Determine the JAR filename (without filename extension)
  -    protected String getJarBaseName(String aDescriptorFileName) {
  -        String aBaseName = null;
  -        EjbJar.Config aConfig = super.getConfig();
  +    protected String getJarBaseName(String descriptorFileName) {
  +
  +        String baseName = null;
  +
  +        if ( getConfig().namingScheme.getValue().equals(EjbJar.NamingScheme.DESCRIPTOR) ) {
   
  -        if (aConfig.namingScheme.getValue().equals(EjbJar.NamingScheme.DESCRIPTOR)) {
               // try to find JOnAS specific convention name
  -            // ??/MyEJB.xml ( I will find later the ??/jonas-MyEJB.xml file )
  -            if (aDescriptorFileName.indexOf(aConfig.baseNameTerminator) == -1) {
  -                String aCanonicalDescriptor = aDescriptorFileName.replace('\\', '/');
  +            if ( descriptorFileName.indexOf(getConfig().baseNameTerminator) == -1 ) {
  +
  +		// baseNameTerminator not found: the descriptor use the
  +		// JOnAS naming convention, ie [Foo.xml,jonas-Foo.xml] and
  +		// not [Foo<baseNameTerminator>-ejb-jar.xml,
  +		// Foo<baseNameTerminator>-jonas-ejb-jar.xml].
  +		
  +                String aCanonicalDescriptor = descriptorFileName.replace('\\', '/');
                   int lastSeparatorIndex = aCanonicalDescriptor.lastIndexOf('/');
  -                int endBaseName;
  +                int endOfBaseName;
   
                   if (lastSeparatorIndex != -1) {
  -                    endBaseName = aDescriptorFileName.indexOf(".xml", lastSeparatorIndex);
  +                    endOfBaseName = descriptorFileName.indexOf(".xml", lastSeparatorIndex);
                   } else {
  -                    endBaseName = aDescriptorFileName.indexOf(".xml");
  +                    endOfBaseName = descriptorFileName.indexOf(".xml");
                   }
   
  -                if (endBaseName != -1) {
  -                    aBaseName = aDescriptorFileName.substring(0, endBaseName);
  +                if ( endOfBaseName != -1 ) {
  +                    baseName = descriptorFileName.substring(0, endOfBaseName);
                   }
               }
           }
   
  -        if (aBaseName == null) {
  -            // else get standard BaseName
  -            aBaseName = super.getJarBaseName(aDescriptorFileName);
  -        }
  -        return aBaseName;
  +        if ( baseName == null ) {
  +            // else get standard baseName
  +            baseName = super.getJarBaseName(descriptorFileName);
       }
   
  +        log("JAR base name: " + baseName, Project.MSG_VERBOSE);	
   
  -    /**
  -     * 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.
  -     */
  -    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, publicId);
  +        return baseName;
  +    }
   
  -        // todo ? if (alwaysRebuild || isRebuildRequired(genericJarFile, jarFile))
  -        buildJOnASJar(baseName, genericJarFile, jarFile, files, publicId);
  +    protected void registerKnownDTDs(DescriptorHandler handler) {
  + 	handler.registerDTD(EJB_JAR_1_1_PUBLIC_ID, 
  +			    jonasroot + File.separator + "xml" + File.separator + EJB_JAR_1_1_DTD);
  + 	handler.registerDTD(EJB_JAR_2_0_PUBLIC_ID, 
  +			    jonasroot + File.separator + "xml" + File.separator + EJB_JAR_2_0_DTD);
   
  -        if (!keepGeneric) {
  -            log("deleting generic jar " + genericJarFile.toString(),
  -                Project.MSG_VERBOSE);
  -            genericJarFile.delete();
  -        }
  + 	handler.registerDTD(JONAS_EJB_JAR_2_4_PUBLIC_ID, 
  +			    jonasroot + File.separator + "xml" + File.separator + JONAS_EJB_JAR_2_4_DTD);
  + 	handler.registerDTD(JONAS_EJB_JAR_2_5_PUBLIC_ID, 
  +			    jonasroot + File.separator + "xml" + File.separator + JONAS_EJB_JAR_2_5_DTD);
       }
   
  -
       /**
  -     * Helper method invoked by execute() for each JOnAS jar to be built.
  -     * Encapsulates the logic of constructing a java task for calling GenIC
  -     * and executing it.
  -     *
  -     * @param inBaseName the base name of the jar
  -     * @param inSourceJar java.io.File representing the source (EJB1.1)
  -     *      jarfile.
  -     * @param someFiles list of files in the jar. Add all the new genererated
  -     *      files.
  -     * @param inPublicId the link to DTD (to rewrite JAR).
  -     */
  -    private void buildJOnASJar(final String inBaseName,
  -                                     final File inSourceJar, final File inDestJar,
  -                                     final Hashtable someFiles, String inPublicId) {
  -        org.apache.tools.ant.taskdefs.Java aJavaTask = null;
  -        String aGenIcClassName = genicClass;
  -        boolean isOldGenIC = false;
  -        boolean isTempDirectory = false;
  -        File anOutputDirectoryFile = null;
  -
  -        // do not call GenIC
  -        // only copy file
  -        if (noGENIC) {
  -            try {
  -                FileUtils.newFileUtils().copyFile(inSourceJar, inDestJar);
  +     * Add to the given hashtable all the file generated by GenIC.
  +     *
  +     * @param genericJarFile jar file.
  +     * @param ejbFiles the hashtable.
  +     */
  +    private void addGenICGeneratedFiles(File genericJarFile, Hashtable ejbFiles) {
  +     
  +        Java genicTask = null;	// GenIC task 
  +	String genicClass = null; // GenIC class (3 GenIC classes for various versions of JOnAS are supported)
  +	boolean error = false;	// true if an error occurs during the GenIC call
  +
  +        if ( nogenic ) {
                   return;
  -            } catch (IOException anIOException) {
  -                throw new BuildException("Unable to write EJB jar", anIOException);
               }
  +
  +	genicTask = (Java) getTask().getProject().createTask("java");
  +	genicTask.setTaskName("genic");
  +	genicTask.setFork(true);
  +	
  +	// jonasroot
  +	genicTask.createJvmarg().setValue("-Dinstall.root=" + jonasroot);
  +	
  +	// java policy file
  +	String jonasConfigDir = jonasroot + File.separator + "config";            
  +	File javaPolicyFile = new File(jonasConfigDir, "java.policy");
  +	if ( javaPolicyFile.exists() ) {
  +	    genicTask.createJvmarg().setValue("-Djava.security.policy="
  +					      + javaPolicyFile.toString());
           }
   
  -        // call GenIC
  +	// outputdir
           try {
  -            aJavaTask = (Java) getTask().getProject().createTask("java");
  -            aJavaTask.setTaskName("genic");
  -            if (aGenIcClassName == null) {
  -                aGenIcClassName = GENIC_CLASS;
  -            } else if (OLD_GENIC_CLASS.equals(aGenIcClassName)) {
  -                isOldGenIC = true;
  +	    outputdir = createTempDir();	    
  +	} catch (IOException aIOException) {
  +	    String msg = "Cannot create temp dir: " + aIOException.getMessage();
  +	    throw new BuildException(msg, aIOException);
  +	}
  +	log("Using temporary output directory: " + outputdir, Project.MSG_VERBOSE);
  +	
  +	genicTask.createArg().setValue("-d");
  +	genicTask.createArg().setFile(outputdir);
  +	
  +	// work around a bug of GenIC 2.5
  +	String key;
  +	File f;
  +	Enumeration keys = ejbFiles.keys();
  +	while ( keys.hasMoreElements() ) {
  +	    key = (String)keys.nextElement();
  +	    f = new File(outputdir + File.separator + key);	    
  +	    f.getParentFile().mkdirs();
  +	}
  +	log("Worked around a bug of GenIC 2.5.", Project.MSG_VERBOSE);
  +
  +	// classpath 
  +	Path classpath = getCombinedClasspath();	    
  +	if ( classpath == null ) {
  +	    classpath = new Path(getTask().getProject());
               }
  -            // ClassName
  -            aJavaTask.setClassname(aGenIcClassName);
  +	classpath.append(new Path(classpath.getProject(), jonasConfigDir));
  +	classpath.append(new Path(classpath.getProject(), outputdir.toString()));
   
  -            // JVM Args
  -            if (jonasroot == null) {
  -                throw new BuildException("Error : set the jonasroot parameter");
  -            } else if (!jonasroot.isDirectory()) {
  -                log("jonasroot attribut '" + jonasroot + "' is not a valid directory",
  -                    Project.MSG_ERR);
  +	// try to create the classpath for the correct ORB
  +	if ( orb != null ) {	    
  +	    String orbJar = jonasroot + File.separator + "lib" + File.separator + orb + "_jonas.jar";
  +	    classpath.append(new Path(classpath.getProject(), orbJar));
               }
  -            aJavaTask.createJvmarg().setValue("-Dinstall.root=" + jonasroot);
   
  -            File aJavaPolicyFile = new File(jonasroot, "config/java.policy");
  +	log("Using classpath: " + classpath.toString(), Project.MSG_VERBOSE);
  +	genicTask.setClasspath(classpath);
   
  -            if (aJavaPolicyFile.exists()) {
  -                aJavaTask.createJvmarg().setValue("-Djava.security.policy="
  -                     + aJavaPolicyFile.toString());
  +	// class name (search in the classpath provided for the ejbjar element)
  +	genicClass = getGenicClassName(classpath);
  +	if ( genicClass == null ) {
  +	    log("Cannot find GenIC class in classpath.", Project.MSG_ERR);
  +	    throw new BuildException("GenIC class not found, please check the classpath.");
  +	} else {
  +	    log("Using '" + genicClass + "' GenIC class." , Project.MSG_VERBOSE);	    
  +	    genicTask.setClassname(genicClass);
               }
   
  -            // Find output directory
  -            if (ouputdirectory == null) {
  -                anOutputDirectoryFile = createTempDir();
  -                isTempDirectory = true;
  -                log("Use temporary output directory : " +
  -                    anOutputDirectoryFile, Project.MSG_VERBOSE);
  -            } else {
  -                anOutputDirectoryFile = ouputdirectory;
  -                log("Use temporary specific output directory : " +
  -                    anOutputDirectoryFile, Project.MSG_VERBOSE);
  -            }
  -            aJavaTask.createArg().setValue("-d");
  -            aJavaTask.createArg().setFile(anOutputDirectoryFile);
  -
  -            // Additionnal args
  -            aJavaTask.createArg().setLine(additionalArgs);
  -            // KeepGenerated
  +	// keepgenerated
               if (keepgenerated) {
  -                aJavaTask.createArg().setValue("-keepgenerated");
  +	    genicTask.createArg().setValue("-keepgenerated");
               }
   
  -            // Verbose
  -            if (verbose) {
  -                aJavaTask.createArg().setValue("-verbose");
  +	// nocompil
  +	if ( nocompil ) {
  +	    genicTask.createArg().setValue("-nocompil");
               }
   
  -            // -secpropag
  -            if (secpropag) {
  -                aJavaTask.createArg().setValue("-secpropag");
  +	// novalidation
  +	if ( novalidation ) {
  +	    genicTask.createArg().setValue("-novalidation");
               }
   
  -            // The compiler
  -            if (compiler == null) {
  -                // try to use the compiler specified by build.compiler. Right now we are just going
  -                // to allow Jikes
  -                String aBuildCompiler = getTask().getProject().getProperty("build.compiler");
  -
  -                if ("jikes".equals(aBuildCompiler)) {
  -                    aJavaTask.createArg().setValue("-javac");
  -                    aJavaTask.createArg().setValue("jikes");
  -                }
  -            } else {
  -                if (!"default".equals(compiler)) {
  -                    aJavaTask.createArg().setValue("-javac");
  -                    aJavaTask.createArg().setLine(compiler);
  -                }
  +	// javac
  +	if ( javac != null ) {
  +	    genicTask.createArg().setValue("-javac");
  +	    genicTask.createArg().setLine(javac);
               }
   
  -            if (!isOldGenIC) {
  -                // the add in jar features is buggy...
  -                aJavaTask.createArg().setValue("-noaddinjar");
  +	// javacopts
  +	if ( javacopts != null && !javacopts.equals("") ) {
  +	    genicTask.createArg().setValue("-javacopts");
  +	    genicTask.createArg().setLine(javacopts);
               }
   
  -            aJavaTask.createArg().setValue(inSourceJar.getPath());
  +	// rmicopts
  +	if ( rmicopts != null && !rmicopts.equals("") ) {
  +	    genicTask.createArg().setValue("-rmicopts");
  +	    genicTask.createArg().setLine(rmicopts);
  +	}
   
  -            // try to create the classpath for the correct ORB
  -            Path aClasspath = getCombinedClasspath();
  +	// secpropag
  +	if ( secpropag ) {
  +	    genicTask.createArg().setValue("-secpropag");
  +	}
   
  -            if (aClasspath == null) {
  -                aClasspath = new Path(getTask().getProject());
  +	// verbose
  +	if ( verbose ) {
  +	    genicTask.createArg().setValue("-verbose");
               }
  -            if (orb != null) {
  -                String aOrbJar = new File(jonasroot, "lib/" + orb + "_jonas.jar").toString();
  -                String aConfigDir = new File(jonasroot, "config/").toString();
  -                Path aJOnASOrbPath = new Path(aClasspath.getProject(),
  -                    aOrbJar + File.pathSeparator + aConfigDir);
   
  -                aClasspath.append(aJOnASOrbPath);
  -            } else {
  -                log("No ORB propertie setup (RMI, JEREMIE, DAVID).", Project.MSG_WARN);
  +	// additionalargs
  +	if ( additionalargs != null ) {
  +	    genicTask.createArg().setValue(additionalargs);
               }
   
  -            // append the output directory
  -            aClasspath.append(new Path(aClasspath.getProject(), anOutputDirectoryFile.getPath()));
  -            aJavaTask.setClasspath(aClasspath);
  +	// the generated classes must not be added in the generic JAR!
  +	// is that buggy on old JOnAS (2.4) ??
  +	genicTask.createArg().setValue("-noaddinjar");
   
  -            aJavaTask.setFork(true);
  +	// input file to process by GenIC
  +	genicTask.createArg().setValue(genericJarFile.getPath());
   
  -            log("Calling " + aGenIcClassName + " for " + inSourceJar.toString(),
  -                Project.MSG_VERBOSE);
  +	// calling GenIC task
  +	log("Calling " + genicClass + " for " + getConfig().descriptorDir + File.separator + descriptorName
  +	    + ".", Project.MSG_VERBOSE);
   
  -            if (aJavaTask.executeJava() != 0) {
  -                throw new BuildException("GenIC reported an error");
  -            }
  -            // Update the list of files.
  -            addAllFiles(anOutputDirectoryFile, "", someFiles);
  + 	if ( genicTask.executeJava() != 0 ) {
   
  -            // rewrite the jar with the new files
  -            super.writeJar(inBaseName, inDestJar, someFiles, inPublicId);
  -        } catch (BuildException aBuildException) {
  -            throw aBuildException;
  -        } catch (Exception e) {
  -            // Have to catch this because of the semantics of calling main()
  -            String msg = "Exception while calling " + aGenIcClassName + ". Details: " + e.toString();
  +	    // the method deleteOnExit() do not work because the directory is not empty
  +	    log("Deleting temp output directory '" + outputdir + "'.", Project.MSG_VERBOSE);
  +	    deleteAllFiles(outputdir);
   
  -            throw new BuildException(msg, e);
  -        } finally {
  -            if (isTempDirectory && anOutputDirectoryFile != null) {
  -                dellAllFiles(anOutputDirectoryFile);
  -            } else if (cleanWorkDir && anOutputDirectoryFile != null) {
  -                dellAllFilesInside(anOutputDirectoryFile);
  -            }
  -        }
  +	    if ( !keepgeneric ) {
  +		log("Deleting generic JAR " + genericJarFile.toString(), Project.MSG_VERBOSE);
  +		genericJarFile.delete();	     
       }
   
  -
  -    /**
  -     * 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(final String aBaseName) {
  -        return new File(getDestDir(), aBaseName + jarSuffix);
  +	    throw new BuildException("GenIC reported an error.");
       }
   
  +	// add the generated files to the ejbFiles
  +	addAllFiles(outputdir, "", ejbFiles);
  +    }
   
       /**
  -     * Create a free tempory directory for GenIC output.
  +     * Get the GenIC class name to use in the given classpath.
        *
  -     * @return directory file
  -     * @throws BuildException if impossible to find a tempory directory
  +     * @param classpath classpath where the GenIC class must be searched.
  +     * @return the GenIC class name. Return <code>null</code> if the class name
  +     * cannot be found.
        */
  -    private File createTempDir() {
  -        String theTempDir = System.getProperty("java.io.tmpdir");
  -        int anIndice = 0;
  -        File aFile = null;
  -        // try 50 times to find a free tempory directory
  -        while (anIndice < 50 && aFile == null) {
  -            aFile = new File(theTempDir, "GenicTemp" + anIndice);
  -            if (aFile.exists()) {
  -                anIndice++;
  -                aFile = null;
  +    String getGenicClassName(Path classpath) {
  +
  +	log("Looking for GenIC class in classpath: " + classpath.toString(), Project.MSG_VERBOSE);
  +
  +	AntClassLoader cl = new AntClassLoader(classpath.getProject(), classpath);
  +
  +	try {
  +	    cl.loadClass(JonasDeploymentTool.GENIC_CLASS);
  +	    log("Found GenIC class '" + JonasDeploymentTool.GENIC_CLASS + "' in classpath.", Project.MSG_VERBOSE);
  +	    return JonasDeploymentTool.GENIC_CLASS;
  +
  +	} catch (ClassNotFoundException cnf1) {
  + 	    log("GenIC class '" + JonasDeploymentTool.GENIC_CLASS + "' not found in classpath.", 
  +		Project.MSG_VERBOSE);
               }
  +
  +	try {
  +	    cl.loadClass(JonasDeploymentTool.OLD_GENIC_CLASS_1);
  +	    log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1 + 
  +		"' in classpath.", Project.MSG_VERBOSE);
  +	    return JonasDeploymentTool.OLD_GENIC_CLASS_1;
  +
  +	} catch (ClassNotFoundException cnf2) {
  + 	    log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1 + 
  +		"' not found in classpath.",
  +		Project.MSG_VERBOSE);
           }
   
  -        if (aFile == null) {
  -            // problem in temp directory
  -            throw new BuildException("Impossible to find a free temp directory for output.");
  -        } else {
  -            aFile.mkdirs();
  -            return (aFile);
  +	try {
  +	    cl.loadClass(JonasDeploymentTool.OLD_GENIC_CLASS_2);
  +	    log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2 + 
  +		"' in classpath.", Project.MSG_VERBOSE);
  +	    return JonasDeploymentTool.OLD_GENIC_CLASS_2;
  +
  +	} catch (ClassNotFoundException cnf3) {
  + 	    log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2 + 
  +		"' not found in classpath.",
  +		Project.MSG_VERBOSE);
           }
  +	return null;
       }
   
  +    protected void checkConfiguration(String descriptorFileName,
  +				      SAXParser saxParser) throws BuildException {
   
  -    /**
  -     * add all files in anOutputDir + ' / ' + aRootDir to the HashTable
  -     * someFiles.
  -     *
  -     * @param anOutputDir - start directory
  -     * @param aCurrentDirOrFile - a sub-directory to scan or a file to add.
  -     * @param someFiles - where to add the files
  -     */
  -    private void addAllFiles(final File anOutputDir, String aCurrentDirOrFile, Hashtable someFiles) {
  -        File aFile = new File(anOutputDir, aCurrentDirOrFile);
  -
  -        if (aFile.isDirectory()) {
  -            String aCurrentDir = "";
  +	// jonasroot
  +	if ( jonasroot == null ) {
  +	    throw new BuildException("The jonasroot attribut is not set.");
  +	} else if ( !jonasroot.isDirectory() ) {
  +	    throw new BuildException("The jonasroot attribut '" + jonasroot + 
  +				     "' is not a valid directory.");
  +	}
   
  -            if (aCurrentDirOrFile.length() > 0) {
  -                aCurrentDir = aCurrentDirOrFile + '/';
  +	// orb
  +	if ( orb != null && !orb.equals(RMI_ORB) && !orb.equals(JEREMIE_ORB) && !orb.equals(DAVID_ORB) ) {
  +	    throw new BuildException("The orb attribut '" + orb + "' is not valid (must be either " +
  +				     RMI_ORB + ", " + JEREMIE_ORB + " or " + DAVID_ORB + ").");
               }
  -            File theFiles[] = aFile.listFiles();
   
  -            for (int i = 0; i < theFiles.length; i++) {
  -                addAllFiles(anOutputDir, aCurrentDir + theFiles[i].getName(), someFiles);
  +	// additionalargs
  +	if ( additionalargs != null && additionalargs.equals("") ) {
  +	    throw new BuildException("Empty additionalargs attribut.");
               }
  -        } else {
  -            // is a file
  -            someFiles.put(aCurrentDirOrFile, aFile);
  +
  +	// javac
  +	if ( javac != null && javac.equals("") ) {
  +	    throw new BuildException("Empty javac attribut.");	
           }
       }
   
  +    /* ----------------------------------------------------------------------------------- */
  +    /* utilitary methods */
  +    /* ----------------------------------------------------------------------------------- */    
  +
  +    /**
  +     * Create a temporary directory for GenIC output.
  +     *
  +     * @return the temp directory.
  +     * @throws BuildException if a temp directory cannot be created.
  +     */
  +    private File createTempDir() throws IOException {       
  +	File tmpDir = File.createTempFile("genic", null, null);	    
  +	tmpDir.delete();
  +	if ( !tmpDir.mkdir() ) {
  +	    throw new IOException("Cannot create the temporary directory '" + tmpDir + "'.");
  +	}
  +	return tmpDir;
  +    }
   
       /**
  -     * Delete all the files in a directory
  +     * Delete a file. If the file is a directory, delete recursivly all the
  +     * files inside.
        *
  -     * @param aFile file to delete recursivly
  +     * @param aFile file to delete.
        */
  -    private void dellAllFiles(File aFile) {
  +    private void deleteAllFiles(File aFile) {
           if (aFile.isDirectory()) {
               File someFiles[] = aFile.listFiles();
   
               for (int i = 0; i < someFiles.length; i++) {
  -                dellAllFiles(someFiles[i]);
  +                deleteAllFiles(someFiles[i]);
               }
           }
           aFile.delete();
       }
   
  -
       /**
  -     * Delete all the files in a directory, but don't delete the directory
  +     * Add a file to the a given hashtable. If the file is a directory, add
  +     * recursivly all the files inside to the hashtable.
        *
  -     * @param aFile file to delete recursivly
  +     * @param file the file to add.
  +     * @param rootDir the current sub-directory to scan.
  +     * @param hashtable the hashtable where to add the files.
        */
  -    private void dellAllFilesInside(File aFile) {
  -        if (aFile.isDirectory()) {
  -            File someFiles[] = aFile.listFiles();
  +    private void addAllFiles(File file, String rootDir, Hashtable hashtable) {
   
  -            for (int i = 0; i < someFiles.length; i++) {
  -                dellAllFiles(someFiles[i]);
  +        if ( !file.exists() ) {
  +	    throw new IllegalArgumentException();
               }
  +	
  +	String newRootDir;
  +        if ( file.isDirectory() ) {
  +	    File files[] = file.listFiles();	
  +	    for (int i = 0; i < files.length; i++) {
  +		if ( rootDir.length() > 0 ) {
  +		    newRootDir = rootDir + File.separator + files[i].getName();
  +		} else {
  +		    newRootDir = files[i].getName();		     
  +		}
  +		addAllFiles(files[i], newRootDir, hashtable);
  +	    }
  +        } else {
  +            hashtable.put(rootDir, file);
           }
       }
  -
   }
  -
  
  
  

--
To unsubscribe, e-mail:   <mailto:ant-dev-unsubscribe@jakarta.apache.org>
For additional commands, e-mail: <mailto:ant-dev-help@jakarta.apache.org>


Mime
View raw message