git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274841 13f79535-47bb-0310-9956-ffa450edef68master
@@ -80,14 +80,14 @@ import org.apache.tools.ant.util.FileUtils; | |||
public class AntClassLoader2 extends AntClassLoader { | |||
/** Instance of a utility class to use for file operations. */ | |||
private FileUtils fileUtils; | |||
/** | |||
* Constructor | |||
*/ | |||
public AntClassLoader2() { | |||
fileUtils = FileUtils.newFileUtils(); | |||
} | |||
/** | |||
* Define a class given its bytes | |||
* | |||
@@ -107,11 +107,11 @@ public class AntClassLoader2 extends AntClassLoader { | |||
definePackage(container, className); | |||
return defineClass(className, classData, 0, classData.length, | |||
Project.class.getProtectionDomain()); | |||
} | |||
/** | |||
* Get the manifest from the given jar, if it is indeed a jar and it has a | |||
* Get the manifest from the given jar, if it is indeed a jar and it has a | |||
* manifest | |||
* | |||
* @param container the File from which a manifest is required. | |||
@@ -135,50 +135,50 @@ public class AntClassLoader2 extends AntClassLoader { | |||
} | |||
} | |||
} | |||
/** | |||
* Define the package information associated with a class. | |||
* | |||
* @param container the file containing the class definition. | |||
* @param className the class name of for which the package information | |||
* is to be determined. | |||
* | |||
* | |||
* @exception IOException if the package information cannot be read from the | |||
* container. | |||
*/ | |||
protected void definePackage(File container, String className) | |||
*/ | |||
protected void definePackage(File container, String className) | |||
throws IOException { | |||
int classIndex = className.lastIndexOf('.'); | |||
if (classIndex == -1) { | |||
return; | |||
} | |||
String packageName = className.substring(0, classIndex); | |||
if (getPackage(packageName) != null) { | |||
// already defined | |||
// already defined | |||
return; | |||
} | |||
// define the package now | |||
// define the package now | |||
Manifest manifest = getJarManifest(container); | |||
if (manifest == null) { | |||
definePackage(packageName, null, null, null, null, null, | |||
definePackage(packageName, null, null, null, null, null, | |||
null, null); | |||
} else { | |||
definePackage(container, packageName, manifest); | |||
} | |||
} | |||
/** | |||
* Define the package information when the class comes from a | |||
* Define the package information when the class comes from a | |||
* jar with a manifest | |||
* | |||
* @param container the jar file containing the manifest | |||
* @param packageName the name of the package being defined. | |||
* @param manifest the jar's manifest | |||
*/ | |||
protected void definePackage(File container, String packageName, | |||
protected void definePackage(File container, String packageName, | |||
Manifest manifest) { | |||
String sectionName = packageName.replace('.', '/') + "/"; | |||
@@ -190,57 +190,57 @@ public class AntClassLoader2 extends AntClassLoader { | |||
String implementationVersion = null; | |||
String sealedString = null; | |||
URL sealBase = null; | |||
Attributes sectionAttributes = manifest.getAttributes(sectionName); | |||
if (sectionAttributes != null) { | |||
specificationTitle | |||
specificationTitle | |||
= sectionAttributes.getValue(Name.SPECIFICATION_TITLE); | |||
specificationVendor | |||
specificationVendor | |||
= sectionAttributes.getValue(Name.SPECIFICATION_VENDOR); | |||
specificationVersion | |||
specificationVersion | |||
= sectionAttributes.getValue(Name.SPECIFICATION_VERSION); | |||
implementationTitle | |||
implementationTitle | |||
= sectionAttributes.getValue(Name.IMPLEMENTATION_TITLE); | |||
implementationVendor | |||
implementationVendor | |||
= sectionAttributes.getValue(Name.IMPLEMENTATION_VENDOR); | |||
implementationVersion | |||
implementationVersion | |||
= sectionAttributes.getValue(Name.IMPLEMENTATION_VERSION); | |||
sealedString | |||
sealedString | |||
= sectionAttributes.getValue(Name.SEALED); | |||
} | |||
Attributes mainAttributes = manifest.getMainAttributes(); | |||
if (mainAttributes != null) { | |||
if (specificationTitle == null) { | |||
specificationTitle | |||
specificationTitle | |||
= mainAttributes.getValue(Name.SPECIFICATION_TITLE); | |||
} | |||
if (specificationVendor == null) { | |||
specificationVendor | |||
specificationVendor | |||
= mainAttributes.getValue(Name.SPECIFICATION_VENDOR); | |||
} | |||
if (specificationVersion == null) { | |||
specificationVersion | |||
specificationVersion | |||
= mainAttributes.getValue(Name.SPECIFICATION_VERSION); | |||
} | |||
if (implementationTitle == null) { | |||
implementationTitle | |||
implementationTitle | |||
= mainAttributes.getValue(Name.IMPLEMENTATION_TITLE); | |||
} | |||
if (implementationVendor == null) { | |||
implementationVendor | |||
implementationVendor | |||
= mainAttributes.getValue(Name.IMPLEMENTATION_VENDOR); | |||
} | |||
if (implementationVersion == null) { | |||
implementationVersion | |||
implementationVersion | |||
= mainAttributes.getValue(Name.IMPLEMENTATION_VERSION); | |||
} | |||
if (sealedString == null) { | |||
sealedString | |||
sealedString | |||
= mainAttributes.getValue(Name.SEALED); | |||
} | |||
} | |||
if (sealedString != null && sealedString.equalsIgnoreCase("true")) { | |||
try { | |||
sealBase = new URL("file:" + container.getPath()); | |||
@@ -248,15 +248,15 @@ public class AntClassLoader2 extends AntClassLoader { | |||
// ignore | |||
} | |||
} | |||
definePackage(packageName, specificationTitle, specificationVersion, | |||
specificationVendor, implementationTitle, | |||
definePackage(packageName, specificationTitle, specificationVersion, | |||
specificationVendor, implementationTitle, | |||
implementationVersion, implementationVendor, sealBase); | |||
} | |||
/** | |||
* Add a file to the path. This classloader reads the manifest, if | |||
* Add a file to the path. This classloader reads the manifest, if | |||
* available, and adds any additional class path jars specified in the | |||
* manifest. | |||
* | |||
@@ -267,29 +267,29 @@ public class AntClassLoader2 extends AntClassLoader { | |||
*/ | |||
protected void addPathFile(File pathComponent) throws IOException { | |||
super.addPathFile(pathComponent); | |||
if (pathComponent.isDirectory()) { | |||
return; | |||
} | |||
String classpath = null; | |||
ZipFile jarFile = null; | |||
InputStream manifestStream = null; | |||
try { | |||
jarFile = new ZipFile(pathComponent); | |||
manifestStream | |||
manifestStream | |||
= jarFile.getInputStream(new ZipEntry("META-INF/MANIFEST.MF")); | |||
if (manifestStream == null) { | |||
return; | |||
} | |||
Reader manifestReader | |||
} | |||
Reader manifestReader | |||
= new InputStreamReader(manifestStream, "UTF-8"); | |||
org.apache.tools.ant.taskdefs.Manifest manifest | |||
= new org.apache.tools.ant.taskdefs.Manifest(manifestReader); | |||
classpath | |||
classpath | |||
= manifest.getMainSection().getAttributeValue("Class-Path"); | |||
} catch (org.apache.tools.ant.taskdefs.ManifestException e) { | |||
// ignore | |||
} finally { | |||
@@ -300,7 +300,7 @@ public class AntClassLoader2 extends AntClassLoader { | |||
jarFile.close(); | |||
} | |||
} | |||
if (classpath != null) { | |||
URL baseURL = fileUtils.getFileURL(pathComponent); | |||
StringTokenizer st = new StringTokenizer(classpath); | |||
@@ -308,7 +308,7 @@ public class AntClassLoader2 extends AntClassLoader { | |||
String classpathElement = st.nextToken(); | |||
URL libraryURL = new URL(baseURL, classpathElement); | |||
if (!libraryURL.getProtocol().equals("file")) { | |||
log("Skipping jar library " + classpathElement | |||
log("Skipping jar library " + classpathElement | |||
+ " since only relative URLs are supported by this" | |||
+ " loader", Project.MSG_VERBOSE); | |||
continue; | |||
@@ -460,7 +460,7 @@ public abstract class Definer extends Task { | |||
/** | |||
* Set the classname of the class that the definition | |||
* must be compatible with, either directly or | |||
* by use of the adapeter class. | |||
* by use of the adapter class. | |||
* | |||
* @param adaptTo the name of the adaptto class | |||
*/ | |||
@@ -99,14 +99,14 @@ public class FieldRefCPInfo extends ConstantPoolEntry { | |||
* and against which this entry is to be resolved. | |||
*/ | |||
public void resolve(ConstantPool constantPool) { | |||
ClassCPInfo fieldClass | |||
ClassCPInfo fieldClass | |||
= (ClassCPInfo) constantPool.getEntry(classIndex); | |||
fieldClass.resolve(constantPool); | |||
fieldClassName = fieldClass.getClassName(); | |||
NameAndTypeCPInfo nt | |||
NameAndTypeCPInfo nt | |||
= (NameAndTypeCPInfo) constantPool.getEntry(nameAndTypeIndex); | |||
nt.resolve(constantPool); | |||
@@ -126,10 +126,10 @@ public class FieldRefCPInfo extends ConstantPoolEntry { | |||
String value; | |||
if (isResolved()) { | |||
value = "Field : Class = " + fieldClassName + ", name = " | |||
value = "Field : Class = " + fieldClassName + ", name = " | |||
+ fieldName + ", type = " + fieldType; | |||
} else { | |||
value = "Field : Class index = " + classIndex | |||
value = "Field : Class index = " + classIndex | |||
+ ", name and type index = " + nameAndTypeIndex; | |||
} | |||
@@ -418,7 +418,7 @@ public class BorlandDeploymentTool extends GenericDeploymentTool implements Exe | |||
//debug ? | |||
if (java2iiopdebug) { | |||
commandline.createArgument().setValue("-VBJdebug"); | |||
} | |||
} | |||
//set the classpath | |||
commandline.createArgument().setValue("-VBJclasspath"); | |||
commandline.createArgument().setPath(getCombinedClasspath()); | |||
@@ -426,12 +426,12 @@ public class BorlandDeploymentTool extends GenericDeploymentTool implements Exe | |||
commandline.createArgument().setValue("-list_files"); | |||
//no TIE classes | |||
commandline.createArgument().setValue("-no_tie"); | |||
if ( java2iioparams != null) { | |||
log("additional "+java2iioparams +" to java2iiop " ,0); | |||
commandline.createArgument().setValue(java2iioparams); | |||
commandline.createArgument().setValue(java2iioparams); | |||
} | |||
//root dir | |||
commandline.createArgument().setValue("-root_dir"); | |||
@@ -441,7 +441,7 @@ public class BorlandDeploymentTool extends GenericDeploymentTool implements Exe | |||
//add the home class | |||
while (ithomes.hasNext()) { | |||
commandline.createArgument().setValue(ithomes.next().toString()); | |||
} | |||
} | |||
try { | |||
log("Calling java2iiop", Project.MSG_VERBOSE); | |||
@@ -476,8 +476,8 @@ public class BorlandDeploymentTool extends GenericDeploymentTool implements Exe | |||
String home = toClass(clazz); | |||
homes.add(home); | |||
log(" Home " + home, Project.MSG_VERBOSE); | |||
} | |||
} | |||
} | |||
} | |||
buildBorlandStubs(homes.iterator()); | |||
@@ -537,8 +537,8 @@ public class BorlandDeploymentTool extends GenericDeploymentTool implements Exe | |||
String classfile = toClassFile(javafile); | |||
String key = classfile.substring(getConfig().srcDir.getAbsolutePath().length() + 1); | |||
_genfiles.put(key, new File(classfile)); | |||
} | |||
} | |||
} | |||
} | |||
reader.close(); | |||
} catch (Exception e) { | |||
String msg = "Exception while parsing java2iiop output. Details: " + e.toString(); | |||
@@ -551,7 +551,7 @@ public class BorlandDeploymentTool extends GenericDeploymentTool implements Exe | |||
String s = reader.readLine(); | |||
if (s != null) { | |||
log("[java2iiop] " + s, Project.MSG_ERR); | |||
} | |||
} | |||
} | |||
} | |||
@@ -1,7 +1,7 @@ | |||
/* | |||
* The Apache Software License, Version 1.1 | |||
* | |||
* Copyright (c) 2000,2002 The Apache Software Foundation. All rights | |||
* Copyright (c) 2000,2002 The Apache Software Foundation. All rights | |||
* reserved. | |||
* | |||
* Redistribution and use in source and binary forms, with or without | |||
@@ -76,19 +76,19 @@ public class DDCreator extends MatchingTask { | |||
* on the EJBC task, as supported by the MatchingTask superclass. | |||
*/ | |||
private File descriptorDirectory; | |||
/** | |||
* The directory where generated serialised deployment descriptors are placed. | |||
*/ | |||
private File generatedFilesDirectory; | |||
/** | |||
* The classpath to be used in the weblogic ejbc calls. It must contain the weblogic | |||
* classes necessary fro DDCreator <b>and</b> the implementation classes of the | |||
* classes necessary fro DDCreator <b>and</b> the implementation classes of the | |||
* home and remote interfaces. | |||
*/ | |||
private String classpath; | |||
/** | |||
* Do the work. | |||
* | |||
@@ -103,26 +103,26 @@ public class DDCreator extends MatchingTask { | |||
public void execute() throws BuildException { | |||
if (descriptorDirectory == null || | |||
!descriptorDirectory.isDirectory()) { | |||
throw new BuildException("descriptors directory " + descriptorDirectory.getPath() + | |||
throw new BuildException("descriptors directory " + descriptorDirectory.getPath() + | |||
" is not valid"); | |||
} | |||
if (generatedFilesDirectory == null || | |||
!generatedFilesDirectory.isDirectory()) { | |||
throw new BuildException("dest directory " + generatedFilesDirectory.getPath() + | |||
throw new BuildException("dest directory " + generatedFilesDirectory.getPath() + | |||
" is not valid"); | |||
} | |||
String args = descriptorDirectory + " " + generatedFilesDirectory; | |||
// get all the files in the descriptor directory | |||
DirectoryScanner ds = super.getDirectoryScanner(descriptorDirectory); | |||
String[] files = ds.getIncludedFiles(); | |||
for (int i = 0; i < files.length; ++i) { | |||
args += " " + files[i]; | |||
} | |||
String systemClassPath = System.getProperty("java.class.path"); | |||
String execClassPath = getProject().translatePath(systemClassPath + ":" + classpath); | |||
Java ddCreatorTask = (Java) getProject().createTask("java"); | |||
@@ -132,7 +132,7 @@ public class DDCreator extends MatchingTask { | |||
Commandline.Argument arguments = ddCreatorTask.createArg(); | |||
arguments.setLine(args); | |||
ddCreatorTask.setClasspath(new Path(getProject(), execClassPath)); | |||
if (ddCreatorTask.executeJava() != 0) { | |||
if (ddCreatorTask.executeJava() != 0) { | |||
throw new BuildException("Execution of ddcreator helper failed"); | |||
} | |||
} | |||
@@ -146,7 +146,7 @@ public class DDCreator extends MatchingTask { | |||
public void setDescriptors(String dirName) { | |||
descriptorDirectory = new File(dirName); | |||
} | |||
/** | |||
* Set the directory into which the serialized deployment descriptors are to | |||
* be written. | |||
@@ -1,7 +1,7 @@ | |||
/* | |||
* The Apache Software License, Version 1.1 | |||
* | |||
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
* reserved. | |||
* | |||
* Redistribution and use in source and binary forms, with or without | |||
@@ -68,10 +68,10 @@ import javax.ejb.deployment.DeploymentDescriptor; | |||
*/ | |||
public class DDCreatorHelper { | |||
/** | |||
* The root directory of the tree containing the textual deployment desciptors. | |||
* The root directory of the tree containing the textual deployment desciptors. | |||
*/ | |||
private File descriptorDirectory; | |||
/** | |||
* The directory where generated serialised desployment descriptors are written. | |||
*/ | |||
@@ -80,19 +80,19 @@ public class DDCreatorHelper { | |||
/** | |||
* The descriptor text files for which a serialised descriptor is to be created. | |||
*/ | |||
String[] descriptors; | |||
String[] descriptors; | |||
/** | |||
* The main method. | |||
* | |||
* The main method creates an instance of the DDCreatorHelper, passing it the | |||
* The main method creates an instance of the DDCreatorHelper, passing it the | |||
* args which it then processes. | |||
*/ | |||
*/ | |||
public static void main(String[] args) throws Exception { | |||
DDCreatorHelper helper = new DDCreatorHelper(args); | |||
helper.process(); | |||
} | |||
/** | |||
* Initialise the helper with the command arguments. | |||
* | |||
@@ -101,20 +101,20 @@ public class DDCreatorHelper { | |||
int index = 0; | |||
descriptorDirectory = new File(args[index++]); | |||
generatedFilesDirectory = new File(args[index++]); | |||
descriptors = new String[args.length - index]; | |||
for (int i = 0; index < args.length; ++i) { | |||
descriptors[i] = args[index++]; | |||
} | |||
} | |||
/** | |||
* Do the actual work. | |||
* | |||
* The work proceeds by examining each descriptor given. If the serialised | |||
* file does not exist or is older than the text description, the weblogic | |||
* DDCreator tool is invoked directly to build the serialised descriptor. | |||
*/ | |||
*/ | |||
private void process() throws Exception { | |||
for (int i = 0; i < descriptors.length; ++i) { | |||
String descriptorName = descriptors[i]; | |||
@@ -128,12 +128,12 @@ public class DDCreatorHelper { | |||
serName = descriptorName + ".ser"; | |||
} | |||
File serFile = new File(generatedFilesDirectory, serName); | |||
// do we need to regenerate the file | |||
if (!serFile.exists() || serFile.lastModified() < descriptorFile.lastModified() | |||
|| regenerateSerializedFile(serFile)) { | |||
String[] args = {"-noexit", | |||
String[] args = {"-noexit", | |||
"-d", serFile.getParent(), | |||
"-outputfile", serFile.getName(), | |||
descriptorFile.getPath()}; | |||
@@ -168,8 +168,8 @@ public class DDCreatorHelper { | |||
return false; | |||
} catch (Exception e) { | |||
// Weblogic will throw an error if the deployment descriptor does | |||
// Weblogic will throw an error if the deployment descriptor does | |||
// not match the class files. | |||
return true; | |||
@@ -164,7 +164,7 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase { | |||
// resolve relative to project basedir | |||
fileDTD = owningTask.getProject().resolveFile(location); | |||
} | |||
if (fileDTD.exists()) { | |||
if (publicId != null) { | |||
fileDTDs.put(publicId, fileDTD); | |||
@@ -341,7 +341,7 @@ public class DescriptorHandler extends org.xml.sax.HandlerBase { | |||
protected void processElement() { | |||
if (inEJBRef || | |||
if (inEJBRef || | |||
(parseState != STATE_IN_ENTITY && parseState != STATE_IN_SESSION && parseState != STATE_IN_MESSAGE)) { | |||
return; | |||
} | |||
@@ -67,11 +67,11 @@ public interface EJBDeploymentTool { | |||
* deployment files. | |||
* | |||
* @param descriptorFilename the name of the deployment descriptor | |||
* @param saxParser a SAX parser which can be used to parse the deployment descriptor. | |||
* @param saxParser a SAX parser which can be used to parse the deployment descriptor. | |||
*/ | |||
void processDescriptor(String descriptorFilename, SAXParser saxParser) | |||
void processDescriptor(String descriptorFilename, SAXParser saxParser) | |||
throws BuildException; | |||
/** | |||
* Called to validate that the tool parameters have been configured. | |||
* | |||
@@ -82,9 +82,9 @@ public interface EJBDeploymentTool { | |||
* Set the task which owns this tool | |||
*/ | |||
void setTask(Task task); | |||
/** | |||
* Configure this tool for use in the ejbjar task. | |||
*/ | |||
void configure(EjbJar.Config config); | |||
void configure(EjbJar.Config config); | |||
} |
@@ -464,7 +464,7 @@ public class EjbJar extends MatchingTask { | |||
/** | |||
* Gets the destination directory. | |||
* | |||
* | |||
* @return destination directory | |||
* @since ant 1.6 | |||
*/ | |||
@@ -488,7 +488,7 @@ public class EjbJar extends MatchingTask { | |||
/** | |||
* Gets the CMP version. | |||
* | |||
* | |||
* @return CMP version | |||
* @since ant 1.6 | |||
*/ | |||
@@ -498,7 +498,7 @@ public class EjbJar extends MatchingTask { | |||
/** | |||
* 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/> | |||
@@ -1,7 +1,7 @@ | |||
/* | |||
* The Apache Software License, Version 1.1 | |||
* | |||
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
* Copyright (c) 2000-2002 The Apache Software Foundation. All rights | |||
* reserved. | |||
* | |||
* Redistribution and use in source and binary forms, with or without | |||
@@ -74,26 +74,26 @@ import javax.ejb.deployment.EntityDescriptor; | |||
*/ | |||
public class EjbcHelper { | |||
/** | |||
* The root directory of the tree containing the serialised deployment desciptors. | |||
* The root directory of the tree containing the serialised deployment desciptors. | |||
*/ | |||
private File descriptorDirectory; | |||
/** | |||
* The directory where generated files are placed. | |||
*/ | |||
private File generatedFilesDirectory; | |||
/** | |||
* The name of the manifest file generated for the EJB jar. | |||
*/ | |||
private File manifestFile; | |||
/** | |||
* The source directory for the home and remote interfaces. This is used to determine if | |||
* the generated deployment classes are out of date. | |||
*/ | |||
private File sourceDirectory; | |||
/** | |||
* The names of the serialised deployment descriptors | |||
*/ | |||
@@ -103,15 +103,15 @@ public class EjbcHelper { | |||
/** | |||
* Command line interface for the ejbc helper task. | |||
*/ | |||
*/ | |||
public static void main(String[] args) throws Exception { | |||
EjbcHelper helper = new EjbcHelper(args); | |||
helper.process(); | |||
} | |||
/** | |||
* Initialise the EjbcHelper by reading the command arguments. | |||
*/ | |||
*/ | |||
private EjbcHelper(String[] args) { | |||
int index = 0; | |||
descriptorDirectory = new File(args[index++]); | |||
@@ -119,25 +119,25 @@ public class EjbcHelper { | |||
sourceDirectory = new File(args[index++]); | |||
manifestFile = new File(args[index++]); | |||
keepGenerated = Boolean.valueOf(args[index++]).booleanValue(); | |||
descriptors = new String[args.length - index]; | |||
for (int i = 0; index < args.length; ++i) { | |||
descriptors[i] = args[index++]; | |||
} | |||
} | |||
private String[] getCommandLine(boolean debug, File descriptorFile) { | |||
Vector v = new Vector(); | |||
if (!debug) { | |||
v.addElement("-noexit"); | |||
} | |||
if (keepGenerated) { | |||
v.addElement("-keepgenerated"); | |||
v.addElement("-keepgenerated"); | |||
} | |||
v.addElement("-d"); | |||
v.addElement(generatedFilesDirectory.getPath()); | |||
v.addElement(descriptorFile.getPath()); | |||
String[] args = new String[v.size()]; | |||
v.copyInto(args); | |||
return args; | |||
@@ -148,7 +148,7 @@ public class EjbcHelper { | |||
* for a given deployment descriptor. | |||
* | |||
* This process attempts to determine if the support classes need to be | |||
* rebuilt. It does this by examining only some of the support classes | |||
* rebuilt. It does this by examining only some of the support classes | |||
* which are typically generated. If the ejbc task is interrupted generating | |||
* the support classes for a bean, all of the support classes should be removed | |||
* to force regeneration of the support classes. | |||
@@ -170,38 +170,38 @@ public class EjbcHelper { | |||
ObjectInputStream ois = new ObjectInputStream(fis); | |||
DeploymentDescriptor dd = (DeploymentDescriptor) ois.readObject(); | |||
fis.close(); | |||
String homeInterfacePath = dd.getHomeInterfaceClassName().replace('.', '/') + ".java"; | |||
String remoteInterfacePath = dd.getRemoteInterfaceClassName().replace('.', '/') + ".java"; | |||
String primaryKeyClassPath = null; | |||
if (dd instanceof EntityDescriptor) { | |||
primaryKeyClassPath = ((EntityDescriptor) dd).getPrimaryKeyClassName().replace('.', '/') + ".java";; | |||
} | |||
File homeInterfaceSource = new File(sourceDirectory, homeInterfacePath); | |||
File remoteInterfaceSource = new File(sourceDirectory, remoteInterfacePath); | |||
File primaryKeyClassSource = null; | |||
if (primaryKeyClassPath != null) { | |||
primaryKeyClassSource = new File(sourceDirectory, remoteInterfacePath); | |||
} | |||
// are any of the above out of date. | |||
// are any of the above out of date. | |||
// we find the implementation classes and see if they are older than any | |||
// of the above or the .ser file itself. | |||
String beanClassBase = dd.getEnterpriseBeanClassName().replace('.', '/'); | |||
File ejbImplentationClass | |||
File ejbImplentationClass | |||
= new File(generatedFilesDirectory, beanClassBase + "EOImpl.class"); | |||
File homeImplementationClass | |||
File homeImplementationClass | |||
= new File(generatedFilesDirectory, beanClassBase + "HomeImpl.class"); | |||
File beanStubClass | |||
File beanStubClass | |||
= new File(generatedFilesDirectory, beanClassBase + "EOImpl_WLStub.class"); | |||
// if the implementation classes don;t exist regenerate | |||
// if the implementation classes don;t exist regenerate | |||
if (!ejbImplentationClass.exists() || !homeImplementationClass.exists() || | |||
!beanStubClass.exists()) { | |||
return true; | |||
} | |||
// Is the ser file or any of the source files newer then the class files. | |||
// firstly find the oldest of the two class files. | |||
long classModificationTime = ejbImplentationClass.lastModified(); | |||
@@ -211,14 +211,14 @@ public class EjbcHelper { | |||
if (beanStubClass.lastModified() < classModificationTime) { | |||
classModificationTime = beanStubClass.lastModified(); | |||
} | |||
if (descriptorFile.lastModified() > classModificationTime || | |||
homeInterfaceSource.lastModified() > classModificationTime || | |||
remoteInterfaceSource.lastModified() > classModificationTime) { | |||
return true; | |||
} | |||
if (primaryKeyClassSource != null && | |||
if (primaryKeyClassSource != null && | |||
primaryKeyClassSource.lastModified() > classModificationTime) { | |||
return true; | |||
} | |||
@@ -231,20 +231,20 @@ public class EjbcHelper { | |||
fis.close(); | |||
} | |||
} | |||
return false; | |||
} | |||
/** | |||
* Process the descriptors in turn generating support classes for each and a manifest | |||
* file for all of the beans. | |||
*/ | |||
*/ | |||
private void process() throws Exception { | |||
String manifest = "Manifest-Version: 1.0\n\n"; | |||
for (int i = 0; i < descriptors.length; ++i) { | |||
String descriptorName = descriptors[i]; | |||
File descriptorFile = new File(descriptorDirectory, descriptorName); | |||
if (isRegenRequired(descriptorFile)) { | |||
System.out.println("Running ejbc for " + descriptorFile.getName()); | |||
regenerateSupportClasses(descriptorFile); | |||
@@ -253,26 +253,26 @@ public class EjbcHelper { | |||
} | |||
manifest += "Name: " + descriptorName.replace('\\', '/') + "\nEnterprise-Bean: True\n\n"; | |||
} | |||
FileWriter fw = new FileWriter(manifestFile); | |||
PrintWriter pw = new PrintWriter(fw); | |||
pw.print(manifest); | |||
fw.flush(); | |||
fw.close(); | |||
} | |||
/** | |||
* Perform the weblogic.ejbc call to regenerate the support classes. | |||
* | |||
* Note that this method relies on an undocumented -noexit option to the | |||
* Note that this method relies on an undocumented -noexit option to the | |||
* ejbc tool to stop the ejbc tool exiting the VM altogether. | |||
*/ | |||
private void regenerateSupportClasses(File descriptorFile) throws Exception { | |||
// create a Java task to do the rebuild | |||
String[] args = getCommandLine(false, descriptorFile); | |||
try { | |||
weblogic.ejbc.main(args); | |||
} catch (Exception e) { | |||
@@ -68,7 +68,7 @@ public class InnerClassFilenameFilter implements FilenameFilter { | |||
} | |||
public boolean accept (File Dir, String filename){ | |||
if ((filename.lastIndexOf(".") != filename.lastIndexOf(".class")) | |||
if ((filename.lastIndexOf(".") != filename.lastIndexOf(".class")) | |||
|| (filename.indexOf(baseClassName + "$") != 0)) { | |||
return false; | |||
} | |||
@@ -83,7 +83,7 @@ public class JbossDeploymentTool extends GenericDeploymentTool { | |||
public void setSuffix(String inString) { | |||
jarSuffix = inString; | |||
} | |||
/** | |||
* Add any vendor specific files which should be included in the | |||
* EJB Jar. | |||
@@ -579,9 +579,9 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool { | |||
javaTask.createArg().setValue("-keepgenerated"); | |||
} | |||
if (compiler == null) { | |||
// try to use the compiler specified by build.compiler. | |||
// try to use the compiler specified by build.compiler. | |||
// Right now we are just going to allow Jikes | |||
String buildCompiler | |||
String buildCompiler | |||
= getTask().getProject().getProperty("build.compiler"); | |||
if (buildCompiler != null && buildCompiler.equals("jikes")) { | |||
@@ -628,7 +628,7 @@ public class WeblogicDeploymentTool extends GenericDeploymentTool { | |||
} | |||
} catch (Exception e) { | |||
// Have to catch this because of the semantics of calling main() | |||
String msg = "Exception while calling " + ejbcClassName | |||
String msg = "Exception while calling " + ejbcClassName | |||
+ ". Details: " + e.toString(); | |||
throw new BuildException(msg, e); | |||
@@ -65,7 +65,7 @@ public class WeblogicTOPLinkDeploymentTool extends WeblogicDeploymentTool { | |||
private String toplinkDescriptor; | |||
private String toplinkDTD; | |||
/** | |||
* Setter used to store the name of the toplink descriptor. | |||
* @param inString the string to use as the descriptor name. | |||
@@ -76,8 +76,8 @@ public class WeblogicTOPLinkDeploymentTool extends WeblogicDeploymentTool { | |||
/** | |||
* Setter used to store the location of the toplink DTD file. | |||
* This is expected to be an URL (file or otherwise). If running this on NT using a file URL, the safest | |||
* thing would be to not use a drive spec in the URL and make sure the file resides on the drive that | |||
* This is expected to be an URL (file or otherwise). If running this on NT using a file URL, the safest | |||
* thing would be to not use a drive spec in the URL and make sure the file resides on the drive that | |||
* ANT is running from. This will keep the setting in the build XML platform independent. | |||
* @param inString the string to use as the DTD location. | |||
*/ | |||
@@ -94,11 +94,11 @@ public class WeblogicTOPLinkDeploymentTool extends WeblogicDeploymentTool { | |||
handler.registerDTD("-//The Object People, Inc.//DTD TOPLink for WebLogic CMP 2.5.1//EN", | |||
TL_DTD_LOC); | |||
} | |||
return handler; | |||
return handler; | |||
} | |||
/** | |||
* Add any vendor specific files which should be included in the | |||
* Add any vendor specific files which should be included in the | |||
* EJB Jar. | |||
*/ | |||
protected void addVendorFiles(Hashtable ejbFiles, String ddPrefix) { | |||
@@ -109,16 +109,16 @@ public class WeblogicTOPLinkDeploymentTool extends WeblogicDeploymentTool { | |||
File toplinkDD = new File(getConfig().descriptorDir, ddPrefix + toplinkDescriptor); | |||
if (toplinkDD.exists()) { | |||
ejbFiles.put(META_DIR + toplinkDescriptor, | |||
toplinkDD); | |||
} else { | |||
log("Unable to locate toplink deployment descriptor. It was expected to be in " + | |||
log("Unable to locate toplink deployment descriptor. It was expected to be in " + | |||
toplinkDD.getPath(), Project.MSG_WARN); | |||
} | |||
} | |||
} | |||
/** | |||
* Called to validate that the tool parameters have been configured. | |||
* | |||
@@ -126,7 +126,7 @@ public class WeblogicTOPLinkDeploymentTool extends WeblogicDeploymentTool { | |||
public void validateConfigured() throws BuildException { | |||
super.validateConfigured(); | |||
if (toplinkDescriptor == null) { | |||
throw new BuildException("The toplinkdescriptor attribute must " | |||
throw new BuildException("The toplinkdescriptor attribute must " | |||
+ "be specified"); | |||
} | |||
} | |||
@@ -216,10 +216,9 @@ public abstract class MSVSS extends Task implements MSVSSConstants { | |||
* Executes the task. <br> | |||
* Builds a command line to execute ss.exe and then calls Exec's run method | |||
* to execute the command line. | |||
* @throws BuildException | |||
* @throws BuildException if the command cannot execute. | |||
*/ | |||
public void execute() | |||
throws BuildException { | |||
public void execute() throws BuildException { | |||
int result = 0; | |||
Commandline commandLine = buildCmdLine(); | |||
result = run(commandLine); | |||
@@ -377,17 +376,15 @@ public abstract class MSVSS extends Task implements MSVSSConstants { | |||
* @return An empty string if label is not set. | |||
*/ | |||
protected String getLabel() { | |||
if (m_Label != null && m_Label.length()>0) { | |||
if (m_Label != null && m_Label.length() > 0) { | |||
if (m_Label.length() > 31) { | |||
String label = m_Label.substring(0, 30); | |||
log("Label is longer than 31 characters, truncated to: " + label, Project.MSG_WARN); | |||
return FLAG_LABEL + label; | |||
} | |||
else { | |||
} else { | |||
return FLAG_LABEL + m_Label; | |||
} | |||
} | |||
else { | |||
} else { | |||
return ""; | |||
} | |||
} | |||
@@ -410,15 +407,13 @@ public abstract class MSVSS extends Task implements MSVSSConstants { | |||
protected String getVersionDateLabel() { | |||
if (m_Version != null) { | |||
return FLAG_VERSION + m_Version; | |||
} | |||
else if (m_Date != null) { | |||
} else if (m_Date != null) { | |||
return FLAG_VERSION_DATE + m_Date; | |||
} | |||
else { | |||
} else { | |||
// Use getLabel() so labels longer then 30 char are truncated | |||
// and the user is warned | |||
String label = getLabel(); | |||
if (! label.equals("") && label!=null) { | |||
if (!label.equals("") && label != null) { | |||
return FLAG_VERSION_LABEL + label; | |||
} | |||
} | |||
@@ -447,9 +442,9 @@ public abstract class MSVSS extends Task implements MSVSSConstants { | |||
} else { | |||
// make sure m_LocalDir exists, create it if it doesn't | |||
File dir = getProject().resolveFile(m_LocalPath); | |||
if (! dir.exists()) { | |||
if (!dir.exists()) { | |||
boolean done = dir.mkdirs(); | |||
if (! done) { | |||
if (!done) { | |||
String msg = "Directory " + m_LocalPath + " creation was not " | |||
+ "successful for an unknown reason"; | |||
throw new BuildException(msg, getLocation()); | |||
@@ -593,7 +588,7 @@ public abstract class MSVSS extends Task implements MSVSSConstants { | |||
* @return An empty string if get local copy is true. | |||
*/ | |||
protected String getGetLocalCopy() { | |||
return (! m_getLocalCopy) ? FLAG_NO_GET : ""; | |||
return (!m_getLocalCopy) ? FLAG_NO_GET : ""; | |||
} | |||
/** | |||
@@ -618,14 +613,11 @@ public abstract class MSVSS extends Task implements MSVSSConstants { | |||
public String getFileTimeStamp() { | |||
if (m_timestamp == null) { | |||
return ""; | |||
} | |||
else if (m_timestamp.getValue().equals(TIME_MODIFIED)) { | |||
} else if (m_timestamp.getValue().equals(TIME_MODIFIED)) { | |||
return FLAG_FILETIME_MODIFIED; | |||
} | |||
else if (m_timestamp.getValue().equals(TIME_UPDATED)) { | |||
} else if (m_timestamp.getValue().equals(TIME_UPDATED)) { | |||
return FLAG_FILETIME_UPDATED; | |||
} | |||
else { | |||
} else { | |||
return FLAG_FILETIME_DEF; | |||
} | |||
} | |||
@@ -638,17 +630,14 @@ public abstract class MSVSS extends Task implements MSVSSConstants { | |||
public String getWritableFiles() { | |||
if (m_writablefiles == null) { | |||
return ""; | |||
} | |||
else if (m_writablefiles.getValue().equals(WRITABLE_REPLACE)) { | |||
} else if (m_writablefiles.getValue().equals(WRITABLE_REPLACE)) { | |||
return FLAG_REPLACE_WRITABLE; | |||
} | |||
else if (m_writablefiles.getValue().equals(WRITABLE_SKIP)) { | |||
} else if (m_writablefiles.getValue().equals(WRITABLE_SKIP)) { | |||
// ss.exe exits with '100', when files have been skipped | |||
// so we have to ignore the failure | |||
m_FailOnError = false; | |||
return FLAG_SKIP_WRITABLE; | |||
} | |||
else { | |||
} else { | |||
return ""; | |||
} | |||
} | |||
@@ -741,7 +730,7 @@ public abstract class MSVSS extends Task implements MSVSSConstants { | |||
* @return The values. | |||
*/ | |||
public String[] getValues() { | |||
return new String[] { TIME_CURRENT, TIME_MODIFIED, TIME_UPDATED }; | |||
return new String[] {TIME_CURRENT, TIME_MODIFIED, TIME_UPDATED}; | |||
} | |||
} | |||
@@ -754,7 +743,7 @@ public abstract class MSVSS extends Task implements MSVSSConstants { | |||
* @return The values. | |||
*/ | |||
public String[] getValues() { | |||
return new String[] { WRITABLE_REPLACE, WRITABLE_SKIP, WRITABLE_FAIL }; | |||
return new String[] {WRITABLE_REPLACE, WRITABLE_SKIP, WRITABLE_FAIL}; | |||
} | |||
} | |||
} |
@@ -137,7 +137,7 @@ public class MSVSSADD extends MSVSS { | |||
* | |||
* @param response The auto response value. | |||
*/ | |||
public void setAutoresponse(String response){ | |||
public void setAutoresponse(String response) { | |||
super.setInternalAutoResponse(response); | |||
} | |||
@@ -166,7 +166,7 @@ public class MSVSSCHECKOUT extends MSVSS { | |||
* | |||
* @param response The auto response value. | |||
*/ | |||
public void setAutoresponse(String response){ | |||
public void setAutoresponse(String response) { | |||
super.setInternalAutoResponse(response); | |||
} | |||
@@ -175,7 +175,7 @@ public class MSVSSCHECKOUT extends MSVSS { | |||
* | |||
* @param timestamp The file time stamping behaviour. | |||
*/ | |||
public void setFileTimeStamp(CurrentModUpdated timestamp){ | |||
public void setFileTimeStamp(CurrentModUpdated timestamp) { | |||
super.setInternalFileTimeStamp(timestamp); | |||
} | |||
@@ -184,7 +184,7 @@ public class MSVSSGET extends MSVSS { | |||
* | |||
* @param response The auto response value. | |||
*/ | |||
public void setAutoresponse(String response){ | |||
public void setAutoresponse(String response) { | |||
super.setInternalAutoResponse(response); | |||
} | |||