Browse Source

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
master
Antoine Levy-Lambert 22 years ago
parent
commit
202be1f5e1
4 changed files with 109 additions and 10 deletions
  1. +6
    -0
      WHATSNEW
  2. +20
    -2
      docs/manual/OptionalTasks/ejb.html
  3. +54
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/EjbJar.java
  4. +29
    -5
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/JbossDeploymentTool.java

+ 6
- 0
WHATSNEW View File

@@ -389,6 +389,12 @@ Bugzilla Report 19180.

* <junit>'s nested <formatter> elements now support if/unless clauses.

* <ejbjar>
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
===================================



+ 20
- 2
docs/manual/OptionalTasks/ejb.html View File

@@ -19,6 +19,7 @@
<li>Conor MacNeill</li>
<li>Cyrille Morvan (<a href="mailto:cmorvan@ingenosya.com">cmorvan@ingenosya.com</a>)</li>
<li>Greg Nelson (<a href="mailto:gn@sun.com">gn@sun.com</a>)</li>
<li>Rob van Oostrum(<a href="mailto:rvanoo@xs4all.nl">rvanoo@xs4all.nl</a>)</li>
</ul>

<p>Version @VERSION@<br>
@@ -716,6 +717,13 @@ the value <code>none</code>.</p>
deployment elements have been specified).</td>
<td valign="top" align="center">Yes</td>
</tr>
<tr>
<td valign="top">cmpversion</td>
<td valign="top">Either <code>1.0</code> or <code>2.0</code>.<br/>
Default is <code>1.0</code>.<br/>
A CMP 2.0 implementation exists currently only for JBoss.</td>
<td valign="top" align="center">No</td>
</tr>
<tr>
<td valign="top">naming</td>
<td valign="top">Controls the naming convention used to name generated
@@ -844,8 +852,18 @@ deployment element are detailed here.
<h3><a name="ejbjar_jboss">Jboss element</a></h3>

<p>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:
<ul><li>jboss.xml</li>
<li>for container manager persistence:<br/>
<table border="1">
<tr><td><b>CMP version</b></td><td><b>File name</b></td></tr>
<tr><td>CMP 1.0</td><td>jaws.xml</td></tr>
<tr><td>CMP 2.0</td><td>jbosscmp-jdbc.xml</td></tr>
</table>
</li>
</ul>
<br/>
. The JBoss server uses hot deployment and does
not require compilation of additional stubs and skeletons.</p>

<table border="1" cellpadding="2" cellspacing="0">


+ 54
- 3
src/main/org/apache/tools/ant/taskdefs/optional/ejb/EjbJar.java View File

@@ -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 <a href="mailto:tfennell@sapient.com">Tim Fennell</a>
* @author Conor MacNeill
*/
* @author <a href="mailto:rvanoo@xs4all.nl">Rob van Oostrum</a>
* */
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 <code>1.0</code> or <code>2.0</code>.<br/>
* Default is <code>1.0</code>.<br/>
* Initially, only the JBoss implementation does something specific for CMP 2.0.<br/>
* @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()

}




+ 29
- 5
src/main/org/apache/tools/ant/taskdefs/optional/ejb/JbossDeploymentTool.java View File

@@ -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 <a href="mailto:p.austin@talk21.com">Paul Austin</a>
* @author <a href="mailto:rvanoo@xs4all.nl">Rob van Oostrum</a>
* @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();
}
}

Loading…
Cancel
Save