make the basejarname attribute actually do something useful git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@269221 13f79535-47bb-0310-9956-ffa450edef68master
@@ -240,7 +240,7 @@ public class BorlandDeploymentTool extends GenericDeploymentTool | |||
* Add any vendor specific files which should be included in the | |||
* EJB Jar. | |||
*/ | |||
protected void addVendorFiles(Hashtable ejbFiles, String baseName) { | |||
protected void addVendorFiles(Hashtable ejbFiles, String baseName, String descriptorFileName) { | |||
File borlandDD = new File(getConfig().descriptorDir,META_DIR+BAS_DD); | |||
if (borlandDD.exists()) { | |||
@@ -131,6 +131,7 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase { | |||
if (fileDTD.exists()) { | |||
if (publicId != null) { | |||
fileDTDs.put(publicId, fileDTD); | |||
owningTask.log("Mapped publicId " + publicId + " to file " + fileDTD, Project.MSG_VERBOSE); | |||
} | |||
return; | |||
} | |||
@@ -138,6 +139,7 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase { | |||
if (getClass().getResource(location) != null) { | |||
if (publicId != null) { | |||
resourceDTDs.put(publicId, location); | |||
owningTask.log("Mapped publicId " + publicId + " to resource " + location, Project.MSG_VERBOSE); | |||
} | |||
} | |||
} | |||
@@ -469,6 +469,13 @@ public class EjbJar extends MatchingTask { | |||
throw new BuildException(msg, pce); | |||
} | |||
} // end of execute() | |||
public static class NamignScheme extends EnumeratedAttribute { | |||
public String[] getValues() { | |||
return new String[] {"ejb-name", "directory", "descriptor"}; | |||
} | |||
} | |||
} | |||
@@ -113,10 +113,10 @@ public class GenericDeploymentTool implements EJBDeploymentTool { | |||
*/ | |||
private List addedfiles; | |||
/** | |||
* Handler used to parse the EJB XML descriptor | |||
*/ | |||
private DescriptorHandler handler; | |||
/** | |||
* Handler used to parse the EJB XML descriptor | |||
*/ | |||
private DescriptorHandler handler; | |||
/** | |||
* Setter used to store the value of destination directory prior to execute() | |||
@@ -210,9 +210,9 @@ public class GenericDeploymentTool implements EJBDeploymentTool { | |||
getTask().log(message, level); | |||
} | |||
protected Location getLocation() { | |||
return getTask().getLocation(); | |||
} | |||
protected Location getLocation() { | |||
return getTask().getLocation(); | |||
} | |||
/** | |||
@@ -303,24 +303,24 @@ public class GenericDeploymentTool implements EJBDeploymentTool { | |||
public void processDescriptor(String descriptorFileName, SAXParser saxParser) { | |||
checkConfiguration(descriptorFileName, saxParser); | |||
checkConfiguration(descriptorFileName, saxParser); | |||
try { | |||
// Retrive the files to be added to JAR from EJB descriptor | |||
Hashtable ejbFiles = parseEjbFiles(descriptorFileName, saxParser); | |||
// Retrive the files to be added to JAR from EJB descriptor | |||
Hashtable ejbFiles = parseEjbFiles(descriptorFileName, saxParser); | |||
// Add any support classes specified in the build file | |||
addSupportClasses(ejbFiles); | |||
// Add any support classes specified in the build file | |||
addSupportClasses(ejbFiles); | |||
// Determine the JAR filename (without filename extension) | |||
String baseName = getJarBaseName(descriptorFileName); | |||
// Determine the JAR filename (without filename extension) | |||
String baseName = getJarBaseName(descriptorFileName); | |||
// First the regular deployment descriptor | |||
ejbFiles.put(META_DIR + EJB_DD, | |||
new File(config.descriptorDir, descriptorFileName)); | |||
// now the vendor specific files, if any | |||
addVendorFiles(ejbFiles, baseName); | |||
addVendorFiles(ejbFiles, baseName, descriptorFileName); | |||
// add any inherited files | |||
checkAndAddInherited(ejbFiles); | |||
@@ -351,7 +351,7 @@ public class GenericDeploymentTool implements EJBDeploymentTool { | |||
Project.MSG_INFO); | |||
// Use helper method to write the jarfile | |||
String publicId = getPublicId(); | |||
String publicId = getPublicId(); | |||
writeJar(baseName, jarFile, ejbFiles, publicId); | |||
} | |||
@@ -380,59 +380,59 @@ public class GenericDeploymentTool implements EJBDeploymentTool { | |||
} | |||
} | |||
/** | |||
* This method is called as the first step in the processDescriptor method | |||
* to allow vendor-specific subclasses to validate the task configuration | |||
* prior to processing the descriptor. If the configuration is invalid, | |||
* a BuildException should be thrown. | |||
* | |||
* @param descriptorFileName String representing the file name of an EJB | |||
* descriptor to be processed | |||
* @param saxParser SAXParser which may be used to parse the XML | |||
* descriptor | |||
* @thows BuildException Thrown if the configuration is invalid | |||
*/ | |||
protected void checkConfiguration(String descriptorFileName, | |||
SAXParser saxParser) throws BuildException { | |||
/* | |||
* For the GenericDeploymentTool, do nothing. Vendor specific | |||
* subclasses should throw a BuildException if the configuration is | |||
* invalid for their server. | |||
*/ | |||
} | |||
/** | |||
* This method returns a list of EJB files found when the specified EJB | |||
* descriptor is parsed and processed. | |||
* | |||
* @param descriptorFileName String representing the file name of an EJB | |||
* descriptor to be processed | |||
* @param saxParser SAXParser which may be used to parse the XML | |||
* descriptor | |||
* @return Hashtable of EJB class (and other) files to be | |||
* added to the completed JAR file | |||
* @throws SAXException Any SAX exception, possibly wrapping another | |||
* exception | |||
/** | |||
* This method is called as the first step in the processDescriptor method | |||
* to allow vendor-specific subclasses to validate the task configuration | |||
* prior to processing the descriptor. If the configuration is invalid, | |||
* a BuildException should be thrown. | |||
* | |||
* @param descriptorFileName String representing the file name of an EJB | |||
* descriptor to be processed | |||
* @param saxParser SAXParser which may be used to parse the XML | |||
* descriptor | |||
* @thows BuildException Thrown if the configuration is invalid | |||
*/ | |||
protected void checkConfiguration(String descriptorFileName, | |||
SAXParser saxParser) throws BuildException { | |||
/* | |||
* For the GenericDeploymentTool, do nothing. Vendor specific | |||
* subclasses should throw a BuildException if the configuration is | |||
* invalid for their server. | |||
*/ | |||
} | |||
/** | |||
* This method returns a list of EJB files found when the specified EJB | |||
* descriptor is parsed and processed. | |||
* | |||
* @param descriptorFileName String representing the file name of an EJB | |||
* descriptor to be processed | |||
* @param saxParser SAXParser which may be used to parse the XML | |||
* descriptor | |||
* @return Hashtable of EJB class (and other) files to be | |||
* added to the completed JAR file | |||
* @throws SAXException Any SAX exception, possibly wrapping another | |||
* exception | |||
* @throws IOException An IOException from the parser, possibly from a | |||
* the byte stream or character stream | |||
*/ | |||
protected Hashtable parseEjbFiles(String descriptorFileName, SAXParser saxParser) | |||
throws IOException, SAXException { | |||
FileInputStream descriptorStream = null; | |||
Hashtable ejbFiles = null; | |||
try { | |||
handler = getDescriptorHandler(config.srcDir); | |||
/* Parse the ejb deployment descriptor. While it may not | |||
* look like much, we use a SAXParser and an inner class to | |||
* get hold of all the classfile names for the descriptor. | |||
*/ | |||
descriptorStream = new FileInputStream(new File(config.descriptorDir, descriptorFileName)); | |||
saxParser.parse(new InputSource(descriptorStream), handler); | |||
ejbFiles = handler.getFiles(); | |||
* the byte stream or character stream | |||
*/ | |||
protected Hashtable parseEjbFiles(String descriptorFileName, SAXParser saxParser) | |||
throws IOException, SAXException { | |||
FileInputStream descriptorStream = null; | |||
Hashtable ejbFiles = null; | |||
try { | |||
handler = getDescriptorHandler(config.srcDir); | |||
/* Parse the ejb deployment descriptor. While it may not | |||
* look like much, we use a SAXParser and an inner class to | |||
* get hold of all the classfile names for the descriptor. | |||
*/ | |||
descriptorStream = new FileInputStream(new File(config.descriptorDir, descriptorFileName)); | |||
saxParser.parse(new InputSource(descriptorStream), handler); | |||
ejbFiles = handler.getFiles(); | |||
} finally { | |||
if (descriptorStream != null) { | |||
@@ -443,74 +443,79 @@ public class GenericDeploymentTool implements EJBDeploymentTool { | |||
} | |||
} | |||
return ejbFiles; | |||
} | |||
/** | |||
* Adds any classes the user specifies using <i>support</i> nested elements | |||
* to the <code>ejbFiles</code> Hashtable. | |||
* | |||
* @param ejbFiles Hashtable of EJB classes (and other) files that will be | |||
* added to the completed JAR file | |||
*/ | |||
protected void addSupportClasses(Hashtable ejbFiles) { | |||
// add in support classes if any | |||
Project project = task.getProject(); | |||
for (Iterator i = config.supportFileSets.iterator(); i.hasNext();) { | |||
FileSet supportFileSet = (FileSet)i.next(); | |||
File supportBaseDir = supportFileSet.getDir(project); | |||
DirectoryScanner supportScanner = supportFileSet.getDirectoryScanner(project); | |||
supportScanner.scan(); | |||
String[] supportFiles = supportScanner.getIncludedFiles(); | |||
for (int j = 0; j < supportFiles.length; ++j) { | |||
ejbFiles.put(supportFiles[j], new File(supportBaseDir, supportFiles[j])); | |||
} | |||
} | |||
} | |||
/** | |||
* Using the EJB descriptor file name passed from the <code>ejbjar</code> | |||
* task, this method returns the "basename" which will be used to name the | |||
* completed JAR file. | |||
* | |||
* @param descriptorFileName String representing the file name of an EJB | |||
* descriptor to be processed | |||
* @return The "basename" which will be used to name the | |||
* completed JAR file | |||
*/ | |||
protected String getJarBaseName(String descriptorFileName) { | |||
String baseName = ""; | |||
// Work out what the base name is | |||
if (config.baseJarName != null) { | |||
baseName = config.baseJarName; | |||
} else { | |||
int lastSeparatorIndex = descriptorFileName.lastIndexOf(File.separator); | |||
int endBaseName = -1; | |||
if (lastSeparatorIndex != -1) { | |||
endBaseName = descriptorFileName.indexOf(config.baseNameTerminator, | |||
lastSeparatorIndex); | |||
} else { | |||
endBaseName = descriptorFileName.indexOf(config.baseNameTerminator); | |||
} | |||
if (endBaseName != -1) { | |||
baseName = descriptorFileName.substring(0, endBaseName); | |||
} | |||
baseName = descriptorFileName.substring(0, endBaseName); | |||
} | |||
return baseName; | |||
} | |||
return ejbFiles; | |||
} | |||
/** | |||
* Adds any classes the user specifies using <i>support</i> nested elements | |||
* to the <code>ejbFiles</code> Hashtable. | |||
* | |||
* @param ejbFiles Hashtable of EJB classes (and other) files that will be | |||
* added to the completed JAR file | |||
*/ | |||
protected void addSupportClasses(Hashtable ejbFiles) { | |||
// add in support classes if any | |||
Project project = task.getProject(); | |||
for (Iterator i = config.supportFileSets.iterator(); i.hasNext();) { | |||
FileSet supportFileSet = (FileSet)i.next(); | |||
File supportBaseDir = supportFileSet.getDir(project); | |||
DirectoryScanner supportScanner = supportFileSet.getDirectoryScanner(project); | |||
supportScanner.scan(); | |||
String[] supportFiles = supportScanner.getIncludedFiles(); | |||
for (int j = 0; j < supportFiles.length; ++j) { | |||
ejbFiles.put(supportFiles[j], new File(supportBaseDir, supportFiles[j])); | |||
} | |||
} | |||
} | |||
/** | |||
* Using the EJB descriptor file name passed from the <code>ejbjar</code> | |||
* task, this method returns the "basename" which will be used to name the | |||
* completed JAR file. | |||
* | |||
* @param descriptorFileName String representing the file name of an EJB | |||
* descriptor to be processed | |||
* @return The "basename" which will be used to name the | |||
* completed JAR file | |||
*/ | |||
protected String getJarBaseName(String descriptorFileName) { | |||
String baseName = ""; | |||
// Work out what the base name is | |||
if (config.baseJarName != null) { | |||
String canonicalDescriptor = descriptorFileName.replace('\\', '/'); | |||
int index = canonicalDescriptor.lastIndexOf('/'); | |||
if (index != -1) { | |||
baseName = descriptorFileName.substring(0, index + 1); | |||
} | |||
baseName += config.baseJarName; | |||
} else { | |||
int lastSeparatorIndex = descriptorFileName.lastIndexOf(File.separator); | |||
int endBaseName = -1; | |||
if (lastSeparatorIndex != -1) { | |||
endBaseName = descriptorFileName.indexOf(config.baseNameTerminator, | |||
lastSeparatorIndex); | |||
} else { | |||
endBaseName = descriptorFileName.indexOf(config.baseNameTerminator); | |||
} | |||
if (endBaseName != -1) { | |||
baseName = descriptorFileName.substring(0, endBaseName); | |||
} | |||
baseName = descriptorFileName.substring(0, endBaseName); | |||
} | |||
return baseName; | |||
} | |||
/** | |||
* Add any vendor specific files which should be included in the | |||
* EJB Jar. | |||
*/ | |||
protected void addVendorFiles(Hashtable ejbFiles, String baseName) { | |||
protected void addVendorFiles(Hashtable ejbFiles, String baseName, String descriptorFileName) { | |||
// nothing to add for generic tool. | |||
} | |||
@@ -523,55 +528,55 @@ public class GenericDeploymentTool implements EJBDeploymentTool { | |||
return new File(destDir, baseName + genericJarSuffix); | |||
} | |||
/** | |||
* This method checks the timestamp on each file listed in the <code> | |||
* ejbFiles</code> and compares them to the timestamp on the <code>jarFile | |||
* </code>. If the <code>jarFile</code>'s timestamp is more recent than | |||
* each EJB file, <code>false</code> is returned. Otherwise, <code>true | |||
* </code> is returned. | |||
* | |||
* @param ejbFiles Hashtable of EJB classes (and other) files that will be | |||
* added to the completed JAR file | |||
* @param jarFile JAR file which will contain all of the EJB classes (and | |||
* other) files | |||
* @return boolean indicating whether or not the <code>jarFile</code> | |||
* is up to date | |||
*/ | |||
protected boolean needToRebuild(Hashtable ejbFiles, File jarFile) { | |||
// By default we assume we need to build. | |||
boolean needBuild = true; | |||
if (jarFile.exists()) { | |||
long lastBuild = jarFile.lastModified(); | |||
Iterator fileIter = ejbFiles.values().iterator(); | |||
// Set the need build to false until we find out otherwise. | |||
needBuild = false; | |||
// Loop through the files seeing if any has been touched | |||
// more recently than the destination jar. | |||
while( (needBuild == false) && (fileIter.hasNext()) ) { | |||
File currentFile = (File) fileIter.next(); | |||
needBuild = ( lastBuild < currentFile.lastModified() ); | |||
if (needBuild) { | |||
log("Build needed because " + currentFile.getPath() + " is out of date", | |||
Project.MSG_VERBOSE); | |||
} | |||
} | |||
} | |||
return needBuild; | |||
} | |||
/** | |||
* Returns the Public ID of the DTD specified in the EJB descriptor. Not | |||
* every vendor-specific <code>DeploymentTool</code> will need to reference | |||
* this value or may want to determine this value in a vendor-specific way. | |||
* | |||
* @return Public ID of the DTD specified in the EJB descriptor. | |||
*/ | |||
protected String getPublicId() { | |||
return handler.getPublicId(); | |||
} | |||
/** | |||
* This method checks the timestamp on each file listed in the <code> | |||
* ejbFiles</code> and compares them to the timestamp on the <code>jarFile | |||
* </code>. If the <code>jarFile</code>'s timestamp is more recent than | |||
* each EJB file, <code>false</code> is returned. Otherwise, <code>true | |||
* </code> is returned. | |||
* | |||
* @param ejbFiles Hashtable of EJB classes (and other) files that will be | |||
* added to the completed JAR file | |||
* @param jarFile JAR file which will contain all of the EJB classes (and | |||
* other) files | |||
* @return boolean indicating whether or not the <code>jarFile</code> | |||
* is up to date | |||
*/ | |||
protected boolean needToRebuild(Hashtable ejbFiles, File jarFile) { | |||
// By default we assume we need to build. | |||
boolean needBuild = true; | |||
if (jarFile.exists()) { | |||
long lastBuild = jarFile.lastModified(); | |||
Iterator fileIter = ejbFiles.values().iterator(); | |||
// Set the need build to false until we find out otherwise. | |||
needBuild = false; | |||
// Loop through the files seeing if any has been touched | |||
// more recently than the destination jar. | |||
while( (needBuild == false) && (fileIter.hasNext()) ) { | |||
File currentFile = (File) fileIter.next(); | |||
needBuild = ( lastBuild < currentFile.lastModified() ); | |||
if (needBuild) { | |||
log("Build needed because " + currentFile.getPath() + " is out of date", | |||
Project.MSG_VERBOSE); | |||
} | |||
} | |||
} | |||
return needBuild; | |||
} | |||
/** | |||
* Returns the Public ID of the DTD specified in the EJB descriptor. Not | |||
* every vendor-specific <code>DeploymentTool</code> will need to reference | |||
* this value or may want to determine this value in a vendor-specific way. | |||
* | |||
* @return Public ID of the DTD specified in the EJB descriptor. | |||
*/ | |||
protected String getPublicId() { | |||
return handler.getPublicId(); | |||
} | |||
/** | |||
* Method used to encapsulate the writing of the JAR file. Iterates over the | |||
@@ -785,14 +790,14 @@ public class GenericDeploymentTool implements EJBDeploymentTool { | |||
/** | |||
* Called to validate that the tool parameters have been configured. | |||
* | |||
* @throws BuildException If the Deployment Tool's configuration isn't | |||
* valid | |||
* @throws BuildException If the Deployment Tool's configuration isn't | |||
* valid | |||
*/ | |||
public void validateConfigured() throws BuildException { | |||
if ((destDir == null) || (!destDir.isDirectory())) { | |||
String msg = "A valid destination directory must be specified " | |||
+ "using the \"destdir\" attribute."; | |||
throw new BuildException(msg, getLocation()); | |||
String msg = "A valid destination directory must be specified " | |||
+ "using the \"destdir\" attribute."; | |||
throw new BuildException(msg, getLocation()); | |||
} | |||
} | |||
} |
@@ -122,302 +122,301 @@ import org.apache.tools.ant.BuildException; | |||
*/ | |||
public class IPlanetDeploymentTool extends GenericDeploymentTool { | |||
/* Attributes set by the Ant build file */ | |||
private File iashome; | |||
private String jarSuffix = ".jar"; | |||
private boolean keepgenerated = false; | |||
private boolean debug = false; | |||
/* | |||
* Filenames of the standard EJB descriptor (which is passed to this class | |||
* from the parent "ejbjar" task) and the iAS-specific EJB descriptor | |||
* (whose name is determined by this class). Both filenames are relative | |||
* to the directory specified by the "srcdir" attribute in the ejbjar task. | |||
*/ | |||
private String descriptorName; | |||
private String iasDescriptorName; | |||
/* | |||
* The displayName variable stores the value of the "display-name" element | |||
* from the standard EJB descriptor. As a future enhancement to this task, | |||
* we may determine the name of the EJB JAR file using this display-name, | |||
* but this has not be implemented yet. | |||
*/ | |||
private String displayName; | |||
/* | |||
* Regardless of the name of the iAS-specific EJB descriptor file, it will | |||
* written in the completed JAR file as "ias-ejb-jar.xml". This is the | |||
* naming convention implemented by iAS. | |||
*/ | |||
/* Attributes set by the Ant build file */ | |||
private File iashome; | |||
private String jarSuffix = ".jar"; | |||
private boolean keepgenerated = false; | |||
private boolean debug = false; | |||
/* | |||
* Filenames of the standard EJB descriptor (which is passed to this class | |||
* from the parent "ejbjar" task) and the iAS-specific EJB descriptor | |||
* (whose name is determined by this class). Both filenames are relative | |||
* to the directory specified by the "srcdir" attribute in the ejbjar task. | |||
*/ | |||
private String descriptorName; | |||
private String iasDescriptorName; | |||
/* | |||
* The displayName variable stores the value of the "display-name" element | |||
* from the standard EJB descriptor. As a future enhancement to this task, | |||
* we may determine the name of the EJB JAR file using this display-name, | |||
* but this has not be implemented yet. | |||
*/ | |||
private String displayName; | |||
/* | |||
* Regardless of the name of the iAS-specific EJB descriptor file, it will | |||
* written in the completed JAR file as "ias-ejb-jar.xml". This is the | |||
* naming convention implemented by iAS. | |||
*/ | |||
private static final String IAS_DD = "ias-ejb-jar.xml"; | |||
/** | |||
* Setter method used to store the "home" directory of the user's iAS | |||
* installation. The directory specified should typically be | |||
* <code>[install-location]/iplanet/ias6/ias</code>. | |||
* | |||
* installation. The directory specified should typically be | |||
* <code>[install-location]/iplanet/ias6/ias</code>. | |||
* | |||
* @param iashome The home directory for the user's iAS installation. | |||
*/ | |||
public void setIashome(File iashome) { | |||
this.iashome = iashome; | |||
} | |||
public void setIashome(File iashome) { | |||
this.iashome = iashome; | |||
} | |||
/** | |||
* Setter method used to specify whether the Java source files generated by | |||
* the ejbc utility should be saved or automatically deleted. | |||
* | |||
* | |||
* @param keepgenerated boolean which, if <code>true</code>, indicates that | |||
* Java source files generated by ejbc for the stubs | |||
* and skeletons should be kept. | |||
* Java source files generated by ejbc for the stubs | |||
* and skeletons should be kept. | |||
*/ | |||
public void setKeepgenerated(boolean keepgenerated) { | |||
this.keepgenerated = keepgenerated; | |||
} | |||
public void setKeepgenerated(boolean keepgenerated) { | |||
this.keepgenerated = keepgenerated; | |||
} | |||
/** | |||
* Sets whether or not debugging output will be generated when ejbc is | |||
* executed. | |||
* | |||
* @param debug A boolean indicating if debugging output should be generated | |||
* executed. | |||
* | |||
* @param debug A boolean indicating if debugging output should be generated | |||
*/ | |||
public void setDebug(boolean debug) { | |||
this.debug = debug; | |||
} | |||
public void setDebug(boolean debug) { | |||
this.debug = debug; | |||
} | |||
/** | |||
* Setter method used to specify the filename suffix (for example, ".jar") | |||
* for the JAR files to be created. | |||
* | |||
* for the JAR files to be created. | |||
* | |||
* @param jarSuffix The string to use as the JAR filename suffix. | |||
*/ | |||
public void setSuffix(String jarSuffix) { | |||
this.jarSuffix = jarSuffix; | |||
} | |||
/** | |||
/** | |||
* Since iAS doesn't generate a "generic" JAR as part of its processing, | |||
* this attribute is ignored and a warning message is displayed to the user. | |||
* | |||
* this attribute is ignored and a warning message is displayed to the user. | |||
* | |||
* @param inString the string to use as the suffix. This parameter is | |||
* ignored. | |||
* ignored. | |||
*/ | |||
public void setGenericJarSuffix(String inString) { | |||
log("Since a generic JAR file is not created during processing, the " | |||
+ "iPlanet Deployment Tool does not support the " | |||
+ "\"genericjarsuffix\" attribute. It will be ignored.", | |||
Project.MSG_WARN); | |||
+ "iPlanet Deployment Tool does not support the " | |||
+ "\"genericjarsuffix\" attribute. It will be ignored.", | |||
Project.MSG_WARN); | |||
} | |||
public void processDescriptor(String descriptorName, SAXParser saxParser) { | |||
this.descriptorName = descriptorName; | |||
public void processDescriptor(String descriptorName, SAXParser saxParser) { | |||
this.descriptorName = descriptorName; | |||
log("iPlanet Deployment Tool processing: " + descriptorName + " (and " | |||
+ getIasDescriptorName() + ")", Project.MSG_VERBOSE); | |||
log("iPlanet Deployment Tool processing: " + descriptorName + " (and " | |||
+ getIasDescriptorName() + ")", Project.MSG_VERBOSE); | |||
super.processDescriptor(descriptorName, saxParser); | |||
} | |||
super.processDescriptor(descriptorName, saxParser); | |||
} | |||
/** | |||
* Verifies that the user selections are valid. | |||
* | |||
* @param descriptorFileName String representing the file name of an EJB | |||
* descriptor to be processed | |||
* @param saxParser SAXParser which may be used to parse the XML | |||
* descriptor | |||
* @throws BuildException If the user selections are invalid. | |||
* | |||
* @param descriptorFileName String representing the file name of an EJB | |||
* descriptor to be processed | |||
* @param saxParser SAXParser which may be used to parse the XML | |||
* descriptor | |||
* @throws BuildException If the user selections are invalid. | |||
*/ | |||
protected void checkConfiguration(String descriptorFileName, | |||
SAXParser saxParser) throws BuildException { | |||
int startOfName = descriptorFileName.lastIndexOf(File.separatorChar) + 1; | |||
String stdXml = descriptorFileName.substring(startOfName); | |||
if (stdXml.equals(EJB_DD) && (getConfig().baseJarName == null)) { | |||
String msg = "No name specified for the completed JAR file. The EJB" | |||
+ " descriptor should be prepended with the JAR " | |||
+ "name or it should be specified using the " | |||
+ "attribute \"basejarname\" in the \"ejbjar\" task."; | |||
throw new BuildException(msg, getLocation()); | |||
} | |||
File iasDescriptor = new File(getConfig().descriptorDir, | |||
getIasDescriptorName()); | |||
if ((!iasDescriptor.exists()) || (!iasDescriptor.isFile())) { | |||
String msg = "The iAS-specific EJB descriptor (" | |||
+ iasDescriptor + ") was not found."; | |||
throw new BuildException(msg, getLocation()); | |||
} | |||
if ((iashome != null) && (!iashome.isDirectory())) { | |||
String msg = "If \"iashome\" is specified, it must be a valid " | |||
+ "directory (it was set to " + iashome + ")."; | |||
throw new BuildException(msg, getLocation()); | |||
} | |||
} | |||
/** | |||
* This method returns a list of EJB files found when the specified EJB | |||
* descriptor is parsed and processed. | |||
* | |||
* @param descriptorFileName String representing the file name of an EJB | |||
* descriptor to be processed | |||
* @param saxParser SAXParser which may be used to parse the XML | |||
* descriptor | |||
* @return Hashtable of EJB class (and other) files to be | |||
* added to the completed JAR file | |||
protected void checkConfiguration(String descriptorFileName, | |||
SAXParser saxParser) throws BuildException { | |||
int startOfName = descriptorFileName.lastIndexOf(File.separatorChar) + 1; | |||
String stdXml = descriptorFileName.substring(startOfName); | |||
if (stdXml.equals(EJB_DD) && (getConfig().baseJarName == null)) { | |||
String msg = "No name specified for the completed JAR file. The EJB" | |||
+ " descriptor should be prepended with the JAR " | |||
+ "name or it should be specified using the " | |||
+ "attribute \"basejarname\" in the \"ejbjar\" task."; | |||
throw new BuildException(msg, getLocation()); | |||
} | |||
File iasDescriptor = new File(getConfig().descriptorDir, | |||
getIasDescriptorName()); | |||
if ((!iasDescriptor.exists()) || (!iasDescriptor.isFile())) { | |||
String msg = "The iAS-specific EJB descriptor (" | |||
+ iasDescriptor + ") was not found."; | |||
throw new BuildException(msg, getLocation()); | |||
} | |||
if ((iashome != null) && (!iashome.isDirectory())) { | |||
String msg = "If \"iashome\" is specified, it must be a valid " | |||
+ "directory (it was set to " + iashome + ")."; | |||
throw new BuildException(msg, getLocation()); | |||
} | |||
} | |||
/** | |||
* This method returns a list of EJB files found when the specified EJB | |||
* descriptor is parsed and processed. | |||
* | |||
* @param descriptorFileName String representing the file name of an EJB | |||
* descriptor to be processed | |||
* @param saxParser SAXParser which may be used to parse the XML | |||
* descriptor | |||
* @return Hashtable of EJB class (and other) files to be | |||
* added to the completed JAR file | |||
* @throws IOException An IOException from the parser, possibly from | |||
* the byte stream or character stream | |||
* @throws SAXException Any SAX exception, possibly wrapping another | |||
* exception | |||
*/ | |||
protected Hashtable parseEjbFiles(String descriptorFileName, | |||
SAXParser saxParser) throws IOException, SAXException { | |||
Hashtable files; | |||
/* Build and populate an instance of the ejbc utility */ | |||
IPlanetEjbc ejbc = new IPlanetEjbc( | |||
new File(getConfig().descriptorDir, | |||
descriptorFileName), | |||
new File(getConfig().descriptorDir, | |||
getIasDescriptorName()), | |||
getConfig().srcDir, | |||
getCombinedClasspath().toString(), | |||
saxParser); | |||
ejbc.setRetainSource(keepgenerated); | |||
ejbc.setDebugOutput(debug); | |||
if (iashome != null) { | |||
ejbc.setIasHomeDir(iashome); | |||
} | |||
/* Execute the ejbc utility -- stubs/skeletons are rebuilt, if needed */ | |||
try { | |||
ejbc.execute(); | |||
} catch (IPlanetEjbc.EjbcException e) { | |||
throw new BuildException("An error has occurred while trying to " | |||
+ "execute the iAS ejbc utility", e, getLocation()); | |||
} | |||
displayName = ejbc.getDisplayName(); | |||
files = ejbc.getEjbFiles(); | |||
/* Add CMP descriptors to the list of EJB files */ | |||
String[] cmpDescriptors = ejbc.getCmpDescriptors(); | |||
if (cmpDescriptors.length > 0) { | |||
File baseDir = getConfig().descriptorDir; | |||
int endOfPath = descriptorFileName.lastIndexOf(File.separator); | |||
String relativePath = descriptorFileName.substring(0, endOfPath + 1); | |||
for (int i = 0; i < cmpDescriptors.length; i++) { | |||
int endOfCmp = cmpDescriptors[i].lastIndexOf('/'); | |||
String cmpDescriptor = cmpDescriptors[i].substring(endOfCmp + 1); | |||
File cmpFile = new File(baseDir, relativePath + cmpDescriptor); | |||
if (!cmpFile.exists()) { | |||
throw new BuildException("The CMP descriptor file (" | |||
+ cmpFile + ") could not be found.", getLocation()); | |||
} | |||
files.put(cmpDescriptors[i], cmpFile); | |||
} | |||
} | |||
return files; | |||
} | |||
* the byte stream or character stream | |||
* @throws SAXException Any SAX exception, possibly wrapping another | |||
* exception | |||
*/ | |||
protected Hashtable parseEjbFiles(String descriptorFileName, | |||
SAXParser saxParser) throws IOException, SAXException { | |||
Hashtable files; | |||
/* Build and populate an instance of the ejbc utility */ | |||
IPlanetEjbc ejbc = new IPlanetEjbc( | |||
new File(getConfig().descriptorDir, | |||
descriptorFileName), | |||
new File(getConfig().descriptorDir, | |||
getIasDescriptorName()), | |||
getConfig().srcDir, | |||
getCombinedClasspath().toString(), | |||
saxParser); | |||
ejbc.setRetainSource(keepgenerated); | |||
ejbc.setDebugOutput(debug); | |||
if (iashome != null) { | |||
ejbc.setIasHomeDir(iashome); | |||
} | |||
/* Execute the ejbc utility -- stubs/skeletons are rebuilt, if needed */ | |||
try { | |||
ejbc.execute(); | |||
} catch (IPlanetEjbc.EjbcException e) { | |||
throw new BuildException("An error has occurred while trying to " | |||
+ "execute the iAS ejbc utility", e, getLocation()); | |||
} | |||
displayName = ejbc.getDisplayName(); | |||
files = ejbc.getEjbFiles(); | |||
/* Add CMP descriptors to the list of EJB files */ | |||
String[] cmpDescriptors = ejbc.getCmpDescriptors(); | |||
if (cmpDescriptors.length > 0) { | |||
File baseDir = getConfig().descriptorDir; | |||
int endOfPath = descriptorFileName.lastIndexOf(File.separator); | |||
String relativePath = descriptorFileName.substring(0, endOfPath + 1); | |||
for (int i = 0; i < cmpDescriptors.length; i++) { | |||
int endOfCmp = cmpDescriptors[i].lastIndexOf('/'); | |||
String cmpDescriptor = cmpDescriptors[i].substring(endOfCmp + 1); | |||
File cmpFile = new File(baseDir, relativePath + cmpDescriptor); | |||
if (!cmpFile.exists()) { | |||
throw new BuildException("The CMP descriptor file (" | |||
+ cmpFile + ") could not be found.", getLocation()); | |||
} | |||
files.put(cmpDescriptors[i], cmpFile); | |||
} | |||
} | |||
return files; | |||
} | |||
/** | |||
* Add the iAS-specific EJB descriptor to the list of files which will be | |||
* written to the JAR file. | |||
* | |||
* @param ejbFiles Hashtable of EJB class (and other) files to be added to | |||
* the completed JAR file. | |||
* @param baseName String name of the EJB JAR file to be written (without | |||
* a filename extension). | |||
* written to the JAR file. | |||
* | |||
* @param ejbFiles Hashtable of EJB class (and other) files to be added to | |||
* the completed JAR file. | |||
* @param baseName String name of the EJB JAR file to be written (without | |||
* a filename extension). | |||
*/ | |||
protected void addVendorFiles(Hashtable ejbFiles, String baseName) { | |||
ejbFiles.put(META_DIR + IAS_DD, new File(getConfig().descriptorDir, | |||
getIasDescriptorName())); | |||
} | |||
protected void addVendorFiles(Hashtable ejbFiles, String baseName, String descriptorFileName) { | |||
ejbFiles.put(META_DIR + IAS_DD, new File(getConfig().descriptorDir, | |||
getIasDescriptorName())); | |||
} | |||
/** | |||
* Get the name of the Jar that will be written. The modification date | |||
* of this jar will be checked against the dependent bean classes. | |||
* | |||
* @param baseName String name of the EJB JAR file to be written (without | |||
* a filename extension). | |||
* | |||
* @return File representing the JAR file which will be written. | |||
* | |||
* @param baseName String name of the EJB JAR file to be written (without | |||
* a filename extension). | |||
* | |||
* @return File representing the JAR file which will be written. | |||
*/ | |||
File getVendorOutputJarFile(String baseName) { | |||
File jarFile = new File(getDestDir(), baseName + jarSuffix); | |||
log("JAR file name: " + jarFile.toString(), Project.MSG_VERBOSE); | |||
File jarFile = new File(getDestDir(), baseName + jarSuffix); | |||
log("JAR file name: " + jarFile.toString(), Project.MSG_VERBOSE); | |||
return jarFile; | |||
} | |||
/** | |||
* The iAS ejbc utility doesn't require the Public ID of the descriptor's | |||
* DTD for it to process correctly--this method always returns <code>null | |||
* </code>. | |||
* | |||
* @return <code>null</code>. | |||
*/ | |||
protected String getPublicId() { | |||
return null; | |||
} | |||
/** | |||
* Determines the name of the iAS-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]-ias-ejb-jar.xml". | |||
* | |||
* @return The name of the iAS-specific EJB descriptor file. | |||
*/ | |||
private String getIasDescriptorName() { | |||
/* Only calculate the descriptor name once */ | |||
if (iasDescriptorName != null) { | |||
return iasDescriptorName; | |||
} | |||
String path = ""; // Directory path of the EJB descriptor | |||
String basename; // Filename appearing before name terminator | |||
String remainder; // Filename appearing after the name terminator | |||
/* Find the end of the standard descriptor's relative path */ | |||
int startOfFileName = descriptorName.lastIndexOf(File.separatorChar); | |||
if (startOfFileName != -1) { | |||
path = descriptorName.substring(0, startOfFileName + 1); | |||
} | |||
/* Check to see if the standard name is used (there's no basename) */ | |||
if (descriptorName.substring(startOfFileName + 1).equals(EJB_DD)) { | |||
basename = ""; | |||
remainder = EJB_DD; | |||
} else { | |||
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 "ias-" appears at the | |||
* end of the name and before the '.' (if present). | |||
*/ | |||
if (endOfBaseName < 0) { | |||
endOfBaseName = descriptorName.lastIndexOf('.') - 1; | |||
if (endOfBaseName < 0) { | |||
endOfBaseName = descriptorName.length() - 1; | |||
} | |||
} | |||
basename = descriptorName.substring(startOfFileName + 1, | |||
endOfBaseName + 1); | |||
remainder = descriptorName.substring(endOfBaseName + 1); | |||
} | |||
iasDescriptorName = path + basename + "ias-" + remainder; | |||
return iasDescriptorName; | |||
} | |||
/** | |||
* The iAS ejbc utility doesn't require the Public ID of the descriptor's | |||
* DTD for it to process correctly--this method always returns <code>null | |||
* </code>. | |||
* | |||
* @return <code>null</code>. | |||
*/ | |||
protected String getPublicId() { | |||
return null; | |||
} | |||
/** | |||
* Determines the name of the iAS-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]-ias-ejb-jar.xml". | |||
* | |||
* @return The name of the iAS-specific EJB descriptor file. | |||
*/ | |||
private String getIasDescriptorName() { | |||
/* Only calculate the descriptor name once */ | |||
if (iasDescriptorName != null) { | |||
return iasDescriptorName; | |||
} | |||
String path = ""; // Directory path of the EJB descriptor | |||
String basename; // Filename appearing before name terminator | |||
String remainder; // Filename appearing after the name terminator | |||
/* Find the end of the standard descriptor's relative path */ | |||
int startOfFileName = descriptorName.lastIndexOf(File.separatorChar); | |||
if (startOfFileName != -1) { | |||
path = descriptorName.substring(0, startOfFileName + 1); | |||
} | |||
/* Check to see if the standard name is used (there's no basename) */ | |||
if (descriptorName.substring(startOfFileName + 1).equals(EJB_DD)) { | |||
basename = ""; | |||
remainder = EJB_DD; | |||
} else { | |||
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 "ias-" appears at the | |||
* end of the name and before the '.' (if present). | |||
*/ | |||
if (endOfBaseName < 0) { | |||
endOfBaseName = descriptorName.lastIndexOf('.') - 1; | |||
if (endOfBaseName < 0) { | |||
endOfBaseName = descriptorName.length() - 1; | |||
} | |||
} | |||
basename = descriptorName.substring(startOfFileName + 1, | |||
endOfBaseName + 1); | |||
remainder = descriptorName.substring(endOfBaseName + 1); | |||
} | |||
iasDescriptorName = path + basename + "ias-" + remainder; | |||
return iasDescriptorName; | |||
} | |||
} |
@@ -77,7 +77,7 @@ public class JbossDeploymentTool extends GenericDeploymentTool { | |||
* Add any vendor specific files which should be included in the | |||
* EJB Jar. | |||
*/ | |||
protected void addVendorFiles(Hashtable ejbFiles, String baseName) { | |||
protected void addVendorFiles(Hashtable ejbFiles, String baseName, String descriptorFileName) { | |||
String ddPrefix = (usingBaseJarName() ? "" : baseName + getConfig().baseNameTerminator); | |||
File jbossDD = new File(getConfig().descriptorDir, ddPrefix + JBOSS_DD); | |||
@@ -297,9 +297,21 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool { | |||
* Add any vendor specific files which should be included in the | |||
* EJB Jar. | |||
*/ | |||
protected void addVendorFiles(Hashtable ejbFiles, String baseName) { | |||
String ddPrefix = (usingBaseJarName() ? "" : baseName + getConfig().baseNameTerminator); | |||
protected void addVendorFiles(Hashtable ejbFiles, String baseName, String descriptorFileName) { | |||
String ddPrefix = null; | |||
if (!usingBaseJarName()) { | |||
ddPrefix = baseName + getConfig().baseNameTerminator; | |||
} | |||
else { | |||
String canonicalDescriptor = descriptorFileName.replace('\\', '/'); | |||
int index = canonicalDescriptor.lastIndexOf('/'); | |||
if (index == -1) { | |||
ddPrefix = ""; | |||
} | |||
else { | |||
ddPrefix = descriptorFileName.substring(0, index + 1); | |||
} | |||
} | |||
File weblogicDD = new File(getConfig().descriptorDir, ddPrefix + WL_DD); | |||
if (weblogicDD.exists()) { | |||
@@ -102,8 +102,8 @@ public class WeblogicTOPLinkDeploymentTool extends WeblogicDeploymentTool { | |||
* Add any vendor specific files which should be included in the | |||
* EJB Jar. | |||
*/ | |||
protected void addVendorFiles(Hashtable ejbFiles, String baseName) { | |||
super.addVendorFiles(ejbFiles, baseName); | |||
protected void addVendorFiles(Hashtable ejbFiles, String baseName, String descriptorFileName) { | |||
super.addVendorFiles(ejbFiles, baseName, descriptorFileName); | |||
// Then the toplink deployment descriptor | |||
// Setup a naming standard here?. | |||