From 202be1f5e13eacc3600852b1b297e6183dda48bf Mon Sep 17 00:00:00 2001 From: Antoine Levy-Lambert Date: Thu, 29 May 2003 15:35:26 +0000 Subject: [PATCH] Adds functionality that makes jboss element look for jbosscmp-jdbc.xml descriptor if ejbjar has cmpversion="2.0" set PR: 14709 Submitted by: Rob van Oostrum (rvanoo at xs4all dot nl) git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274637 13f79535-47bb-0310-9956-ffa450edef68 --- WHATSNEW | 6 ++ docs/manual/OptionalTasks/ejb.html | 22 ++++++- .../ant/taskdefs/optional/ejb/EjbJar.java | 57 ++++++++++++++++++- .../optional/ejb/JbossDeploymentTool.java | 34 +++++++++-- 4 files changed, 109 insertions(+), 10 deletions(-) diff --git a/WHATSNEW b/WHATSNEW index 3f2ea59fa..064ade6c6 100644 --- a/WHATSNEW +++ b/WHATSNEW @@ -389,6 +389,12 @@ Bugzilla Report 19180. * 's nested elements now support if/unless clauses. +* + cmpversion attribute added + jboss element will look for jbosscmp-jdbc.xml descriptor + if ejbjar has cmpversion="2.0" set + Bugzilla Reports 14707 and 14709. + Changes from Ant 1.5.2 to Ant 1.5.3 =================================== diff --git a/docs/manual/OptionalTasks/ejb.html b/docs/manual/OptionalTasks/ejb.html index adb95d7ab..ba55d24da 100644 --- a/docs/manual/OptionalTasks/ejb.html +++ b/docs/manual/OptionalTasks/ejb.html @@ -19,6 +19,7 @@
  • Conor MacNeill
  • Cyrille Morvan (cmorvan@ingenosya.com)
  • Greg Nelson (gn@sun.com)
  • +
  • Rob van Oostrum(rvanoo@xs4all.nl)
  • Version @VERSION@
    @@ -716,6 +717,13 @@ the value none.

    deployment elements have been specified). Yes + + cmpversion + Either 1.0 or 2.0.
    + Default is 1.0.
    + A CMP 2.0 implementation exists currently only for JBoss. + No + naming Controls the naming convention used to name generated @@ -844,8 +852,18 @@ deployment element are detailed here.

    Jboss element

    The jboss element searches for the JBoss specific deployment descriptors and adds them -to the final ejb jar file. JBoss has two deployment descriptors jboss.xml and jaws.xml -(for container manager persistence only). The JBoss server uses hot deployment and does +to the final ejb jar file. JBoss has two deployment descriptors: +

    • jboss.xml
    • +
    • for container manager persistence:
      + + + + +
      CMP versionFile name
      CMP 1.0jaws.xml
      CMP 2.0jbosscmp-jdbc.xml
      +
    • +
    +
    +. The JBoss server uses hot deployment and does not require compilation of additional stubs and skeletons.

    diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/EjbJar.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/EjbJar.java index a5a8a9948..4c8fcf95e 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/EjbJar.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/EjbJar.java @@ -1,7 +1,7 @@ /* * The Apache Software License, Version 1.1 * - * Copyright (c) 2000-2002 The Apache Software Foundation. All rights + * Copyright (c) 2000-2003 The Apache Software Foundation. All rights * reserved. * * Redistribution and use in source and binary forms, with or without @@ -91,7 +91,8 @@ import org.xml.sax.SAXException; * * @author Tim Fennell * @author Conor MacNeill - */ + * @author Rob van Oostrum + * */ public class EjbJar extends MatchingTask { /** @@ -201,6 +202,21 @@ public class EjbJar extends MatchingTask { } } + /** + * CMP versions supported + * valid CMP versions are 1.0 and 2.0 + * @since ant 1.6 + */ + public static class CMPVersion extends EnumeratedAttribute { + public static final String CMP1_0 = "1.0"; + public static final String CMP2_0 = "2.0"; + public String[] getValues() { + return new String[]{ + CMP1_0, + CMP2_0, + }; + } + } /** * The config which is built by this task and used by the various deployment * tools to access the configuration of the ejbjar task @@ -219,10 +235,12 @@ public class EjbJar extends MatchingTask { /** Instance variable that stores the suffix for the generated jarfile. */ private String genericJarSuffix = "-generic.jar"; + /** Instance variable that stores the CMP version for the jboss jarfile. */ + private String cmpVersion = CMPVersion.CMP1_0; + /** The list of deployment tools we are going to run. */ private ArrayList deploymentTools = new ArrayList(); - /** * Add a deployment tool to the list of deployment tools that will be * processed @@ -444,6 +462,15 @@ public class EjbJar extends MatchingTask { } } + /** + * Gets the destination directory. + * + * @return destination directory + * @since ant 1.6 + */ + public File getDestdir() { + return this.destDir; + } /** * Set the destination directory. The EJB jar files will be written into @@ -459,6 +486,29 @@ public class EjbJar extends MatchingTask { this.destDir = inDir; } + /** + * Gets the CMP version. + * + * @return CMP version + * @since ant 1.6 + */ + public String getCmpversion() { + return this.cmpVersion; + } + + /** + * Sets the CMP version. + * + * @param version CMP version. + * Must be either 1.0 or 2.0.
    + * Default is 1.0.
    + * Initially, only the JBoss implementation does something specific for CMP 2.0.
    + * @since ant 1.6 + */ + public void setCmpversion( CMPVersion version ) { + this.cmpVersion = version.getValue(); + } + /** * Set the classpath to use when resolving classes for inclusion in the jar. * @@ -599,6 +649,7 @@ public class EjbJar extends MatchingTask { throw new BuildException(msg, pce); } } // end of execute() + } diff --git a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JbossDeploymentTool.java b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JbossDeploymentTool.java index ef8e59197..e98a61e59 100644 --- a/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JbossDeploymentTool.java +++ b/src/main/org/apache/tools/ant/taskdefs/optional/ejb/JbossDeploymentTool.java @@ -55,6 +55,7 @@ package org.apache.tools.ant.taskdefs.optional.ejb; import java.io.File; import java.util.Hashtable; +import org.apache.tools.ant.BuildException; import org.apache.tools.ant.Project; /** @@ -63,12 +64,14 @@ import org.apache.tools.ant.Project; * compilation. * * @author Paul Austin + * @author Rob van Oostrum * @version 1.0 * @see EjbJar#createJboss */ public class JbossDeploymentTool extends GenericDeploymentTool { protected static final String JBOSS_DD = "jboss.xml"; - protected static final String JBOSS_CMPD = "jaws.xml"; + protected static final String JBOSS_CMP10D = "jaws.xml"; + protected static final String JBOSS_CMP20D = "jbosscmp-jdbc.xml"; /** Instance variable that stores the suffix for the jboss jarfile. */ private String jarSuffix = ".jar"; @@ -93,10 +96,17 @@ public class JbossDeploymentTool extends GenericDeploymentTool { log("Unable to locate jboss deployment descriptor. It was expected to be in " + jbossDD.getPath(), Project.MSG_WARN); return; } - - File jbossCMPD = new File(getConfig().descriptorDir, ddPrefix + JBOSS_CMPD); + String descriptorFileName = JBOSS_CMP10D; + if ( EjbJar.CMPVersion.CMP2_0.equals( getParent().getCmpversion() ) ) { + descriptorFileName = JBOSS_CMP20D; + } + File jbossCMPD = new File(getConfig().descriptorDir, ddPrefix + descriptorFileName); + if (jbossCMPD.exists()) { - ejbFiles.put(META_DIR + JBOSS_CMPD, jbossCMPD); + ejbFiles.put(META_DIR + descriptorFileName, jbossCMPD); + } else { + log("Unable to locate jboss cmp descriptor. It was expected to be in " + jbossCMPD.getPath(), Project.MSG_WARN); + return; } } @@ -105,6 +115,20 @@ public class JbossDeploymentTool extends GenericDeploymentTool { * of this jar will be checked against the dependent bean classes. */ File getVendorOutputJarFile(String baseName) { - return new File(getDestDir(), baseName + jarSuffix); + return new File( getParent().getDestdir(), baseName + jarSuffix); + } + + /** + * Called to validate that the tool parameters have been configured. + * + * @throws BuildException If the Deployment Tool's configuration isn't + * valid + * @since ant 1.6 + */ + public void validateConfigured() throws BuildException { + } + + private EjbJar getParent() { + return ( EjbJar ) this.getTask(); } }