Browse Source

Fix a few checkstyle errors

git-svn-id: https://svn.apache.org/repos/asf/ant/core/trunk@274775 13f79535-47bb-0310-9956-ffa450edef68
master
Conor MacNeill 22 years ago
parent
commit
6ee5317ca3
19 changed files with 501 additions and 364 deletions
  1. +6
    -6
      docs.xml
  2. +1
    -1
      src/main/org/apache/tools/ant/ExitException.java
  3. +6
    -2
      src/main/org/apache/tools/ant/MagicNames.java
  4. +1
    -1
      src/main/org/apache/tools/ant/filters/TokenFilter.java
  5. +70
    -62
      src/main/org/apache/tools/ant/taskdefs/Classloader.java
  6. +3
    -0
      src/main/org/apache/tools/ant/taskdefs/GZip.java
  7. +4
    -1
      src/main/org/apache/tools/ant/taskdefs/LogStreamHandler.java
  8. +66
    -66
      src/main/org/apache/tools/ant/taskdefs/Redirector.java
  9. +2
    -2
      src/main/org/apache/tools/ant/taskdefs/Rename.java
  10. +4
    -0
      src/main/org/apache/tools/ant/taskdefs/Taskdef.java
  11. +1
    -0
      src/main/org/apache/tools/ant/taskdefs/XSLTLiaison.java
  12. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java
  13. +8
    -1
      src/main/org/apache/tools/ant/taskdefs/condition/Not.java
  14. +3
    -3
      src/main/org/apache/tools/ant/taskdefs/cvslib/RedirectingOutputStream.java
  15. +1
    -1
      src/main/org/apache/tools/ant/taskdefs/cvslib/RedirectingStreamHandler.java
  16. +3
    -0
      src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckin.java
  17. +132
    -113
      src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java
  18. +27
    -18
      src/main/org/apache/tools/ant/taskdefs/optional/j2ee/JonasHotDeploymentTool.java
  19. +162
    -86
      src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java

+ 6
- 6
docs.xml View File

@@ -16,8 +16,8 @@
</fileset> </fileset>
</path> </path>


<target name="prepare">
<available classname="org.apache.velocity.anakia.AnakiaTask"
<target name="prepare">
<available classname="org.apache.velocity.anakia.AnakiaTask"
property="AnakiaTask.present"> property="AnakiaTask.present">
<classpath refid="anakia.classpath"/> <classpath refid="anakia.classpath"/>
</available> </available>
@@ -25,7 +25,7 @@


<target depends="prepare" name="prepare-error" unless="AnakiaTask.present"> <target depends="prepare" name="prepare-error" unless="AnakiaTask.present">
<echo> <echo>
AnakiaTask is not present! Please check to make sure that
AnakiaTask is not present! Please check to make sure that
velocity.jar is in your classpath. velocity.jar is in your classpath.
</echo> </echo>
</target> </target>
@@ -34,7 +34,7 @@
<taskdef name="anakia" classname="org.apache.velocity.anakia.AnakiaTask"> <taskdef name="anakia" classname="org.apache.velocity.anakia.AnakiaTask">
<classpath refid="anakia.classpath"/> <classpath refid="anakia.classpath"/>
</taskdef> </taskdef>
<anakia basedir="${docs.src}" destdir="${docs.dest}/" <anakia basedir="${docs.src}" destdir="${docs.dest}/"
extension=".html" style="./site.vsl" extension=".html" style="./site.vsl"
projectFile="${project.file}" projectFile="${project.file}"
@@ -45,12 +45,12 @@
velocityPropertiesFile="${velocity.props}"> velocityPropertiesFile="${velocity.props}">
</anakia> </anakia>
</target> </target>
<target name="javadocs"> <target name="javadocs">
<ant antfile="build.xml" target="dist_javadocs"> <ant antfile="build.xml" target="dist_javadocs">
<property name="dist.javadocs" value="${docs.dest}/manual/api" /> <property name="dist.javadocs" value="${docs.dest}/manual/api" />
</ant> </ant>
</target> </target>
<target name="all" depends="docs, javadocs"/> <target name="all" depends="docs, javadocs"/>
</project> </project>

+ 1
- 1
src/main/org/apache/tools/ant/ExitException.java View File

@@ -64,7 +64,7 @@ public class ExitException extends SecurityException {


/** Status code */ /** Status code */
private int status; private int status;
/** /**
* Constructs an exit exception. * Constructs an exit exception.
* @param status the status code returned via System.exit() * @param status the status code returned via System.exit()


+ 6
- 2
src/main/org/apache/tools/ant/MagicNames.java View File

@@ -54,8 +54,8 @@
package org.apache.tools.ant; package org.apache.tools.ant;


/** /**
* Magic names used within Ant.
*
* Magic names used within Ant.
*
* Not all magic names are here yet. * Not all magic names are here yet.
* *
* @author Conor MacNeill * @author Conor MacNeill
@@ -64,5 +64,9 @@ package org.apache.tools.ant;
public class MagicNames { public class MagicNames {
/** The name of the script repository used by the script repo task */ /** The name of the script repository used by the script repo task */
public static final String SCRIPT_REPOSITORY = "org.apache.ant.scriptrepo"; public static final String SCRIPT_REPOSITORY = "org.apache.ant.scriptrepo";

/** The name of the reference to the System Class Loader */
public static final String SYSTEM_LOADER_REF = "ant.coreLoader";

} }



+ 1
- 1
src/main/org/apache/tools/ant/filters/TokenFilter.java View File

@@ -594,7 +594,7 @@ public class TokenFilter extends BaseFilterReader
* Abstract class that converts derived filter classes into * Abstract class that converts derived filter classes into
* ChainableReaderFilter's * ChainableReaderFilter's
*/ */
public static abstract class ChainableReaderFilter extends ProjectComponent
public abstract static class ChainableReaderFilter extends ProjectComponent
implements ChainableReader, Filter { implements ChainableReader, Filter {
private boolean byLine = true; private boolean byLine = true;




+ 70
- 62
src/main/org/apache/tools/ant/taskdefs/Classloader.java View File

@@ -54,11 +54,15 @@


package org.apache.tools.ant.taskdefs; package org.apache.tools.ant.taskdefs;


import org.apache.tools.ant.*;
import org.apache.tools.ant.types.*;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
import org.apache.tools.ant.MagicNames;
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.AntClassLoader;
import org.apache.tools.ant.types.Reference;
import org.apache.tools.ant.types.Path;


import java.io.*;
import java.util.*;
import java.io.File;


/** /**
* EXPERIMENTAL * EXPERIMENTAL
@@ -66,11 +70,11 @@ import java.util.*;
* will be used to add classpath elements. * will be used to add classpath elements.
* *
* The classpath is a regular path. Currently only file components are * The classpath is a regular path. Currently only file components are
* supported ( future extensions may allow URLs ).
* supported (future extensions may allow URLs).
* *
* You can modify the core loader by not specifying any name or using * You can modify the core loader by not specifying any name or using
* "ant.coreLoader". ( the core loader is used to load system ant
* tasks and for taskdefs that don't specify an explicit path ).
* "ant.coreLoader". (the core loader is used to load system ant
* tasks and for taskdefs that don't specify an explicit path).
* *
* Taskdef and typedef can use the loader you create if the name follows * Taskdef and typedef can use the loader you create if the name follows
* the "ant.loader.NAME" pattern. NAME will be used as a pathref when * the "ant.loader.NAME" pattern. NAME will be used as a pathref when
@@ -93,58 +97,63 @@ import java.util.*;
* @author Costin Manolache * @author Costin Manolache
*/ */
public class Classloader extends Task { public class Classloader extends Task {
public static final String SYSTEM_LOADER_REF="ant.coreLoader";
/** @see MagicNames#SYSTEM_LOADER_REF */
public static final String SYSTEM_LOADER_REF = MagicNames.SYSTEM_LOADER_REF;


private String name=null;
private String name = null;
private Path classpath; private Path classpath;
private boolean reset=false;
private boolean parentFirst=true;
private String parentName=null;
private boolean reset = false;
private boolean parentFirst = true;
private String parentName = null;


/**
* Default constructor
*/
public Classloader() { public Classloader() {
} }


/** Name of the loader. If none, the default loader will be modified /** Name of the loader. If none, the default loader will be modified
* *
* @param name
* @param name the name of this loader
*/ */
public void setName(String name) { public void setName(String name) {
this.name=name;
this.name = name;
} }


/** Reset the classloader, if it already exists. A new loader will
/**
* Reset the classloader, if it already exists. A new loader will
* be created and all the references to the old one will be removed. * be created and all the references to the old one will be removed.
* ( it is not possible to remove paths from a loader ). The new
* (it is not possible to remove paths from a loader). The new
* path will be used. * path will be used.
* *
* @param b
* @param b true if the loader is to be reset.
*/ */
public void setReset(boolean b) { public void setReset(boolean b) {
this.reset=b;
this.reset = b;
} }


public void setReverse(boolean b ) {
this.parentFirst= ! b;
public void setReverse(boolean b) {
this.parentFirst = !b;
} }


public void setParentFirst(boolean b ) {
this.parentFirst= b;
public void setParentFirst(boolean b) {
this.parentFirst = b;
} }


// TODO: add exceptions for delegation or reverse // TODO: add exceptions for delegation or reverse


// TODO // TODO
public void setParentName( String name ) {
this.parentName=name;
public void setParentName(String name) {
this.parentName = name;
} }




/** Specify which path will be used. If the loader already exists /** Specify which path will be used. If the loader already exists
* and is an AntClassLoader ( or any other loader we can extend ),
* and is an AntClassLoader (or any other loader we can extend),
* the path will be added to the loader. * the path will be added to the loader.
*/ */
public void setClasspathRef( Reference pathRef ) throws BuildException {
classpath=(Path)pathRef.getReferencedObject(project);
public void setClasspathRef(Reference pathRef) throws BuildException {
classpath = (Path) pathRef.getReferencedObject(project);
} }


/** /**
@@ -171,71 +180,70 @@ public class Classloader extends Task {
public void execute() { public void execute() {
try { try {
// Gump friendly - don't mess with the core loader if only classpath // Gump friendly - don't mess with the core loader if only classpath
if( "only".equals( project.getProperty("build.sysclasspath")) &&
(name==null || SYSTEM_LOADER_REF.equals( name ))) {
log( "Changing the system loader is disabled " +
"by build.sysclasspath=only",
Project.MSG_WARN);
if ("only".equals(project.getProperty("build.sysclasspath"))
&& (name == null || SYSTEM_LOADER_REF.equals(name))) {
log("Changing the system loader is disabled "
+ "by build.sysclasspath=only", Project.MSG_WARN);
return; return;
} }


String loaderName=(name==null) ? SYSTEM_LOADER_REF : name;
String loaderName = (name == null) ? SYSTEM_LOADER_REF : name;


Object obj=project.getReference(loaderName);
if( reset ) {
Object obj = project.getReference(loaderName);
if (reset) {
// Are any other references held ? Can we 'close' the loader // Are any other references held ? Can we 'close' the loader
// so it removes the locks on jars ? // so it removes the locks on jars ?
obj=null; // a new one will be created.
obj = null; // a new one will be created.
} }


// XXX maybe use reflection to addPathElement ( other patterns ?)
if( obj!=null && !(obj instanceof AntClassLoader )) {
log( "Referenced object is not an AntClassLoader",
// XXX maybe use reflection to addPathElement (other patterns ?)
if (obj != null && !(obj instanceof AntClassLoader)) {
log("Referenced object is not an AntClassLoader",
Project.MSG_ERR); Project.MSG_ERR);
return; return;
} }


AntClassLoader acl=(AntClassLoader)obj;
AntClassLoader acl = (AntClassLoader) obj;


if( acl==null ) {
if (acl == null) {
// Construct a new class loader // Construct a new class loader
Object parent=null;
if( parentName != null ) {
parent=project.getReference(parentName);
if( !(parent instanceof ClassLoader) ) {
parent=null;
Object parent = null;
if (parentName != null) {
parent = project.getReference(parentName);
if (!(parent instanceof ClassLoader)) {
parent = null;
} }
} }
// TODO: allow user to request the system or no parent // TODO: allow user to request the system or no parent
if( parent==null ) {
parent=this.getClass().getClassLoader();
if (parent == null) {
parent = this.getClass().getClassLoader();
} }


if( name==null ) {
if (name == null) {
// The core loader must be reverse // The core loader must be reverse
//reverse=true; //reverse=true;
} }
project.log("Setting parent loader " + name + " " +
parent + " " + parentFirst, Project.MSG_DEBUG);
project.log("Setting parent loader " + name + " "
+ parent + " " + parentFirst, Project.MSG_DEBUG);


// The param is "parentFirst" // The param is "parentFirst"
acl=new AntClassLoader( (ClassLoader)parent,
project, classpath, parentFirst );
acl = new AntClassLoader((ClassLoader) parent,
project, classpath, parentFirst);


project.addReference( loaderName, acl );
project.addReference(loaderName, acl);


if( name==null ) {
if (name == null) {
// This allows the core loader to load optional tasks // This allows the core loader to load optional tasks
// without delegating // without delegating
acl.addLoaderPackageRoot( "org.apache.tools.ant.taskdefs.optional");
acl.addLoaderPackageRoot("org.apache.tools.ant.taskdefs.optional");
project.setCoreLoader(acl); project.setCoreLoader(acl);
} }
} }
if( classpath != null ) {
String list[]=classpath.list();
for( int i=0; i<list.length; i++ ) {
File f= new File( list[i] );
if( f.exists() ) {
if (classpath != null) {
String[] list = classpath.list();
for (int i = 0; i < list.length; i++) {
File f = new File(list[i]);
if (f.exists()) {
acl.addPathElement(f.getAbsolutePath()); acl.addPathElement(f.getAbsolutePath());
log("Adding to class loader " + acl + " " + f.getAbsolutePath(), log("Adding to class loader " + acl + " " + f.getAbsolutePath(),
Project.MSG_DEBUG); Project.MSG_DEBUG);
@@ -245,7 +253,7 @@ public class Classloader extends Task {


// XXX add exceptions // XXX add exceptions


} catch( Exception ex ) {
} catch (Exception ex) {
ex.printStackTrace(); ex.printStackTrace();
} }
} }


+ 3
- 0
src/main/org/apache/tools/ant/taskdefs/GZip.java View File

@@ -73,6 +73,9 @@ import org.apache.tools.ant.BuildException;
*/ */


public class GZip extends Pack { public class GZip extends Pack {
/**
* perform the GZip compression operation.
*/
protected void pack() { protected void pack() {
GZIPOutputStream zOut = null; GZIPOutputStream zOut = null;
try { try {


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

@@ -67,7 +67,7 @@ import org.apache.tools.ant.Task;
public class LogStreamHandler extends PumpStreamHandler { public class LogStreamHandler extends PumpStreamHandler {


/** /**
* Creates a new instance of this class.
* Creates log stream handler
* *
* @param task the task for whom to log * @param task the task for whom to log
* @param outlevel the loglevel used to log standard output * @param outlevel the loglevel used to log standard output
@@ -78,6 +78,9 @@ public class LogStreamHandler extends PumpStreamHandler {
new LogOutputStream(task, errlevel)); new LogOutputStream(task, errlevel));
} }


/**
* Stop the log stream handler.
*/
public void stop() { public void stop() {
super.stop(); super.stop();
try { try {


+ 66
- 66
src/main/org/apache/tools/ant/taskdefs/Redirector.java View File

@@ -72,76 +72,76 @@ import org.apache.tools.ant.util.StringUtils;
import org.apache.tools.ant.util.TeeOutputStream; import org.apache.tools.ant.util.TeeOutputStream;


/** /**
* The Redirector class manages the setup and connection of
* The Redirector class manages the setup and connection of
* input and output redirection for an Ant task. * input and output redirection for an Ant task.
* *
* @author Conor MacNeill * @author Conor MacNeill
* @since Ant 1.6 * @since Ant 1.6
*/ */
public class Redirector { public class Redirector {
/**
/**
* The file receiveing standard output. Will also receive standard error * The file receiveing standard output. Will also receive standard error
* unless standard error is redirected or logError is true. * unless standard error is redirected or logError is true.
*/ */
private File out; private File out;
/** /**
* The file to which standard error is being redirected
* The file to which standard error is being redirected
*/ */
private File error; private File error;
/**
/**
* The file from which standard input is being taken. * The file from which standard input is being taken.
*/ */
private File input; private File input;


/**
/**
* Indicates if standard error should be logged to Ant's log system * Indicates if standard error should be logged to Ant's log system
* rather than the output. This has no effect if standard error is
* rather than the output. This has no effect if standard error is
* redirected to a file or property. * redirected to a file or property.
*/ */
private boolean logError = false; private boolean logError = false;
/** /**
* Buffer used to capture output for storage into a property * Buffer used to capture output for storage into a property
*/ */
private ByteArrayOutputStream baos = null; private ByteArrayOutputStream baos = null;
/** /**
* Buffer used to capture error output for storage into a property * Buffer used to capture error output for storage into a property
*/ */
private ByteArrayOutputStream errorBaos = null; private ByteArrayOutputStream errorBaos = null;
/** The name of the property into which output is to be stored */ /** The name of the property into which output is to be stored */
private String outputProperty; private String outputProperty;
/** The name of the property into which error output is to be stored */ /** The name of the property into which error output is to be stored */
private String errorProperty; private String errorProperty;
/** String from which input is taken */ /** String from which input is taken */
private String inputString; private String inputString;
/** Flag which indicates if error and output files are to be appended. */ /** Flag which indicates if error and output files are to be appended. */
private boolean append = false; private boolean append = false;
/** The task for which this redirector is working */
/** The task for which this redirector is working */
private Task managingTask; private Task managingTask;


/** The stream for output data */ /** The stream for output data */
private OutputStream outputStream = null; private OutputStream outputStream = null;
/** The stream for error output */ /** The stream for error output */
private OutputStream errorStream = null; private OutputStream errorStream = null;
/** The stream for input */ /** The stream for input */
private InputStream inputStream = null; private InputStream inputStream = null;
/** Stream which are used for line oriented output */
/** Stream which are used for line oriented output */
private PrintStream outPrintStream = null; private PrintStream outPrintStream = null;
/** Stream which is used for line oriented error output */ /** Stream which is used for line oriented error output */
private PrintStream errorPrintStream = null; private PrintStream errorPrintStream = null;
/** /**
* Create a redirector instance for the given task * Create a redirector instance for the given task
* *
@@ -150,7 +150,7 @@ public class Redirector {
public Redirector(Task managingTask) { public Redirector(Task managingTask) {
this.managingTask = managingTask; this.managingTask = managingTask;
} }
/** /**
* Set the input to use for the task * Set the input to use for the task
* *
@@ -168,10 +168,10 @@ public class Redirector {
public void setInputString(String inputString) { public void setInputString(String inputString) {
this.inputString = inputString; this.inputString = inputString;
} }
/** /**
* File the output of the process is redirected to. If error is not
* File the output of the process is redirected to. If error is not
* redirected, it too will appear in the output * redirected, it too will appear in the output
* *
* @param out the file to which output stream is written * @param out the file to which output stream is written
@@ -191,7 +191,7 @@ public class Redirector {
public void setLogError(boolean logError) { public void setLogError(boolean logError) {
this.logError = logError; this.logError = logError;
} }
/** /**
* Set the file to which standard error is to be redirected. * Set the file to which standard error is to be redirected.
* *
@@ -205,7 +205,7 @@ public class Redirector {
* Property name whose value should be set to the output of * Property name whose value should be set to the output of
* the process. * the process.
* *
* @param outputProperty the name of the property to be set with the
* @param outputProperty the name of the property to be set with the
* task's output. * task's output.
*/ */
public void setOutputProperty(String outputProperty) { public void setOutputProperty(String outputProperty) {
@@ -227,7 +227,7 @@ public class Redirector {
* Property name whose value should be set to the error of * Property name whose value should be set to the error of
* the process. * the process.
* *
* @param errorProperty the name of the property to be set
* @param errorProperty the name of the property to be set
* with the error output. * with the error output.
*/ */
public void setErrorProperty(String errorProperty) { public void setErrorProperty(String errorProperty) {
@@ -242,9 +242,9 @@ public class Redirector {
* *
* @exception IOException if the value cannot be read form the stream. * @exception IOException if the value cannot be read form the stream.
*/ */
private void setPropertyFromBAOS(ByteArrayOutputStream baos,
private void setPropertyFromBAOS(ByteArrayOutputStream baos,
String propertyName) throws IOException { String propertyName) throws IOException {
BufferedReader in = BufferedReader in =
new BufferedReader(new StringReader(Execute.toString(baos))); new BufferedReader(new StringReader(Execute.toString(baos)));
String line = null; String line = null;
@@ -257,22 +257,22 @@ public class Redirector {
} }
managingTask.getProject().setNewProperty(propertyName, val.toString()); managingTask.getProject().setNewProperty(propertyName, val.toString());
} }


/** /**
* Create the input, error and output streams based on the
* Create the input, error and output streams based on the
* configuration options. * configuration options.
*/ */
public void createStreams() {
public void createStreams() {
if (out == null && outputProperty == null) { if (out == null && outputProperty == null) {
outputStream = new LogOutputStream(managingTask, Project.MSG_INFO); outputStream = new LogOutputStream(managingTask, Project.MSG_INFO);
errorStream = new LogOutputStream(managingTask, Project.MSG_WARN); errorStream = new LogOutputStream(managingTask, Project.MSG_WARN);
} else { } else {
if (out != null) { if (out != null) {
try { try {
outputStream
outputStream
= new FileOutputStream(out.getAbsolutePath(), append); = new FileOutputStream(out.getAbsolutePath(), append);
managingTask.log("Output redirected to " + out,
managingTask.log("Output redirected to " + out,
Project.MSG_VERBOSE); Project.MSG_VERBOSE);
} catch (FileNotFoundException fne) { } catch (FileNotFoundException fne) {
throw new BuildException("Cannot write to " + out, fne); throw new BuildException("Cannot write to " + out, fne);
@@ -280,10 +280,10 @@ public class Redirector {
throw new BuildException("Cannot write to " + out, ioe); throw new BuildException("Cannot write to " + out, ioe);
} }
} }
if (outputProperty != null) { if (outputProperty != null) {
baos = new ByteArrayOutputStream(); baos = new ByteArrayOutputStream();
managingTask.log("Output redirected to property: "
managingTask.log("Output redirected to property: "
+ outputProperty, Project.MSG_VERBOSE); + outputProperty, Project.MSG_VERBOSE);
if (out == null) { if (out == null) {
outputStream = baos; outputStream = baos;
@@ -293,19 +293,19 @@ public class Redirector {
} else { } else {
baos = null; baos = null;
} }
errorStream = outputStream; errorStream = outputStream;
}
}


if (logError) { if (logError) {
errorStream = new LogOutputStream(managingTask, Project.MSG_WARN); errorStream = new LogOutputStream(managingTask, Project.MSG_WARN);
} }
if (error != null) { if (error != null) {
try { try {
errorStream
errorStream
= new FileOutputStream(error.getAbsolutePath(), append); = new FileOutputStream(error.getAbsolutePath(), append);
managingTask.log("Error redirected to " + error,
managingTask.log("Error redirected to " + error,
Project.MSG_VERBOSE); Project.MSG_VERBOSE);
} catch (FileNotFoundException fne) { } catch (FileNotFoundException fne) {
throw new BuildException("Cannot write to " + error, fne); throw new BuildException("Cannot write to " + error, fne);
@@ -313,10 +313,10 @@ public class Redirector {
throw new BuildException("Cannot write to " + error, ioe); throw new BuildException("Cannot write to " + error, ioe);
} }
} }
if (errorProperty != null) { if (errorProperty != null) {
errorBaos = new ByteArrayOutputStream(); errorBaos = new ByteArrayOutputStream();
managingTask.log("Error redirected to property: " + errorProperty,
managingTask.log("Error redirected to property: " + errorProperty,
Project.MSG_VERBOSE); Project.MSG_VERBOSE);
if (error == null) { if (error == null) {
errorStream = errorBaos; errorStream = errorBaos;
@@ -341,21 +341,21 @@ public class Redirector {
inputStream = new ByteArrayInputStream(inputString.getBytes()); inputStream = new ByteArrayInputStream(inputString.getBytes());
} }
} }
/** /**
* Create the StreamHandler to use with our Execute instance. * Create the StreamHandler to use with our Execute instance.
* *
* @return the execute stream handler to manage the input, output and * @return the execute stream handler to manage the input, output and
* error streams. * error streams.
*
*
* @throws BuildException if the execute stream handler cannot be created. * @throws BuildException if the execute stream handler cannot be created.
*/ */
public ExecuteStreamHandler createHandler() throws BuildException { public ExecuteStreamHandler createHandler() throws BuildException {
createStreams(); createStreams();
return new PumpStreamHandler(outputStream, errorStream, inputStream); return new PumpStreamHandler(outputStream, errorStream, inputStream);
} }
/** /**
* Pass output sent to System.out to specified output. * Pass output sent to System.out to specified output.
* *
@@ -367,8 +367,8 @@ public class Redirector {
} }
outPrintStream.println(line); outPrintStream.println(line);
} }
/**
/**
* Handle an input request * Handle an input request
* *
* @param buffer the buffer into which data is to be read. * @param buffer the buffer into which data is to be read.
@@ -376,19 +376,19 @@ public class Redirector {
* @param length the amount of data to read * @param length the amount of data to read
* *
* @return the number of bytes read * @return the number of bytes read
*
*
* @exception IOException if the data cannot be read * @exception IOException if the data cannot be read
*/ */
protected int handleInput(byte[] buffer, int offset, int length)
protected int handleInput(byte[] buffer, int offset, int length)
throws IOException { throws IOException {
if (inputStream == null) { if (inputStream == null) {
return managingTask.getProject().defaultInput(buffer, offset,
return managingTask.getProject().defaultInput(buffer, offset,
length); length);
} else { } else {
return inputStream.read(buffer, offset, length); return inputStream.read(buffer, offset, length);
}
}
} }
/** /**
* Process data due to a flush operation. * Process data due to a flush operation.
* *
@@ -401,7 +401,7 @@ public class Redirector {
outPrintStream.print(line); outPrintStream.print(line);
outPrintStream.flush(); outPrintStream.flush();
} }
/** /**
* Process error output * Process error output
* *
@@ -413,7 +413,7 @@ public class Redirector {
} }
errorPrintStream.println(line); errorPrintStream.println(line);
} }
/** /**
* Handle a flush operation on the error stream * Handle a flush operation on the error stream
* *
@@ -429,17 +429,17 @@ public class Redirector {
/** /**
* Get the output stream for the redirector * Get the output stream for the redirector
* *
* @return the redirector's output stream or null if no output
* @return the redirector's output stream or null if no output
* has been configured * has been configured
*/ */
public OutputStream getOutputStream() { public OutputStream getOutputStream() {
return outputStream; return outputStream;
} }
/** /**
* Get the error stream for the redirector * Get the error stream for the redirector
* *
* @return the redirector's error stream or null if no output
* @return the redirector's error stream or null if no output
* has been configured * has been configured
*/ */
public OutputStream getErrorStream() { public OutputStream getErrorStream() {
@@ -449,15 +449,15 @@ public class Redirector {
/** /**
* Get the input stream for the redirector * Get the input stream for the redirector
* *
* @return the redirector's input stream or null if no output
* @return the redirector's input stream or null if no output
* has been configured * has been configured
*/ */
public InputStream getInputStream() { public InputStream getInputStream() {
return inputStream; return inputStream;
} }
/** /**
* Complete redirection.
* Complete redirection.
* *
* This opertaion will close any streams and create any specified * This opertaion will close any streams and create any specified
* property values. * property values.
@@ -468,13 +468,13 @@ public class Redirector {
public void complete() throws IOException { public void complete() throws IOException {
System.out.flush(); System.out.flush();
System.err.flush(); System.err.flush();
if (inputStream != null) { if (inputStream != null) {
inputStream.close(); inputStream.close();
} }
outputStream.close(); outputStream.close();
errorStream.close(); errorStream.close();
if (baos != null) { if (baos != null) {
setPropertyFromBAOS(baos, outputProperty); setPropertyFromBAOS(baos, outputProperty);
} }


+ 2
- 2
src/main/org/apache/tools/ant/taskdefs/Rename.java View File

@@ -124,8 +124,8 @@ public class Rename extends Task {
try { try {
FileUtils.newFileUtils().rename(src, dest); FileUtils.newFileUtils().rename(src, dest);
} catch (IOException e) { } catch (IOException e) {
throw new BuildException("Unable to rename " + src + " to " +
dest, e, getLocation());
throw new BuildException("Unable to rename " + src + " to "
+ dest, e, getLocation());
} }
} }
} }

+ 4
- 0
src/main/org/apache/tools/ant/taskdefs/Taskdef.java View File

@@ -75,6 +75,10 @@ import org.apache.tools.ant.TaskAdapter;
*/ */
public class Taskdef extends Typedef { public class Taskdef extends Typedef {


/**
* Default constuctor.
*
*/
public Taskdef() { public Taskdef() {
setAdapterClass(TaskAdapter.class); setAdapterClass(TaskAdapter.class);
setAdaptToClass(Task.class); setAdaptToClass(Task.class);


+ 1
- 0
src/main/org/apache/tools/ant/taskdefs/XSLTLiaison.java View File

@@ -79,6 +79,7 @@ public interface XSLTLiaison {
/** /**
* set the stylesheet to use for the transformation. * set the stylesheet to use for the transformation.
* @param stylesheet the stylesheet to be used for transformation. * @param stylesheet the stylesheet to be used for transformation.
* @throws Exception thrown if any problems happens.
* @since Ant 1.4 * @since Ant 1.4
*/ */
void setStylesheet(File stylesheet) throws Exception; void setStylesheet(File stylesheet) throws Exception;


+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/condition/FilesMatch.java View File

@@ -118,7 +118,7 @@ public class FilesMatch implements Condition {
try { try {
matches = fu.contentEquals(file1, file2); matches = fu.contentEquals(file1, file2);
} catch (IOException ioe) { } catch (IOException ioe) {
throw new BuildException("when comparing files: "
throw new BuildException("when comparing files: "
+ ioe.getMessage(), ioe); + ioe.getMessage(), ioe);
} }
return matches; return matches;


+ 8
- 1
src/main/org/apache/tools/ant/taskdefs/condition/Not.java View File

@@ -68,9 +68,16 @@ import org.apache.tools.ant.BuildException;
*/ */
public class Not extends ConditionBase implements Condition { public class Not extends ConditionBase implements Condition {


/**
* Evaluate condition
*
* @return true if the condition is true.
* @throws BuildException if the condition is not configured correctly.
*/
public boolean eval() throws BuildException { public boolean eval() throws BuildException {
if (countConditions() > 1) { if (countConditions() > 1) {
throw new BuildException("You must not nest more than one condition into <not>");
throw new BuildException("You must not nest more than one "
+ "condition into <not>");
} }
if (countConditions() < 1) { if (countConditions() < 1) {
throw new BuildException("You must nest a condition into <not>"); throw new BuildException("You must nest a condition into <not>");


+ 3
- 3
src/main/org/apache/tools/ant/taskdefs/cvslib/RedirectingOutputStream.java View File

@@ -63,7 +63,7 @@ import org.apache.tools.ant.taskdefs.LogOutputStream;
*/ */
class RedirectingOutputStream class RedirectingOutputStream
extends LogOutputStream { extends LogOutputStream {
private final ChangeLogParser m_parser;
private final ChangeLogParser parser;




/** /**
@@ -73,7 +73,7 @@ class RedirectingOutputStream
*/ */
public RedirectingOutputStream(final ChangeLogParser parser) { public RedirectingOutputStream(final ChangeLogParser parser) {
super(null, 0); super(null, 0);
m_parser = parser;
this.parser = parser;
} }




@@ -83,7 +83,7 @@ class RedirectingOutputStream
* @param line the line to log. * @param line the line to log.
*/ */
protected void processLine(final String line) { protected void processLine(final String line) {
m_parser.stdout(line);
parser.stdout(line);
} }
} }



+ 1
- 1
src/main/org/apache/tools/ant/taskdefs/cvslib/RedirectingStreamHandler.java View File

@@ -74,7 +74,7 @@ class RedirectingStreamHandler


String getErrors() { String getErrors() {
try { try {
final ByteArrayOutputStream error
final ByteArrayOutputStream error
= (ByteArrayOutputStream) getErr(); = (ByteArrayOutputStream) getErr();


return error.toString("ASCII"); return error.toString("ASCII");


+ 3
- 0
src/main/org/apache/tools/ant/taskdefs/optional/ccm/CCMCheckin.java View File

@@ -63,6 +63,9 @@ import java.util.Date;
*/ */
public class CCMCheckin extends CCMCheck { public class CCMCheckin extends CCMCheck {


/**
* Default constructor - setup checkin command
*/
public CCMCheckin() { public CCMCheckin() {
super(); super();
setCcmAction(COMMAND_CHECKIN); setCcmAction(COMMAND_CHECKIN);


+ 132
- 113
src/main/org/apache/tools/ant/taskdefs/optional/ejb/JonasDeploymentTool.java View File

@@ -77,12 +77,16 @@ import org.apache.tools.ant.types.Path;
public class JonasDeploymentTool extends GenericDeploymentTool { public class JonasDeploymentTool extends GenericDeploymentTool {


/** Public Id of the standard deployment descriptor DTD. */ /** Public Id of the standard deployment descriptor DTD. */
protected static final String EJB_JAR_1_1_PUBLIC_ID = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN";
protected static final String EJB_JAR_2_0_PUBLIC_ID = "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN";
protected static final String EJB_JAR_1_1_PUBLIC_ID
= "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 1.1//EN";
protected static final String EJB_JAR_2_0_PUBLIC_ID
= "-//Sun Microsystems, Inc.//DTD Enterprise JavaBeans 2.0//EN";


/** Public Id of the JOnAS-specific deployment descriptor DTD. */ /** Public Id of the JOnAS-specific deployment descriptor DTD. */
protected static final String JONAS_EJB_JAR_2_4_PUBLIC_ID = "-//ObjectWeb//DTD JOnAS 2.4//EN";
protected static final String JONAS_EJB_JAR_2_5_PUBLIC_ID = "-//ObjectWeb//DTD JOnAS 2.5//EN";
protected static final String JONAS_EJB_JAR_2_4_PUBLIC_ID
= "-//ObjectWeb//DTD JOnAS 2.4//EN";
protected static final String JONAS_EJB_JAR_2_5_PUBLIC_ID
= "-//ObjectWeb//DTD JOnAS 2.5//EN";


/** RMI ORB. */ /** RMI ORB. */
protected static final String RMI_ORB = "RMI"; protected static final String RMI_ORB = "RMI";
@@ -104,8 +108,10 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
* Name of the JOnAS-specific deployment descriptor DTD (these files are * Name of the JOnAS-specific deployment descriptor DTD (these files are
* stored in the ${JONAS_ROOT}/xml directory). * stored in the ${JONAS_ROOT}/xml directory).
*/ */
protected static final String JONAS_EJB_JAR_2_4_DTD = "jonas-ejb-jar_2_4.dtd";
protected static final String JONAS_EJB_JAR_2_5_DTD = "jonas-ejb-jar_2_5.dtd";
protected static final String JONAS_EJB_JAR_2_4_DTD
= "jonas-ejb-jar_2_4.dtd";
protected static final String JONAS_EJB_JAR_2_5_DTD
= "jonas-ejb-jar_2_5.dtd";


/** Default JOnAS deployment descriptor name. */ /** Default JOnAS deployment descriptor name. */
protected static final String JONAS_DD = "jonas-ejb-jar.xml"; protected static final String JONAS_DD = "jonas-ejb-jar.xml";
@@ -215,7 +221,10 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
*/ */
private String orb; private String orb;


/** <code>true</code> if GenIC must not be run on the EJB JAR. The default is <code>false</code>. */
/**
* <code>true</code> if GenIC must not be run on the EJB JAR.
* The default is <code>false</code>.
*/
private boolean nogenic = false; private boolean nogenic = false;


/* -------------------- */ /* -------------------- */
@@ -365,7 +374,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool {


super.processDescriptor(descriptorName, saxParser); super.processDescriptor(descriptorName, saxParser);


if ( outputdir != null ) {
if (outputdir != null) {
// the method deleteOnExit() do not work because the directory is not empty // the method deleteOnExit() do not work because the directory is not empty
log("Deleting temp output directory '" + outputdir + "'.", Project.MSG_VERBOSE); log("Deleting temp output directory '" + outputdir + "'.", Project.MSG_VERBOSE);
deleteAllFiles(outputdir); deleteAllFiles(outputdir);
@@ -378,14 +387,14 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
// create the generic jar first // create the generic jar first
File genericJarFile = super.getVendorOutputJarFile(baseName); File genericJarFile = super.getVendorOutputJarFile(baseName);
super.writeJar(baseName, genericJarFile, ejbFiles, publicId); super.writeJar(baseName, genericJarFile, ejbFiles, publicId);
// GenIC call on generic jar // GenIC call on generic jar
addGenICGeneratedFiles(genericJarFile, ejbFiles); addGenICGeneratedFiles(genericJarFile, ejbFiles);
// create the real jar // create the real jar
super.writeJar(baseName, getVendorOutputJarFile(baseName), ejbFiles, publicId); super.writeJar(baseName, getVendorOutputJarFile(baseName), ejbFiles, publicId);
if ( !keepgeneric ) {
if (!keepgeneric) {
log("Deleting generic JAR " + genericJarFile.toString(), Project.MSG_VERBOSE); log("Deleting generic JAR " + genericJarFile.toString(), Project.MSG_VERBOSE);
genericJarFile.delete(); genericJarFile.delete();
} }
@@ -397,7 +406,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
jonasDescriptorName = getJonasDescriptorName(); jonasDescriptorName = getJonasDescriptorName();
File jonasDD = new File(getConfig().descriptorDir, jonasDescriptorName); File jonasDD = new File(getConfig().descriptorDir, jonasDescriptorName);


if ( jonasDD.exists() ) {
if (jonasDD.exists()) {
ejbFiles.put(META_DIR + JONAS_DD, jonasDD); ejbFiles.put(META_DIR + JONAS_DD, jonasDD);
} else { } else {
log("Unable to locate the JOnAS deployment descriptor. It was expected to be in: " log("Unable to locate the JOnAS deployment descriptor. It was expected to be in: "
@@ -431,18 +440,19 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
String remainder; // Filename appearing after the name terminator String remainder; // Filename appearing after the name terminator


int startOfFileName = descriptorName.lastIndexOf(File.separatorChar); int startOfFileName = descriptorName.lastIndexOf(File.separatorChar);
if ( startOfFileName != -1 ) {
if (startOfFileName != -1) {
// extract path info // extract path info
path = descriptorName.substring(0, startOfFileName+1);
fileName = descriptorName.substring(startOfFileName+1);
path = descriptorName.substring(0, startOfFileName + 1);
fileName = descriptorName.substring(startOfFileName + 1);
} else { } else {
// descriptorName is just a file without path // descriptorName is just a file without path
path = ""; path = "";
fileName = descriptorName; fileName = descriptorName;
} }


if ( fileName.startsWith(EJB_DD) )
if (fileName.startsWith(EJB_DD)) {
return path + JONAS_DD; return path + JONAS_DD;
}


int endOfBaseName = descriptorName.indexOf(getConfig().baseNameTerminator, startOfFileName); int endOfBaseName = descriptorName.indexOf(getConfig().baseNameTerminator, startOfFileName);


@@ -451,7 +461,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
* extension aren't found. These will ensure "jonas-" appears at the * extension aren't found. These will ensure "jonas-" appears at the
* end of the name and before the '.' (if present). * end of the name and before the '.' (if present).
*/ */
if ( endOfBaseName < 0 ) {
if (endOfBaseName < 0) {
// baseNameTerminator not found: the descriptor use the // baseNameTerminator not found: the descriptor use the
// JOnAS naming convention, ie [Foo.xml,jonas-Foo.xml] and // JOnAS naming convention, ie [Foo.xml,jonas-Foo.xml] and
// not [Foo<baseNameTerminator>-ejb-jar.xml, // not [Foo<baseNameTerminator>-ejb-jar.xml,
@@ -468,7 +478,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
baseName = descriptorName.substring(startOfFileName + 1, endOfBaseName + 1); baseName = descriptorName.substring(startOfFileName + 1, endOfBaseName + 1);
remainder = descriptorName.substring(endOfBaseName + 1); remainder = descriptorName.substring(endOfBaseName + 1);


if ( jonasConvention ) {
if (jonasConvention) {
jonasDescriptorName = path + "jonas-" + baseName + ".xml"; jonasDescriptorName = path + "jonas-" + baseName + ".xml";
} else { } else {
jonasDescriptorName = path + baseName + "jonas-" + remainder; jonasDescriptorName = path + baseName + "jonas-" + remainder;
@@ -484,10 +494,10 @@ public class JonasDeploymentTool extends GenericDeploymentTool {


String baseName = null; String baseName = null;


if ( getConfig().namingScheme.getValue().equals(EjbJar.NamingScheme.DESCRIPTOR) ) {
if (getConfig().namingScheme.getValue().equals(EjbJar.NamingScheme.DESCRIPTOR)) {


// try to find JOnAS specific convention name // try to find JOnAS specific convention name
if ( descriptorFileName.indexOf(getConfig().baseNameTerminator) == -1 ) {
if (descriptorFileName.indexOf(getConfig().baseNameTerminator) == -1) {


// baseNameTerminator not found: the descriptor use the // baseNameTerminator not found: the descriptor use the
// JOnAS naming convention, ie [Foo.xml,jonas-Foo.xml] and // JOnAS naming convention, ie [Foo.xml,jonas-Foo.xml] and
@@ -498,19 +508,19 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
int lastSeparatorIndex = aCanonicalDescriptor.lastIndexOf('/'); int lastSeparatorIndex = aCanonicalDescriptor.lastIndexOf('/');
int endOfBaseName; int endOfBaseName;


if ( lastSeparatorIndex != -1 ) {
if (lastSeparatorIndex != -1) {
endOfBaseName = descriptorFileName.indexOf(".xml", lastSeparatorIndex); endOfBaseName = descriptorFileName.indexOf(".xml", lastSeparatorIndex);
} else { } else {
endOfBaseName = descriptorFileName.indexOf(".xml"); endOfBaseName = descriptorFileName.indexOf(".xml");
} }


if ( endOfBaseName != -1 ) {
if (endOfBaseName != -1) {
baseName = descriptorFileName.substring(0, endOfBaseName); baseName = descriptorFileName.substring(0, endOfBaseName);
} }
} }
} }


if ( baseName == null ) {
if (baseName == null) {
// else get standard baseName // else get standard baseName
baseName = super.getJarBaseName(descriptorFileName); baseName = super.getJarBaseName(descriptorFileName);
} }
@@ -525,7 +535,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
jonasroot + File.separator + "xml" + File.separator + EJB_JAR_1_1_DTD); jonasroot + File.separator + "xml" + File.separator + EJB_JAR_1_1_DTD);
handler.registerDTD(EJB_JAR_2_0_PUBLIC_ID, handler.registerDTD(EJB_JAR_2_0_PUBLIC_ID,
jonasroot + File.separator + "xml" + File.separator + EJB_JAR_2_0_DTD); jonasroot + File.separator + "xml" + File.separator + EJB_JAR_2_0_DTD);
handler.registerDTD(JONAS_EJB_JAR_2_4_PUBLIC_ID, handler.registerDTD(JONAS_EJB_JAR_2_4_PUBLIC_ID,
jonasroot + File.separator + "xml" + File.separator + JONAS_EJB_JAR_2_4_DTD); jonasroot + File.separator + "xml" + File.separator + JONAS_EJB_JAR_2_4_DTD);
handler.registerDTD(JONAS_EJB_JAR_2_5_PUBLIC_ID, handler.registerDTD(JONAS_EJB_JAR_2_5_PUBLIC_ID,
@@ -539,29 +549,32 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
* @param ejbFiles the hashtable. * @param ejbFiles the hashtable.
*/ */
private void addGenICGeneratedFiles(File genericJarFile, Hashtable ejbFiles) { private void addGenICGeneratedFiles(File genericJarFile, Hashtable ejbFiles) {
// GenIC task
Java genicTask = null;

// GenIC class (3 GenIC classes for various versions of JOnAS
// are supported)
String genicClass = null;


Java genicTask = null; // GenIC task
String genicClass = null; // GenIC class (3 GenIC classes for various versions of JOnAS are supported)
if ( nogenic ) {
if (nogenic) {
return; return;
} }

genicTask = (Java) getTask().getProject().createTask("java"); genicTask = (Java) getTask().getProject().createTask("java");
genicTask.setTaskName("genic"); genicTask.setTaskName("genic");
genicTask.setFork(true); genicTask.setFork(true);
// jonasroot // jonasroot
genicTask.createJvmarg().setValue("-Dinstall.root=" + jonasroot); genicTask.createJvmarg().setValue("-Dinstall.root=" + jonasroot);
// java policy file // java policy file
String jonasConfigDir = jonasroot + File.separator + "config"; String jonasConfigDir = jonasroot + File.separator + "config";
File javaPolicyFile = new File(jonasConfigDir, "java.policy"); File javaPolicyFile = new File(jonasConfigDir, "java.policy");
if ( javaPolicyFile.exists() ) {
if (javaPolicyFile.exists()) {
genicTask.createJvmarg().setValue("-Djava.security.policy=" genicTask.createJvmarg().setValue("-Djava.security.policy="
+ javaPolicyFile.toString()); + javaPolicyFile.toString());
} }
// outputdir // outputdir
try { try {
outputdir = createTempDir(); outputdir = createTempDir();
@@ -570,121 +583,122 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
throw new BuildException(msg, aIOException); throw new BuildException(msg, aIOException);
} }
log("Using temporary output directory: " + outputdir, Project.MSG_VERBOSE); log("Using temporary output directory: " + outputdir, Project.MSG_VERBOSE);
genicTask.createArg().setValue("-d"); genicTask.createArg().setValue("-d");
genicTask.createArg().setFile(outputdir); genicTask.createArg().setFile(outputdir);
// work around a bug of GenIC 2.5 // work around a bug of GenIC 2.5
String key; String key;
File f; File f;
Enumeration keys = ejbFiles.keys(); Enumeration keys = ejbFiles.keys();
while ( keys.hasMoreElements() ) {
key = (String)keys.nextElement();
while (keys.hasMoreElements()) {
key = (String) keys.nextElement();
f = new File(outputdir + File.separator + key); f = new File(outputdir + File.separator + key);
f.getParentFile().mkdirs(); f.getParentFile().mkdirs();
} }
log("Worked around a bug of GenIC 2.5.", Project.MSG_VERBOSE); log("Worked around a bug of GenIC 2.5.", Project.MSG_VERBOSE);
// classpath // classpath
Path classpath = getCombinedClasspath(); Path classpath = getCombinedClasspath();
if ( classpath == null ) {
if (classpath == null) {
classpath = new Path(getTask().getProject()); classpath = new Path(getTask().getProject());
} }
classpath.append(new Path(classpath.getProject(), jonasConfigDir)); classpath.append(new Path(classpath.getProject(), jonasConfigDir));
classpath.append(new Path(classpath.getProject(), outputdir.toString())); classpath.append(new Path(classpath.getProject(), outputdir.toString()));
// try to create the classpath for the correct ORB // try to create the classpath for the correct ORB
if ( orb != null ) {
String orbJar = jonasroot + File.separator + "lib" + File.separator + orb + "_jonas.jar";
if (orb != null) {
String orbJar = jonasroot + File.separator + "lib"
+ File.separator + orb + "_jonas.jar";
classpath.append(new Path(classpath.getProject(), orbJar)); classpath.append(new Path(classpath.getProject(), orbJar));
} }
log("Using classpath: " + classpath.toString(), Project.MSG_VERBOSE); log("Using classpath: " + classpath.toString(), Project.MSG_VERBOSE);
genicTask.setClasspath(classpath); genicTask.setClasspath(classpath);
// class name (search in the classpath provided for the ejbjar element) // class name (search in the classpath provided for the ejbjar element)
genicClass = getGenicClassName(classpath); genicClass = getGenicClassName(classpath);
if ( genicClass == null ) {
if (genicClass == null) {
log("Cannot find GenIC class in classpath.", Project.MSG_ERR); log("Cannot find GenIC class in classpath.", Project.MSG_ERR);
throw new BuildException("GenIC class not found, please check the classpath."); throw new BuildException("GenIC class not found, please check the classpath.");
} else { } else {
log("Using '" + genicClass + "' GenIC class." , Project.MSG_VERBOSE); log("Using '" + genicClass + "' GenIC class." , Project.MSG_VERBOSE);
genicTask.setClassname(genicClass); genicTask.setClassname(genicClass);
} }
// keepgenerated // keepgenerated
if ( keepgenerated ) {
if (keepgenerated) {
genicTask.createArg().setValue("-keepgenerated"); genicTask.createArg().setValue("-keepgenerated");
} }
// nocompil // nocompil
if ( nocompil ) {
if (nocompil) {
genicTask.createArg().setValue("-nocompil"); genicTask.createArg().setValue("-nocompil");
} }
// novalidation // novalidation
if ( novalidation ) {
if (novalidation) {
genicTask.createArg().setValue("-novalidation"); genicTask.createArg().setValue("-novalidation");
} }
// javac // javac
if ( javac != null ) {
if (javac != null) {
genicTask.createArg().setValue("-javac"); genicTask.createArg().setValue("-javac");
genicTask.createArg().setLine(javac); genicTask.createArg().setLine(javac);
} }
// javacopts // javacopts
if ( javacopts != null && !javacopts.equals("") ) {
if (javacopts != null && !javacopts.equals("")) {
genicTask.createArg().setValue("-javacopts"); genicTask.createArg().setValue("-javacopts");
genicTask.createArg().setLine(javacopts); genicTask.createArg().setLine(javacopts);
} }
// rmicopts // rmicopts
if ( rmicopts != null && !rmicopts.equals("") ) {
if (rmicopts != null && !rmicopts.equals("")) {
genicTask.createArg().setValue("-rmicopts"); genicTask.createArg().setValue("-rmicopts");
genicTask.createArg().setLine(rmicopts); genicTask.createArg().setLine(rmicopts);
} }
// secpropag // secpropag
if ( secpropag ) {
if (secpropag) {
genicTask.createArg().setValue("-secpropag"); genicTask.createArg().setValue("-secpropag");
} }
// verbose // verbose
if ( verbose ) {
if (verbose) {
genicTask.createArg().setValue("-verbose"); genicTask.createArg().setValue("-verbose");
} }
// additionalargs // additionalargs
if ( additionalargs != null ) {
if (additionalargs != null) {
genicTask.createArg().setValue(additionalargs); genicTask.createArg().setValue(additionalargs);
} }
// the generated classes must not be added in the generic JAR! // the generated classes must not be added in the generic JAR!
// is that buggy on old JOnAS (2.4) ?? // is that buggy on old JOnAS (2.4) ??
genicTask.createArg().setValue("-noaddinjar"); genicTask.createArg().setValue("-noaddinjar");
// input file to process by GenIC // input file to process by GenIC
genicTask.createArg().setValue(genericJarFile.getPath()); genicTask.createArg().setValue(genericJarFile.getPath());
// calling GenIC task // calling GenIC task
log("Calling " + genicClass + " for " + getConfig().descriptorDir + File.separator + descriptorName
+ ".", Project.MSG_VERBOSE);
if ( genicTask.executeJava() != 0 ) {
log("Calling " + genicClass + " for " + getConfig().descriptorDir
+ File.separator + descriptorName + ".", Project.MSG_VERBOSE);
if (genicTask.executeJava() != 0) {
// the method deleteOnExit() do not work because the directory is not empty // the method deleteOnExit() do not work because the directory is not empty
log("Deleting temp output directory '" + outputdir + "'.", Project.MSG_VERBOSE); log("Deleting temp output directory '" + outputdir + "'.", Project.MSG_VERBOSE);
deleteAllFiles(outputdir); deleteAllFiles(outputdir);
if ( !keepgeneric ) {
if (!keepgeneric) {
log("Deleting generic JAR " + genericJarFile.toString(), Project.MSG_VERBOSE); log("Deleting generic JAR " + genericJarFile.toString(), Project.MSG_VERBOSE);
genericJarFile.delete(); genericJarFile.delete();
} }
throw new BuildException("GenIC reported an error."); throw new BuildException("GenIC reported an error.");
} }
// add the generated files to the ejbFiles // add the generated files to the ejbFiles
addAllFiles(outputdir, "", ejbFiles); addAllFiles(outputdir, "", ejbFiles);
} }
@@ -698,41 +712,44 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
*/ */
String getGenicClassName(Path classpath) { String getGenicClassName(Path classpath) {


log("Looking for GenIC class in classpath: " + classpath.toString(), Project.MSG_VERBOSE);
log("Looking for GenIC class in classpath: "
+ classpath.toString(), Project.MSG_VERBOSE);

AntClassLoader cl = classpath.getProject().createClassLoader(classpath); AntClassLoader cl = classpath.getProject().createClassLoader(classpath);
try { try {
cl.loadClass(JonasDeploymentTool.GENIC_CLASS); cl.loadClass(JonasDeploymentTool.GENIC_CLASS);
log("Found GenIC class '" + JonasDeploymentTool.GENIC_CLASS + "' in classpath.", Project.MSG_VERBOSE);
log("Found GenIC class '" + JonasDeploymentTool.GENIC_CLASS
+ "' in classpath.", Project.MSG_VERBOSE);
return JonasDeploymentTool.GENIC_CLASS; return JonasDeploymentTool.GENIC_CLASS;
} catch (ClassNotFoundException cnf1) { } catch (ClassNotFoundException cnf1) {
log("GenIC class '" + JonasDeploymentTool.GENIC_CLASS + "' not found in classpath.",
log("GenIC class '" + JonasDeploymentTool.GENIC_CLASS
+ "' not found in classpath.",
Project.MSG_VERBOSE); Project.MSG_VERBOSE);
} }
try { try {
cl.loadClass(JonasDeploymentTool.OLD_GENIC_CLASS_1); cl.loadClass(JonasDeploymentTool.OLD_GENIC_CLASS_1);
log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1 +
"' in classpath.", Project.MSG_VERBOSE);
log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1
+ "' in classpath.", Project.MSG_VERBOSE);
return JonasDeploymentTool.OLD_GENIC_CLASS_1; return JonasDeploymentTool.OLD_GENIC_CLASS_1;
} catch (ClassNotFoundException cnf2) { } catch (ClassNotFoundException cnf2) {
log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1 +
"' not found in classpath.",
log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_1
+ "' not found in classpath.",
Project.MSG_VERBOSE); Project.MSG_VERBOSE);
} }
try { try {
cl.loadClass(JonasDeploymentTool.OLD_GENIC_CLASS_2); cl.loadClass(JonasDeploymentTool.OLD_GENIC_CLASS_2);
log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2 +
"' in classpath.", Project.MSG_VERBOSE);
log("Found GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2
+ "' in classpath.", Project.MSG_VERBOSE);
return JonasDeploymentTool.OLD_GENIC_CLASS_2; return JonasDeploymentTool.OLD_GENIC_CLASS_2;
} catch (ClassNotFoundException cnf3) { } catch (ClassNotFoundException cnf3) {
log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2 +
"' not found in classpath.",
log("GenIC class '" + JonasDeploymentTool.OLD_GENIC_CLASS_2
+ "' not found in classpath.",
Project.MSG_VERBOSE); Project.MSG_VERBOSE);
} }
return null; return null;
@@ -742,26 +759,28 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
SAXParser saxParser) throws BuildException { SAXParser saxParser) throws BuildException {


// jonasroot // jonasroot
if ( jonasroot == null ) {
if (jonasroot == null) {
throw new BuildException("The jonasroot attribut is not set."); throw new BuildException("The jonasroot attribut is not set.");
} else if ( !jonasroot.isDirectory() ) {
throw new BuildException("The jonasroot attribut '" + jonasroot +
"' is not a valid directory.");
} else if (!jonasroot.isDirectory()) {
throw new BuildException("The jonasroot attribut '" + jonasroot
+ "' is not a valid directory.");
} }
// orb // orb
if ( orb != null && !orb.equals(RMI_ORB) && !orb.equals(JEREMIE_ORB) && !orb.equals(DAVID_ORB) ) {
throw new BuildException("The orb attribut '" + orb + "' is not valid (must be either " +
RMI_ORB + ", " + JEREMIE_ORB + " or " + DAVID_ORB + ").");
if (orb != null && !orb.equals(RMI_ORB) && !orb.equals(JEREMIE_ORB)
&& !orb.equals(DAVID_ORB)) {
throw new BuildException("The orb attribut '" + orb
+ "' is not valid (must be either "
+ RMI_ORB + ", " + JEREMIE_ORB + " or " + DAVID_ORB + ").");
} }
// additionalargs // additionalargs
if ( additionalargs != null && additionalargs.equals("") ) {
if (additionalargs != null && additionalargs.equals("")) {
throw new BuildException("Empty additionalargs attribut."); throw new BuildException("Empty additionalargs attribut.");
} }
// javac // javac
if ( javac != null && javac.equals("") ) {
if (javac != null && javac.equals("")) {
throw new BuildException("Empty javac attribut."); throw new BuildException("Empty javac attribut.");
} }
} }
@@ -779,7 +798,7 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
private File createTempDir() throws IOException { private File createTempDir() throws IOException {
File tmpDir = File.createTempFile("genic", null, null); File tmpDir = File.createTempFile("genic", null, null);
tmpDir.delete(); tmpDir.delete();
if ( !tmpDir.mkdir() ) {
if (!tmpDir.mkdir()) {
throw new IOException("Cannot create the temporary directory '" + tmpDir + "'."); throw new IOException("Cannot create the temporary directory '" + tmpDir + "'.");
} }
return tmpDir; return tmpDir;
@@ -792,8 +811,8 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
* @param aFile file to delete. * @param aFile file to delete.
*/ */
private void deleteAllFiles(File aFile) { private void deleteAllFiles(File aFile) {
if ( aFile.isDirectory() ) {
File someFiles[] = aFile.listFiles();
if (aFile.isDirectory()) {
File[] someFiles = aFile.listFiles();


for (int i = 0; i < someFiles.length; i++) { for (int i = 0; i < someFiles.length; i++) {
deleteAllFiles(someFiles[i]); deleteAllFiles(someFiles[i]);
@@ -812,15 +831,15 @@ public class JonasDeploymentTool extends GenericDeploymentTool {
*/ */
private void addAllFiles(File file, String rootDir, Hashtable hashtable) { private void addAllFiles(File file, String rootDir, Hashtable hashtable) {


if ( !file.exists() ) {
if (!file.exists()) {
throw new IllegalArgumentException(); throw new IllegalArgumentException();
} }


String newRootDir; String newRootDir;
if ( file.isDirectory() ) {
File files[] = file.listFiles();
if (file.isDirectory()) {
File[] files = file.listFiles();
for (int i = 0; i < files.length; i++) { for (int i = 0; i < files.length; i++) {
if ( rootDir.length() > 0 ) {
if (rootDir.length() > 0) {
newRootDir = rootDir + File.separator + files[i].getName(); newRootDir = rootDir + File.separator + files[i].getName();
} else { } else {
newRootDir = files[i].getName(); newRootDir = files[i].getName();


+ 27
- 18
src/main/org/apache/tools/ant/taskdefs/optional/j2ee/JonasHotDeploymentTool.java View File

@@ -96,7 +96,7 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements
* Description of the Field * Description of the Field
*/ */
private File jonasroot; private File jonasroot;
/** /**
* Description of the Field * Description of the Field
*/ */
@@ -106,7 +106,7 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements
* Description of the Field * Description of the Field
*/ */
private String davidHost; private String davidHost;
/** /**
* Description of the Field * Description of the Field
*/ */
@@ -114,7 +114,7 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements




/** /**
* Set the host for the David ORB; required if
* Set the host for the David ORB; required if
* ORB==david. * ORB==david.
* *
*@param inValue The new davidhost value *@param inValue The new davidhost value
@@ -125,7 +125,7 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements




/** /**
* Set the port for the David ORB; required if
* Set the port for the David ORB; required if
* ORB==david. * ORB==david.
* *
*@param inValue The new davidport value *@param inValue The new davidport value
@@ -147,11 +147,11 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements




/** /**
*
*
* Choose your ORB : RMI, JEREMIE, DAVID, ...; optional. * Choose your ORB : RMI, JEREMIE, DAVID, ...; optional.
* If omitted, it defaults * If omitted, it defaults
* to the one present in classpath. The corresponding JOnAS JAR is * to the one present in classpath. The corresponding JOnAS JAR is
* automatically added to the classpath. If your orb is DAVID (RMI/IIOP) you must
* automatically added to the classpath. If your orb is DAVID (RMI/IIOP) you must
* specify davidhost and davidport properties. * specify davidhost and davidport properties.
* *
*@param inValue RMI, JEREMIE, DAVID,... *@param inValue RMI, JEREMIE, DAVID,...
@@ -217,21 +217,30 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements


if (jonasroot == null || jonasroot.isDirectory()) { if (jonasroot == null || jonasroot.isDirectory()) {
java.createJvmarg().setValue("-Dinstall.root=" + jonasroot); java.createJvmarg().setValue("-Dinstall.root=" + jonasroot);
java.createJvmarg().setValue("-Djava.security.policy=" + jonasroot + "/config/java.policy");
java.createJvmarg().setValue("-Djava.security.policy=" + jonasroot
+ "/config/java.policy");


if ("DAVID".equals(orb)) { if ("DAVID".equals(orb)) {
java.createJvmarg().setValue("-Dorg.omg.CORBA.ORBClass=org.objectweb.david.libs.binding.orbs.iiop.IIOPORB");
java.createJvmarg().setValue("-Dorg.omg.CORBA.ORBSingletonClass=org.objectweb.david.libs.binding.orbs.ORBSingletonClass");
java.createJvmarg().setValue("-Djavax.rmi.CORBA.StubClass=org.objectweb.david.libs.stub_factories.rmi.StubDelegate");
java.createJvmarg().setValue("-Djavax.rmi.CORBA.PortableRemoteObjectClass=org.objectweb.david.libs.binding.rmi.ORBPortableRemoteObjectDelegate");
java.createJvmarg().setValue("-Djavax.rmi.CORBA.UtilClass=org.objectweb.david.libs.helpers.RMIUtilDelegate");
java.createJvmarg().setValue("-Dorg.omg.CORBA.ORBClass"
+ "=org.objectweb.david.libs.binding.orbs.iiop.IIOPORB");
java.createJvmarg().setValue("-Dorg.omg.CORBA.ORBSingletonClass="
+ "org.objectweb.david.libs.binding.orbs.ORBSingletonClass");
java.createJvmarg().setValue("-Djavax.rmi.CORBA.StubClass="
+ "org.objectweb.david.libs.stub_factories.rmi.StubDelegate");
java.createJvmarg().setValue("-Djavax.rmi.CORBA.PortableRemoteObjectClass="
+ "org.objectweb.david.libs.binding.rmi.ORBPortableRemoteObjectDelegate");
java.createJvmarg().setValue("-Djavax.rmi.CORBA.UtilClass="
+ "org.objectweb.david.libs.helpers.RMIUtilDelegate");
java.createJvmarg().setValue("-Ddavid.CosNaming.default_method=0"); java.createJvmarg().setValue("-Ddavid.CosNaming.default_method=0");
java.createJvmarg().setValue("-Ddavid.rmi.ValueHandlerClass=com.sun.corba.se.internal.io.ValueHandlerImpl");
java.createJvmarg().setValue("-Ddavid.rmi.ValueHandlerClass="
+ "com.sun.corba.se.internal.io.ValueHandlerImpl");
if (davidHost != null) { if (davidHost != null) {
java.createJvmarg().setValue("-Ddavid.CosNaming.default_host=" + davidHost);
java.createJvmarg().setValue("-Ddavid.CosNaming.default_host="
+ davidHost);
} }
if (davidPort != 0) { if (davidPort != 0) {
java.createJvmarg().setValue("-Ddavid.CosNaming.default_port=" + davidPort);
java.createJvmarg().setValue("-Ddavid.CosNaming.default_port="
+ davidPort);
} }
} }
} }
@@ -240,9 +249,9 @@ public class JonasHotDeploymentTool extends GenericHotDeploymentTool implements
java.createArg().setLine("-n " + getServer()); java.createArg().setLine("-n " + getServer());
} }


if (action.equals(ACTION_DEPLOY) ||
action.equals(ACTION_UPDATE) ||
action.equals("redeploy")) {
if (action.equals(ACTION_DEPLOY)
|| action.equals(ACTION_UPDATE)
|| action.equals("redeploy")) {
java.createArg().setLine("-a " + getTask().getSource()); java.createArg().setLine("-a " + getTask().getSource());
} else if (action.equals(ACTION_DELETE) || action.equals(ACTION_UNDEPLOY)) { } else if (action.equals(ACTION_DELETE) || action.equals(ACTION_UNDEPLOY)) {
java.createArg().setLine("-r " + getTask().getSource()); java.createArg().setLine("-r " + getTask().getSource());


+ 162
- 86
src/main/org/apache/tools/ant/taskdefs/optional/net/FTP.java View File

@@ -87,7 +87,7 @@ import org.apache.tools.ant.util.FileUtils;
* <li> <strong>del</strong> - delete files from a remote server.</li> * <li> <strong>del</strong> - delete files from a remote server.</li>
* <li> <strong>list</strong> - create a file listing.</li> * <li> <strong>list</strong> - create a file listing.</li>
* <li> <strong>chmod</strong> - change unix file permissions.</li> * <li> <strong>chmod</strong> - change unix file permissions.</li>
* <li> <strong>rmdir</strong> - remove directories, if empty, from a
* <li> <strong>rmdir</strong> - remove directories, if empty, from a
* remote server.</li> * remote server.</li>
* </ul> * </ul>
* <strong>Note:</strong> Some FTP servers - notably the Solaris server - seem * <strong>Note:</strong> Some FTP servers - notably the Solaris server - seem
@@ -115,6 +115,9 @@ public class FTP
protected static final int CHMOD = 5; protected static final int CHMOD = 5;
protected static final int RM_DIR = 6; protected static final int RM_DIR = 6;


/** Default port for FTP */
public static final int DEFAULT_FTP_PORT = 21;

private String remotedir; private String remotedir;
private String server; private String server;
private String userid; private String userid;
@@ -129,7 +132,7 @@ public class FTP
private Vector dirCache = new Vector(); private Vector dirCache = new Vector();
private int transferred = 0; private int transferred = 0;
private String remoteFileSep = "/"; private String remoteFileSep = "/";
private int port = 21;
private int port = DEFAULT_FTP_PORT;
private boolean skipFailedTransfers = false; private boolean skipFailedTransfers = false;
private int skipped = 0; private int skipped = 0;
private boolean ignoreNoncriticalErrors = false; private boolean ignoreNoncriticalErrors = false;
@@ -282,31 +285,49 @@ public class FTP
* Sets the remote directory where files will be placed. This may be a * Sets the remote directory where files will be placed. This may be a
* relative or absolute path, and must be in the path syntax expected by * relative or absolute path, and must be in the path syntax expected by
* the remote server. No correction of path syntax will be performed. * the remote server. No correction of path syntax will be performed.
*
* @param dir the remote directory name.
*/ */
public void setRemotedir(String dir) { public void setRemotedir(String dir) {
this.remotedir = dir; this.remotedir = dir;
} }




/** Sets the FTP server to send files to. */
/**
* Sets the FTP server to send files to.
*
* @param server the remote server name.
*/
public void setServer(String server) { public void setServer(String server) {
this.server = server; this.server = server;
} }




/** Sets the FTP port used by the remote server. */
/**
* Sets the FTP port used by the remote server.
*
* @param port the port on which the remote server is listening.
*/
public void setPort(int port) { public void setPort(int port) {
this.port = port; this.port = port;
} }




/** Sets the login user id to use on the specified server. */
/**
* Sets the login user id to use on the specified server.
*
* @param userid remote system userid.
*/
public void setUserid(String userid) { public void setUserid(String userid) {
this.userid = userid; this.userid = userid;
} }




/** Sets the login password for the given user id. */
/**
* Sets the login password for the given user id.
*
* @param password the password on the remote system.
*/
public void setPassword(String password) { public void setPassword(String password) {
this.password = password; this.password = password;
} }
@@ -314,6 +335,8 @@ public class FTP


/** /**
* If true, uses binary mode, otherwise text mode (default is binary). * If true, uses binary mode, otherwise text mode (default is binary).
*
* @param binary if true use binary mode in transfers.
*/ */
public void setBinary(boolean binary) { public void setBinary(boolean binary) {
this.binary = binary; this.binary = binary;
@@ -324,6 +347,8 @@ public class FTP
* Specifies whether to use passive mode. Set to true if you are behind a * Specifies whether to use passive mode. Set to true if you are behind a
* firewall and cannot connect without it. Passive mode is disabled by * firewall and cannot connect without it. Passive mode is disabled by
* default. * default.
*
* @param passive true is passive mode should be used.
*/ */
public void setPassive(boolean passive) { public void setPassive(boolean passive) {
this.passive = passive; this.passive = passive;
@@ -333,6 +358,8 @@ public class FTP
/** /**
* Set to true to receive notification about each file as it is * Set to true to receive notification about each file as it is
* transferred. * transferred.
*
* @param verbose true if verbose notifications are required.
*/ */
public void setVerbose(boolean verbose) { public void setVerbose(boolean verbose) {
this.verbose = verbose; this.verbose = verbose;
@@ -340,8 +367,10 @@ public class FTP




/** /**
* A synonym for <tt>depends</tt>. Set to true to transmit only new or changed
* files.
* A synonym for <tt>depends</tt>. Set to true to transmit only new
* or changed files.
*
* @param newer if true only transfer newer files.
*/ */
public void setNewer(boolean newer) { public void setNewer(boolean newer) {
this.newerOnly = newer; this.newerOnly = newer;
@@ -350,6 +379,8 @@ public class FTP


/** /**
* Set to true to preserve modification times for "gotten" files. * Set to true to preserve modification times for "gotten" files.
*
* @param preserveLastModified if true preserver modification times.
*/ */
public void setPreserveLastModified(boolean preserveLastModified) { public void setPreserveLastModified(boolean preserveLastModified) {
this.preserveLastModified = preserveLastModified; this.preserveLastModified = preserveLastModified;
@@ -359,6 +390,8 @@ public class FTP
/** /**
* Set to true to transmit only files that are new or changed from their * Set to true to transmit only files that are new or changed from their
* remote counterparts. The default is to transmit all files. * remote counterparts. The default is to transmit all files.
*
* @param depends if true only transfer newer files.
*/ */
public void setDepends(boolean depends) { public void setDepends(boolean depends) {
this.newerOnly = depends; this.newerOnly = depends;
@@ -370,6 +403,8 @@ public class FTP
* Unix standard forward slash, but can be manually overridden using this * Unix standard forward slash, but can be manually overridden using this
* call if the remote server requires some other separator. Only the first * call if the remote server requires some other separator. Only the first
* character of the string is used. * character of the string is used.
*
* @param separator the file separator on the remote system.
*/ */
public void setSeparator(String separator) { public void setSeparator(String separator) {
remoteFileSep = separator; remoteFileSep = separator;
@@ -377,16 +412,22 @@ public class FTP




/** /**
* Sets the file permission mode (Unix only) for files sent to the server.
* Sets the file permission mode (Unix only) for files sent to the
* server.
*
* @param theMode unix style file mode for the files sent to the remote
* system.
*/ */

public void setChmod(String theMode) { public void setChmod(String theMode) {
this.chmod = theMode; this.chmod = theMode;
} }




/** Sets the default mask for file creation on a unix server. */

/**
* Sets the default mask for file creation on a unix server.
*
* @param theUmask unix style umask for files created on the remote server.
*/
public void setUmask(String theUmask) { public void setUmask(String theUmask) {
this.umask = theUmask; this.umask = theUmask;
} }
@@ -394,6 +435,9 @@ public class FTP


/** /**
* A set of files to upload or download * A set of files to upload or download
*
* @param set the set of files to be added to the list of files to be
* transferred.
*/ */
public void addFileset(FileSet set) { public void addFileset(FileSet set) {
filesets.addElement(set); filesets.addElement(set);
@@ -409,6 +453,10 @@ public class FTP
* work and also to encapsulate operations on the type in its own * work and also to encapsulate operations on the type in its own
* class. * class.
* @ant.attribute ignore="true" * @ant.attribute ignore="true"
*
* @param action the FTP action to be performed.
*
* @throws BuildException if the action is not a valid action.
*/ */
public void setAction(String action) throws BuildException { public void setAction(String action) throws BuildException {
log("DEPRECATED - The setAction(String) method has been deprecated." log("DEPRECATED - The setAction(String) method has been deprecated."
@@ -424,6 +472,10 @@ public class FTP
/** /**
* Sets the FTP action to be taken. Currently accepts "put", "get", "del", * Sets the FTP action to be taken. Currently accepts "put", "get", "del",
* "mkdir", "chmod" and "list". * "mkdir", "chmod" and "list".
*
* @param action the FTP action to be performed.
*
* @throws BuildException if the action is not a valid action.
*/ */
public void setAction(Action action) throws BuildException { public void setAction(Action action) throws BuildException {
this.action = action.getAction(); this.action = action.getAction();
@@ -433,8 +485,10 @@ public class FTP
/** /**
* The output file for the "list" action. This attribute is ignored for * The output file for the "list" action. This attribute is ignored for
* any other actions. * any other actions.
*
* @param listing file in which to store the listing.
*/ */
public void setListing(File listing) throws BuildException {
public void setListing(File listing) {
this.listing = listing; this.listing = listing;
} }


@@ -443,6 +497,8 @@ public class FTP
* If true, enables unsuccessful file put, delete and get * If true, enables unsuccessful file put, delete and get
* operations to be skipped with a warning and the remainder * operations to be skipped with a warning and the remainder
* of the files still transferred. * of the files still transferred.
*
* @param skipFailedTransfers true if failures in transfers are ignored.
*/ */
public void setSkipFailedTransfers(boolean skipFailedTransfers) { public void setSkipFailedTransfers(boolean skipFailedTransfers) {
this.skipFailedTransfers = skipFailedTransfers; this.skipFailedTransfers = skipFailedTransfers;
@@ -452,13 +508,20 @@ public class FTP
/** /**
* set the flag to skip errors on directory creation. * set the flag to skip errors on directory creation.
* (and maybe later other server specific errors) * (and maybe later other server specific errors)
*
* @param ignoreNoncriticalErrors true if non-critical errors should not
* cause a failure.
*/ */
public void setIgnoreNoncriticalErrors(boolean ignoreNoncriticalErrors) { public void setIgnoreNoncriticalErrors(boolean ignoreNoncriticalErrors) {
this.ignoreNoncriticalErrors = ignoreNoncriticalErrors; this.ignoreNoncriticalErrors = ignoreNoncriticalErrors;
} }




/** Checks to see that all required parameters are set. */
/**
* Checks to see that all required parameters are set.
*
* @throws BuildException if the configuration is not valid.
*/
protected void checkConfiguration() throws BuildException { protected void checkConfiguration() throws BuildException {
if (server == null) { if (server == null) {
throw new BuildException("server attribute must be set!"); throw new BuildException("server attribute must be set!");
@@ -490,6 +553,14 @@ public class FTP
/** /**
* For each file in the fileset, do the appropriate action: send, get, * For each file in the fileset, do the appropriate action: send, get,
* delete, or list. * delete, or list.
*
* @param ftp the FTPClient instance used to perform FTP actions
* @param fs the fileset on which the actions are performed.
*
* @return the number of files to be transferred.
*
* @throws IOException if there is a problem reading a file
* @throws BuildException if there is a problem in the configuration.
*/ */
protected int transferFiles(FTPClient ftp, FileSet fs) protected int transferFiles(FTPClient ftp, FileSet fs)
throws IOException, BuildException { throws IOException, BuildException {
@@ -537,46 +608,26 @@ public class FTP
for (int i = 0; i < dsfiles.length; i++) { for (int i = 0; i < dsfiles.length; i++) {
switch (action) { switch (action) {
case SEND_FILES: case SEND_FILES:
{
sendFile(ftp, dir, dsfiles[i]); sendFile(ftp, dir, dsfiles[i]);
break; break;
}

case GET_FILES: case GET_FILES:
{
getFile(ftp, dir, dsfiles[i]); getFile(ftp, dir, dsfiles[i]);
break; break;
}

case DEL_FILES: case DEL_FILES:
{
delFile(ftp, dsfiles[i]); delFile(ftp, dsfiles[i]);
break; break;
}

case LIST_FILES: case LIST_FILES:
{
listFile(ftp, bw, dsfiles[i]); listFile(ftp, bw, dsfiles[i]);
break; break;
}

case CHMOD: case CHMOD:
{
doSiteCommand(ftp, "chmod " + chmod + " " + dsfiles[i]); doSiteCommand(ftp, "chmod " + chmod + " " + dsfiles[i]);
transferred++; transferred++;
break; break;
}

case RM_DIR: case RM_DIR:
{
rmDir(ftp, dsfiles[i]); rmDir(ftp, dsfiles[i]);
break; break;
}

default: default:
{
throw new BuildException("unknown ftp action " + action); throw new BuildException("unknown ftp action " + action);
}
} }
} }
} finally { } finally {
@@ -592,6 +643,11 @@ public class FTP
/** /**
* Sends all files specified by the configured filesets to the remote * Sends all files specified by the configured filesets to the remote
* server. * server.
*
* @param ftp the FTPClient instance used to perform FTP actions
*
* @throws IOException if there is a problem reading a file
* @throws BuildException if there is a problem in the configuration.
*/ */
protected void transferFiles(FTPClient ftp) protected void transferFiles(FTPClient ftp)
throws IOException, BuildException { throws IOException, BuildException {
@@ -611,12 +667,11 @@ public class FTP
} }
} }


log(transferred + " " + ACTION_TARGET_STRS[action] + " " +
COMPLETED_ACTION_STRS[action]);
log(transferred + " " + ACTION_TARGET_STRS[action] + " "
+ COMPLETED_ACTION_STRS[action]);
if (skipped != 0) { if (skipped != 0) {
log(skipped + " " + ACTION_TARGET_STRS[action] +
" were not successfully "
+ COMPLETED_ACTION_STRS[action]);
log(skipped + " " + ACTION_TARGET_STRS[action]
+ " were not successfully " + COMPLETED_ACTION_STRS[action]);
} }
} }


@@ -627,6 +682,10 @@ public class FTP
* Unix-style paths with forward-slash separators. This can be overridden * Unix-style paths with forward-slash separators. This can be overridden
* with the <code>separator</code> task parameter. No attempt is made to * with the <code>separator</code> task parameter. No attempt is made to
* determine what syntax is appropriate for the remote host. * determine what syntax is appropriate for the remote host.
*
* @param file the remote file name to be resolved
*
* @return the filename as it will appear on the server.
*/ */
protected String resolveFile(String file) { protected String resolveFile(String file) {
return file.replace(System.getProperty("file.separator").charAt(0), return file.replace(System.getProperty("file.separator").charAt(0),
@@ -638,6 +697,11 @@ public class FTP
* Creates all parent directories specified in a complete relative * Creates all parent directories specified in a complete relative
* pathname. Attempts to create existing directories will not cause * pathname. Attempts to create existing directories will not cause
* errors. * errors.
*
* @param ftp the FTP client instance to use to execute FTP actions on
* the remote server.
* @param filename the name of the file whose parents should be created.
*
*/ */
protected void createParents(FTPClient ftp, String filename) protected void createParents(FTPClient ftp, String filename)
throws IOException, BuildException { throws IOException, BuildException {
@@ -647,7 +711,7 @@ public class FTP
return; return;
} }


Vector parents = new Vector(); Vector parents = new Vector();
String dirname; String dirname;


@@ -662,35 +726,35 @@ public class FTP


// find first non cached dir // find first non cached dir
int i = parents.size() - 1; int i = parents.size() - 1;
if (i >= 0) { if (i >= 0) {
String cwd = ftp.printWorkingDirectory(); String cwd = ftp.printWorkingDirectory();
String parent = dir.getParent(); String parent = dir.getParent();
if (parent != null) { if (parent != null) {
if (!ftp.changeWorkingDirectory(resolveFile(parent))) { if (!ftp.changeWorkingDirectory(resolveFile(parent))) {
throw new BuildException("could not change to "
throw new BuildException("could not change to "
+ "directory: " + ftp.getReplyString()); + "directory: " + ftp.getReplyString());
} }
} }
while (i >= 0) { while (i >= 0) {
dir = (File) parents.elementAt(i--); dir = (File) parents.elementAt(i--);
// check if dir exists by trying to change into it. // check if dir exists by trying to change into it.
if (!ftp.changeWorkingDirectory(dir.getName())) { if (!ftp.changeWorkingDirectory(dir.getName())) {
// could not change to it - try to create it // could not change to it - try to create it
log("creating remote directory "
log("creating remote directory "
+ resolveFile(dir.getPath()), Project.MSG_VERBOSE); + resolveFile(dir.getPath()), Project.MSG_VERBOSE);
if(!ftp.makeDirectory(dir.getName())) {
if (!ftp.makeDirectory(dir.getName())) {
handleMkDirFailure(ftp); handleMkDirFailure(ftp);
} }
if (!ftp.changeWorkingDirectory(dir.getName())) { if (!ftp.changeWorkingDirectory(dir.getName())) {
throw new BuildException("could not change to "
throw new BuildException("could not change to "
+ "directory: " + ftp.getReplyString()); + "directory: " + ftp.getReplyString());
} }
} }
dirCache.addElement(dir); dirCache.addElement(dir);
} }
ftp.changeWorkingDirectory(cwd);
ftp.changeWorkingDirectory(cwd);
} }
} }


@@ -717,8 +781,8 @@ public class FTP
+ "assuming out of date.", Project.MSG_VERBOSE); + "assuming out of date.", Project.MSG_VERBOSE);
return false; return false;
} else { } else {
throw new BuildException("could not date test remote file: " +
ftp.getReplyString());
throw new BuildException("could not date test remote file: "
+ ftp.getReplyString());
} }
} }


@@ -734,24 +798,24 @@ public class FTP




/** Sends a site command to the ftp server */ /** Sends a site command to the ftp server */
protected void doSiteCommand(FTPClient ftp, String TheCMD)
protected void doSiteCommand(FTPClient ftp, String theCMD)
throws IOException, BuildException { throws IOException, BuildException {
boolean rc; boolean rc;
String MyReply[] = null;
String myReply[] = null;


log("Doing Site Command: " + TheCMD, Project.MSG_VERBOSE);
log("Doing Site Command: " + theCMD, Project.MSG_VERBOSE);


rc = ftp.sendSiteCommand(TheCMD);
rc = ftp.sendSiteCommand(theCMD);


if (rc == false) { if (rc == false) {
log("Failed to issue Site Command: " + TheCMD, Project.MSG_WARN);
log("Failed to issue Site Command: " + theCMD, Project.MSG_WARN);
} else { } else {


MyReply = ftp.getReplyStrings();
myReply = ftp.getReplyStrings();


for (int x = 0; x < MyReply.length; x++) {
if (MyReply[x].indexOf("200") == -1) {
log(MyReply[x], Project.MSG_WARN);
for (int x = 0; x < myReply.length; x++) {
if (myReply[x].indexOf("200") == -1) {
log(myReply[x], Project.MSG_WARN);
} }
} }
} }
@@ -794,7 +858,7 @@ public class FTP
if (!success) { if (!success) {
String s = "could not put file: " + ftp.getReplyString(); String s = "could not put file: " + ftp.getReplyString();


if (skipFailedTransfers == true) {
if (skipFailedTransfers) {
log(s, Project.MSG_WARN); log(s, Project.MSG_WARN);
skipped++; skipped++;
} else { } else {
@@ -802,7 +866,8 @@ public class FTP
} }


} else { } else {
if (chmod != null) {// see if we should issue a chmod command
// see if we should issue a chmod command
if (chmod != null) {
doSiteCommand(ftp, "chmod " + chmod + " " + filename); doSiteCommand(ftp, "chmod " + chmod + " " + filename);
} }
log("File " + file.getAbsolutePath() + " copied to " + server, log("File " + file.getAbsolutePath() + " copied to " + server,
@@ -831,7 +896,7 @@ public class FTP
if (!ftp.deleteFile(resolveFile(filename))) { if (!ftp.deleteFile(resolveFile(filename))) {
String s = "could not delete file: " + ftp.getReplyString(); String s = "could not delete file: " + ftp.getReplyString();


if (skipFailedTransfers == true) {
if (skipFailedTransfers) {
log(s, Project.MSG_WARN); log(s, Project.MSG_WARN);
skipped++; skipped++;
} else { } else {
@@ -854,7 +919,7 @@ public class FTP
if (!ftp.removeDirectory(resolveFile(dirname))) { if (!ftp.removeDirectory(resolveFile(dirname))) {
String s = "could not remove directory: " + ftp.getReplyString(); String s = "could not remove directory: " + ftp.getReplyString();


if (skipFailedTransfers == true) {
if (skipFailedTransfers) {
log(s, Project.MSG_WARN); log(s, Project.MSG_WARN);
skipped++; skipped++;
} else { } else {
@@ -904,7 +969,7 @@ public class FTP
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
String s = "could not get file: " + ftp.getReplyString(); String s = "could not get file: " + ftp.getReplyString();


if (skipFailedTransfers == true) {
if (skipFailedTransfers) {
log(s, Project.MSG_WARN); log(s, Project.MSG_WARN);
skipped++; skipped++;
} else { } else {
@@ -984,13 +1049,15 @@ public class FTP
subdir = st.nextToken(); subdir = st.nextToken();
log("Checking " + subdir, Project.MSG_DEBUG); log("Checking " + subdir, Project.MSG_DEBUG);
if (!ftp.changeWorkingDirectory(subdir)) { if (!ftp.changeWorkingDirectory(subdir)) {
if(!ftp.makeDirectory(subdir)) {
if (!ftp.makeDirectory(subdir)) {
// codes 521, 550 and 553 can be produced by FTP Servers // codes 521, 550 and 553 can be produced by FTP Servers
// to indicate that an attempt to create a directory has // to indicate that an attempt to create a directory has
// failed because the directory already exists. // failed because the directory already exists.
int rc = ftp.getReplyCode(); int rc = ftp.getReplyCode();
if (!(ignoreNoncriticalErrors && (rc == 550 || rc == 553 || rc==521))) {
throw new BuildException("could not create directory: " + ftp.getReplyString());
if (!(ignoreNoncriticalErrors
&& (rc == 550 || rc == 553 || rc == 521))) {
throw new BuildException("could not create directory: "
+ ftp.getReplyString());
} }
if (verbose) { if (verbose) {
log("Directory already exists"); log("Directory already exists");
@@ -1016,17 +1083,21 @@ public class FTP
*/ */
private void handleMkDirFailure(FTPClient ftp) private void handleMkDirFailure(FTPClient ftp)
throws BuildException { throws BuildException {
int rc=ftp.getReplyCode();
int rc = ftp.getReplyCode();
if (!(ignoreNoncriticalErrors if (!(ignoreNoncriticalErrors
&& (rc == 550 || rc == 553 || rc == 521))) { && (rc == 550 || rc == 553 || rc == 521))) {
throw new BuildException("could not create directory: " +
ftp.getReplyString());
throw new BuildException("could not create directory: "
+ ftp.getReplyString());
} }
} }


/** Runs the task. */
public void execute()
throws BuildException {
/**
* Runs the task.
*
* @throws BuildException if the task fails or is not configured
* correctly.
*/
public void execute() throws BuildException {
checkConfiguration(); checkConfiguration();


FTPClient ftp = null; FTPClient ftp = null;
@@ -1054,8 +1125,8 @@ public class FTP
if (binary) { if (binary) {
ftp.setFileType(org.apache.commons.net.ftp.FTP.IMAGE_FILE_TYPE); ftp.setFileType(org.apache.commons.net.ftp.FTP.IMAGE_FILE_TYPE);
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
throw new BuildException("could not set transfer type: " +
ftp.getReplyString());
throw new BuildException("could not set transfer type: "
+ ftp.getReplyString());
} }
} }


@@ -1064,8 +1135,7 @@ public class FTP
ftp.enterLocalPassiveMode(); ftp.enterLocalPassiveMode();
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
throw new BuildException("could not enter into passive " throw new BuildException("could not enter into passive "
+ "mode: " +
ftp.getReplyString());
+ "mode: " + ftp.getReplyString());
} }
} }


@@ -1087,8 +1157,7 @@ public class FTP
ftp.changeWorkingDirectory(remotedir); ftp.changeWorkingDirectory(remotedir);
if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) { if (!FTPReply.isPositiveCompletion(ftp.getReplyCode())) {
throw new BuildException("could not change remote " throw new BuildException("could not change remote "
+ "directory: " +
ftp.getReplyString());
+ "directory: " + ftp.getReplyString());
} }
} }
log(ACTION_STRS[action] + " " + ACTION_TARGET_STRS[action]); log(ACTION_STRS[action] + " " + ACTION_TARGET_STRS[action]);
@@ -1118,28 +1187,35 @@ public class FTP
*/ */
public static class Action extends EnumeratedAttribute { public static class Action extends EnumeratedAttribute {


private static final String[] validActions = {
private static final String[] VALID_ACTIONS = {
"send", "put", "recv", "get", "del", "delete", "list", "mkdir", "send", "put", "recv", "get", "del", "delete", "list", "mkdir",
"chmod", "rmdir" "chmod", "rmdir"
}; };




/**
* Get the valid values
*
* @return an array of the valid FTP actions.
*/
public String[] getValues() { public String[] getValues() {
return validActions;
return VALID_ACTIONS;
} }




/**
* Get the symbolic equivalent of the action value.
*
* @return the SYMBOL representing the given action.
*/
public int getAction() { public int getAction() {
String actionL = getValue().toLowerCase(Locale.US); String actionL = getValue().toLowerCase(Locale.US);


if (actionL.equals("send") ||
actionL.equals("put")) {
if (actionL.equals("send") || actionL.equals("put")) {
return SEND_FILES; return SEND_FILES;
} else if (actionL.equals("recv") ||
actionL.equals("get")) {
} else if (actionL.equals("recv") || actionL.equals("get")) {
return GET_FILES; return GET_FILES;
} else if (actionL.equals("del") ||
actionL.equals("delete")) {
} else if (actionL.equals("del") || actionL.equals("delete")) {
return DEL_FILES; return DEL_FILES;
} else if (actionL.equals("list")) { } else if (actionL.equals("list")) {
return LIST_FILES; return LIST_FILES;


Loading…
Cancel
Save