Browse Source

Allow ejbjar to specify support classes.

You can add support classes to all the generated jar fils by including a
<support-classes> nested element. This is effectively a fileset and
includes the ability to reference another fileset by refid

So
<ejbjar ...>
       <support-classes dir="${build.classes.server}">
            <include name="**/*.class"/>
       </support-classes>
...
</ejbjar>

or

<ejbjar ...>
       <support-classes refid="support.fileset"/>
...
</ejbjar>


Please note the following.
==========================
If your ejbjar task generates multiple jar files, the support classes will be
added to each one.

The nested element name may change. I am using it to test a facility I added
to the core. If it does change, it will change to <support>


git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@268486 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 24 years ago
parent
commit
6ca00c2391
3 changed files with 38 additions and 7 deletions
  1. +4
    -1
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/EJBDeploymentTool.java
  2. +17
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/EjbJar.java
  3. +17
    -3
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/GenericDeploymentTool.java

+ 4
- 1
src/main/org/apache/tools/ant/taskdefs/optional/ejb/EJBDeploymentTool.java View File

@@ -69,8 +69,11 @@ public interface EJBDeploymentTool {
*
* @param descriptorFilename the name of the deployment descriptor
* @param saxParser a SAX parser which can be used to parse the deployment descriptor.
* @param supportFileSet a fileset containing all the files to be included in the
* ` generated jarfile as support classes.
*/
public void processDescriptor(String descriptorFilename, SAXParser saxParser)
public void processDescriptor(String descriptorFilename, SAXParser saxParser,
FileSet supportFileSet)
throws BuildException;
/**


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

@@ -137,6 +137,11 @@ public class EjbJar extends MatchingTask {
*/
private ArrayList deploymentTools = new ArrayList();

/**
* A Fileset of support classes
*/
private FileSet supportClasses = null;

/**
* Create a weblogic nested element used to configure a
* deployment tool for Weblogic server.
@@ -178,6 +183,16 @@ public class EjbJar extends MatchingTask {
return classpath.createPath();
}

public Object createElement(String elementName) {
if (elementName.equals("support-classes")) {
supportClasses = new FileSet();
return supportClasses;
}
return null;
}

/**
* Set the srcdir attribute. The source directory is the directory that contains
* the classes that will be added to the EJB jar. Typically this will include the
@@ -301,7 +316,7 @@ public class EjbJar extends MatchingTask {
if (srcDir == null) {
throw new BuildException("The srcDir attribute must be specified");
}
if (deploymentTools.size() == 0) {
GenericDeploymentTool genericTool = new GenericDeploymentTool();
genericTool.setDestdir(destDir);
@@ -335,14 +350,13 @@ public class EjbJar extends MatchingTask {
log(files.length + " deployment descriptors located.",
Project.MSG_VERBOSE);
// Loop through the files. Each file represents one deployment
// descriptor, and hence one bean in our model.
for (int index = 0; index < files.length; ++index) {
// process the deployment descriptor in each tool
for (Iterator i = deploymentTools.iterator(); i.hasNext(); ) {
EJBDeploymentTool tool = (EJBDeploymentTool)i.next();
tool.processDescriptor(files[index], saxParser);
tool.processDescriptor(files[index], saxParser, supportClasses);
}
}
}


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

@@ -264,7 +264,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool {
if (!addedfiles.contains(logicalFilename)) {
iStream = new FileInputStream(inputFile);
// Create the zip entry and add it to the jar file
ZipEntry zipEntry = new ZipEntry(logicalFilename);
ZipEntry zipEntry = new ZipEntry(logicalFilename.replace('\\','/'));
jStream.putNextEntry(zipEntry);
// Create the file input stream, and buffer everything over
@@ -301,7 +301,8 @@ public class GenericDeploymentTool implements EJBDeploymentTool {
return new DescriptorHandler(srcDir);
}
public void processDescriptor(String descriptorFileName, SAXParser saxParser) {
public void processDescriptor(String descriptorFileName, SAXParser saxParser,
FileSet supportFileSet) {
FileInputStream descriptorStream = null;

try {
@@ -315,7 +316,20 @@ public class GenericDeploymentTool implements EJBDeploymentTool {
saxParser.parse(new InputSource(descriptorStream), handler);
Hashtable ejbFiles = handler.getFiles();
// add in support classes if any
if (supportFileSet != null) {
Project project = task.getProject();
File supportBaseDir = supportFileSet.getDir(project);
DirectoryScanner supportScanner = supportFileSet.getDirectoryScanner(project);
supportScanner.scan();
String[] supportFiles = supportScanner.getIncludedFiles();
for (int i = 0; i < supportFiles.length; ++i) {
ejbFiles.put(supportFiles[i], new File(supportBaseDir, supportFiles[i]));
}
}

String baseName = "";
// Work out what the base name is


Loading…
Cancel
Save