You are viewing a plain text version of this content. The canonical link for it is here.
Posted to cactus-dev@jakarta.apache.org by vm...@apache.org on 2002/01/23 23:31:34 UTC
cvs commit: jakarta-cactus/src/ant/org/apache/cactus/ant AbstractServerRun.java ArgListTask.java ChangeLogTask.java EnhydraRun.java PathConvert.java ResinRun.java RunServerTestsTask.java StartServerHelper.java StartServerTask.java StopServerHelper.java StopServerTask.java
vmassol 02/01/23 14:31:34
Modified: src/ant/org/apache/cactus/ant AbstractServerRun.java
ArgListTask.java ChangeLogTask.java EnhydraRun.java
PathConvert.java ResinRun.java
RunServerTestsTask.java StartServerHelper.java
StartServerTask.java StopServerHelper.java
StopServerTask.java
Log:
qualified imports
Revision Changes Path
1.6 +109 -109 jakarta-cactus/src/ant/org/apache/cactus/ant/AbstractServerRun.java
Index: AbstractServerRun.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/src/ant/org/apache/cactus/ant/AbstractServerRun.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- AbstractServerRun.java 13 Jan 2002 14:59:53 -0000 1.5
+++ AbstractServerRun.java 23 Jan 2002 22:31:33 -0000 1.6
@@ -53,10 +53,10 @@
*/
package org.apache.cactus.ant;
-import java.net.*;
-import java.io.*;
-import java.util.*;
-import java.lang.reflect.*;
+import java.io.IOException;
+import java.net.ServerSocket;
+import java.net.Socket;
+import java.util.Vector;
/**
* Abstract class for starting/stopping an application server. When this
@@ -67,14 +67,14 @@
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
* @author <a href="mailto:digital@ix.net.au">Robert Leftwich</a>
*
- * @version $Id: AbstractServerRun.java,v 1.5 2002/01/13 14:59:53 vmassol Exp $
+ * @version $Id: AbstractServerRun.java,v 1.6 2002/01/23 22:31:33 vmassol Exp $
*/
public abstract class AbstractServerRun extends Thread
{
/**
* Internal socket port that we use to stop the server.
*/
- private int port = 7777;
+ private int port = 7777;
/**
* Host name. We assume the server is started and stoppped in the same
@@ -104,157 +104,157 @@
/**
* Starts the server (in a blocking mode) and set up a socket listener.
*/
- abstract protected void doStartServer() throws Exception;
+ abstract protected void doStartServer() throws Exception;
/**
* Stops the server by connecting to the socket set up when the server
* was started.
*/
- abstract protected void doStopServer() throws Exception;
+ abstract protected void doStopServer() throws Exception;
/**
* Parse and process the command line to start/stop the server.
*/
- protected void doRun()
- {
- // Look for a -start or -stop flag
- boolean isStart = true;
- Vector newArgs = new Vector();
-
- for (int i = 0; i < this.args.length; i++) {
- if (this.args[i].equalsIgnoreCase("-start")) {
- isStart = true;
- } else if (this.args[i].equalsIgnoreCase("-stop")) {
- isStart = false;
- } else if (this.args[i].equalsIgnoreCase("-port")) {
- this.port = Integer.parseInt(this.args[i+1]);
- i++;
- } else {
- newArgs.add(this.args[i]);
- }
- }
+ protected void doRun()
+ {
+ // Look for a -start or -stop flag
+ boolean isStart = true;
+ Vector newArgs = new Vector();
+
+ for (int i = 0; i < this.args.length; i++) {
+ if (this.args[i].equalsIgnoreCase("-start")) {
+ isStart = true;
+ } else if (this.args[i].equalsIgnoreCase("-stop")) {
+ isStart = false;
+ } else if (this.args[i].equalsIgnoreCase("-port")) {
+ this.port = Integer.parseInt(this.args[i + 1]);
+ i++;
+ } else {
+ newArgs.add(this.args[i]);
+ }
+ }
// Remove the command line arguments that should not be part of the
// server command line (i.e. our own arguments).
String[] strArgs = new String[0];
- this.args = (String[])newArgs.toArray(strArgs);
+ this.args = (String[]) newArgs.toArray(strArgs);
- if (isStart) {
- startServer();
- } else {
- stopServer();
- }
+ if (isStart) {
+ startServer();
+ } else {
+ stopServer();
+ }
- }
+ }
/**
* Starts the server.
*/
- private void startServer()
- {
+ private void startServer()
+ {
// If the server is already started, do nothing
if (this.isStarted) {
return;
}
- try {
- doStartServer();
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException("Error starting server");
- }
+ try {
+ doStartServer();
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException("Error starting server");
+ }
// Server is now started
this.isStarted = true;
- // Set up listener socket for listening to request to stop server
- new Thread(this).start();
- }
+ // Set up listener socket for listening to request to stop server
+ new Thread(this).start();
+ }
/**
* Stops the running server.
*/
- private void stopServer()
- {
- // Open socket connection
- Socket clientSocket = null;
-
- try {
- clientSocket = new Socket(this.host, this.port);
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException("Error opening socket to " + this.host +
+ private void stopServer()
+ {
+ // Open socket connection
+ Socket clientSocket = null;
+
+ try {
+ clientSocket = new Socket(this.host, this.port);
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException("Error opening socket to " + this.host +
":" + this.port + "]");
- } finally {
- try {
- if (clientSocket != null) {
- clientSocket.close();
- }
- } catch (IOException e) {
- throw new RuntimeException("Cannot close client socket");
- }
- }
- }
+ } finally {
+ try {
+ if (clientSocket != null) {
+ clientSocket.close();
+ }
+ } catch (IOException e) {
+ throw new RuntimeException("Cannot close client socket");
+ }
+ }
+ }
/**
* Sets up a listener socket and wait until we receive a request on it to
* stop the running server.
*/
- public void run()
- {
- ServerSocket serverSocket = setUpListenerSocket();
-
- // Accept a client socket connection
- Socket clientSocket = null;
- try {
- clientSocket = serverSocket.accept();
- } catch (IOException e) {
- throw new RuntimeException("Error accepting connection for " +
+ public void run()
+ {
+ ServerSocket serverSocket = setUpListenerSocket();
+
+ // Accept a client socket connection
+ Socket clientSocket = null;
+ try {
+ clientSocket = serverSocket.accept();
+ } catch (IOException e) {
+ throw new RuntimeException("Error accepting connection for " +
"server socket [" + serverSocket + "]");
- } finally {
- // Stop server socket
- try {
- serverSocket.close();
- } catch (IOException e) {
- throw new RuntimeException("Cannot close server socket [" +
+ } finally {
+ // Stop server socket
+ try {
+ serverSocket.close();
+ } catch (IOException e) {
+ throw new RuntimeException("Cannot close server socket [" +
serverSocket + "]");
- }
- }
+ }
+ }
- // Stop server
- try {
- this.doStopServer();
- } catch (Exception e) {
- e.printStackTrace();
- throw new RuntimeException("Cannot stop server");
- }
-
- // Stop server socket
- try {
- serverSocket.close();
- } catch (IOException e) {
- throw new RuntimeException("Cannot close server socket [" +
+ // Stop server
+ try {
+ this.doStopServer();
+ } catch (Exception e) {
+ e.printStackTrace();
+ throw new RuntimeException("Cannot stop server");
+ }
+
+ // Stop server socket
+ try {
+ serverSocket.close();
+ } catch (IOException e) {
+ throw new RuntimeException("Cannot close server socket [" +
serverSocket + "]");
- }
+ }
- }
+ }
/**
* Sets up the listener socket.
*/
- private ServerSocket setUpListenerSocket()
- {
- ServerSocket serverSocket = null;
-
- try {
- serverSocket = new ServerSocket(this.port);
- } catch (IOException e) {
- e.printStackTrace();
- throw new RuntimeException("Error setting up the server " +
+ private ServerSocket setUpListenerSocket()
+ {
+ ServerSocket serverSocket = null;
+
+ try {
+ serverSocket = new ServerSocket(this.port);
+ } catch (IOException e) {
+ e.printStackTrace();
+ throw new RuntimeException("Error setting up the server " +
"listener socket");
- }
+ }
- return serverSocket;
- }
+ return serverSocket;
+ }
}
1.6 +7 -5 jakarta-cactus/src/ant/org/apache/cactus/ant/ArgListTask.java
Index: ArgListTask.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/src/ant/org/apache/cactus/ant/ArgListTask.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- ArgListTask.java 13 Jan 2002 14:59:53 -0000 1.5
+++ ArgListTask.java 23 Jan 2002 22:31:33 -0000 1.6
@@ -53,9 +53,11 @@
*/
package org.apache.cactus.ant;
-import java.util.*;
+import java.util.Enumeration;
+import java.util.Vector;
-import org.apache.tools.ant.*;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
/**
* Compute a string (returned as an Ant property) that contains a list of
@@ -70,7 +72,7 @@
* <property name="property1"/>
* <property name="property2"/>
* <property name="property3"/>
- * </argList>
+ * </argList>
*
* <echo message="${result}"/>
* </code></pre>
@@ -79,7 +81,7 @@
*
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
*
- * @version $Id: ArgListTask.java,v 1.5 2002/01/13 14:59:53 vmassol Exp $
+ * @version $Id: ArgListTask.java,v 1.6 2002/01/23 22:31:33 vmassol Exp $
*/
public class ArgListTask extends Task
{
@@ -124,7 +126,7 @@
while (args.hasMoreElements()) {
String propertyName =
- ((ArgListProperty)args.nextElement()).getName();
+ ((ArgListProperty) args.nextElement()).getName();
// Check if this property is defined
String value = getProject().getProperty(propertyName);
1.10 +69 -42 jakarta-cactus/src/ant/org/apache/cactus/ant/ChangeLogTask.java
Index: ChangeLogTask.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/src/ant/org/apache/cactus/ant/ChangeLogTask.java,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -r1.9 -r1.10
--- ChangeLogTask.java 13 Jan 2002 14:59:53 -0000 1.9
+++ ChangeLogTask.java 23 Jan 2002 22:31:33 -0000 1.10
@@ -53,14 +53,36 @@
*/
package org.apache.cactus.ant;
-import java.io.*;
-import java.util.*;
-import java.text.*;
-import java.net.*;
-
-import org.apache.tools.ant.*;
-import org.apache.tools.ant.taskdefs.*;
-import org.apache.tools.ant.types.*;
+import java.io.BufferedReader;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileNotFoundException;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.InputStreamReader;
+import java.io.OutputStream;
+import java.io.OutputStreamWriter;
+import java.io.PrintWriter;
+import java.io.UnsupportedEncodingException;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+import java.text.ParseException;
+import java.text.SimpleDateFormat;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.Hashtable;
+import java.util.Properties;
+import java.util.Vector;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.DirectoryScanner;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.Execute;
+import org.apache.tools.ant.taskdefs.ExecuteStreamHandler;
+import org.apache.tools.ant.types.Commandline;
+import org.apache.tools.ant.types.FileSet;
/**
* A CVS log task that extract information from the execution of the
@@ -72,14 +94,14 @@
* @author <a href="mailto:jeff.martin@synamic.co.uk">Jeff Martin</a>
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
*
- * @version $Id: ChangeLogTask.java,v 1.9 2002/01/13 14:59:53 vmassol Exp $
+ * @version $Id: ChangeLogTask.java,v 1.10 2002/01/23 22:31:33 vmassol Exp $
*/
public class ChangeLogTask extends Task implements ExecuteStreamHandler
{
/**
* Name of properties file containing the user list. This list is used to
* match a user id retrieved from the '<code>cvs log</code>' command with a
- * display name. The format of the file is :
+ * display name. The format of the file is :
* '<code>[user id] = [display name]</code>'.
*/
private File userConfigFile;
@@ -120,7 +142,7 @@
* Output file stream where results will be written to
*/
private PrintWriter output;
-
+
/**
* Filesets containting list of files against which the cvs log will be
* performed. If empty then all files will in the working directory will
@@ -140,21 +162,25 @@
// state machine states
private final static int GET_ENTRY = 0;
+
private final static int GET_FILE = 1;
+
private final static int GET_DATE = 2;
+
private final static int GET_COMMENT = 3;
+
private final static int GET_REVISION = 4;
/**
* Input format for dates read in from cvs log
*/
- private static final SimpleDateFormat INPUT_DATE =
+ private static final SimpleDateFormat INPUT_DATE =
new SimpleDateFormat("yyyy/MM/dd");
/**
* Input format for dates read in from cvs log
*/
- private static final SimpleDateFormat FULL_INPUT_DATE =
+ private static final SimpleDateFormat FULL_INPUT_DATE =
new SimpleDateFormat("yyyy/MM/dd HH:mm");
/**
@@ -198,7 +224,7 @@
}
/**
- * Set the output file for the log. This method is automatically called by
+ * Set the output file for the log. This method is automatically called by
* the Ant runtime engine when the <code>output</code> attribute is
* encountered in the Ant XML build file. This attribute is mandatory.
*
@@ -212,7 +238,7 @@
}
/**
- * Set the threshold cvs log date. This method is automatically called by
+ * Set the threshold cvs log date. This method is automatically called by
* the Ant runtime engine when the <code>date</code> attribute is
* encountered in the Ant XML build file. This attribute is optional. The
* format is "yyyy/MM/dd".
@@ -224,15 +250,15 @@
{
try {
this.thresholdDate = INPUT_DATE.parse(theThresholdDate);
- } catch(ParseException e) {
- throw new BuildException("Bad date format [" +
+ } catch (ParseException e) {
+ throw new BuildException("Bad date format [" +
theThresholdDate + "].");
}
}
/**
* Set the threshold cvs log date by calculating it : "today - elapsed".
- * This method is automatically called by
+ * This method is automatically called by
* the Ant runtime engine when the <code>elapsed</code> attribute is
* encountered in the Ant XML build file. This attribute is optional. The
* elasped time must be expressed in days.
@@ -249,7 +275,7 @@
/**
* Adds a set of files (nested fileset attribute).
- * This method is automatically called by
+ * This method is automatically called by
* the Ant runtime engine when the <code>fileset</code> nested tag is
* encountered in the Ant XML build file. This attribute is optional.
*
@@ -263,7 +289,7 @@
/**
* Set the test URL to check if internet access is on. This method is
- * automatically called by the Ant runtime engine when the
+ * automatically called by the Ant runtime engine when the
* <code>testURL</code> attribute is encountered in the Ant XML build file.
* This attribute is optional.
*
@@ -275,7 +301,7 @@
}
/**
- * Set the debug file. This is optional and debug will be turned on only
+ * Set the debug file. This is optional and debug will be turned on only
* when this attribute is set. All output from the cvs log command will be
* dumped to this debug file.
*
@@ -288,7 +314,7 @@
throws FileNotFoundException, UnsupportedEncodingException, IOException
{
this.debug = new PrintWriter(new OutputStreamWriter(
- new FileOutputStream(theDebugFile),"UTF-8"), true);
+ new FileOutputStream(theDebugFile), "UTF-8"), true);
}
/**
@@ -299,13 +325,13 @@
{
if (this.userConfigFile != null) {
if (!this.userConfigFile.exists()) {
- throw new BuildException("User list configuration file [" +
+ throw new BuildException("User list configuration file [" +
this.userConfigFile.getAbsolutePath() +
"] was not found. Please check location.");
}
try {
this.userList.load(new FileInputStream(this.userConfigFile));
- } catch(IOException e) {
+ } catch (IOException e) {
throw new BuildException(e);
}
}
@@ -323,7 +349,7 @@
try {
URL url = new URL(this.testURL);
HttpURLConnection connection =
- (HttpURLConnection)url.openConnection();
+ (HttpURLConnection) url.openConnection();
connection.connect();
connection.disconnect();
} catch (MalformedURLException e) {
@@ -338,7 +364,7 @@
try {
this.output = new PrintWriter(new OutputStreamWriter(
- new FileOutputStream(this.outputFile),"UTF-8"));
+ new FileOutputStream(this.outputFile), "UTF-8"));
this.output.println("<changelog>");
this.output.println("</changelog>");
this.output.flush();
@@ -389,7 +415,7 @@
// Check if a threshold date has been specified
if (this.thresholdDate != null) {
- toExecute.createArgument().setValue("-d\">=" +
+ toExecute.createArgument().setValue("-d\">=" +
OUTPUT_DATE.format(this.thresholdDate) + "\"");
}
@@ -397,13 +423,13 @@
if (!this.filesets.isEmpty()) {
Enumeration e = this.filesets.elements();
- while(e.hasMoreElements()) {
- FileSet fs = (FileSet)e.nextElement();
+ while (e.hasMoreElements()) {
+ FileSet fs = (FileSet) e.nextElement();
DirectoryScanner ds = fs.getDirectoryScanner(project);
String[] srcFiles = ds.getIncludedFiles();
for (int i = 0; i < srcFiles.length; i++) {
toExecute.createArgument().setValue(srcFiles[i]);
- }
+ }
}
}
@@ -413,7 +439,7 @@
exe.setWorkingDirectory(this.cvsWorkingDirectory);
try {
exe.execute();
- } catch(IOException e) {
+ } catch (IOException e) {
throw new BuildException(e);
}
}
@@ -465,7 +491,7 @@
public void start() throws IOException
{
this.output = new PrintWriter(new OutputStreamWriter(
- new FileOutputStream(this.outputFile),"UTF-8"));
+ new FileOutputStream(this.outputFile), "UTF-8"));
String file = null;
String line = null;
@@ -483,10 +509,10 @@
while ((line = this.input.readLine()) != null) {
- // Log to debug file if debug mode is on
+ // Log to debug file if debug mode is on
debug("Text: [" + line);
- switch(status){
+ switch (status) {
case GET_FILE:
if (line.startsWith("Working file:")) {
@@ -518,7 +544,7 @@
author = line.substring(10, line.indexOf(";"));
if ((this.userList != null) &&
- this.userList.containsKey(author)) {
+ this.userList.containsKey(author)) {
author = "<![CDATA[" +
this.userList.getProperty(author) + "]]>";
@@ -531,7 +557,7 @@
case GET_COMMENT:
comment = "";
- while (line != null && !line.startsWith("======") &&
+ while (line != null && !line.startsWith("======") &&
!line.startsWith("------")) {
comment += line + "\n";
@@ -539,8 +565,8 @@
debug("Text: [" + line);
}
- comment = "<![CDATA[" +
- comment.substring(0,comment.length() - 1) + "]]>";
+ comment = "<![CDATA[" +
+ comment.substring(0, comment.length() - 1) + "]]>";
// Add the entry to the list of entries
Entry entry;
@@ -548,7 +574,7 @@
entry = new Entry(date, author, comment);
entries.put(date + author + comment, entry);
} else {
- entry = (Entry)entries.get(date + author + comment);
+ entry = (Entry) entries.get(date + author + comment);
}
entry.addFile(file, revision);
@@ -578,7 +604,7 @@
this.output.println("<changelog>");
Enumeration en = entries.elements();
while (en.hasMoreElements()) {
- ((Entry)en.nextElement()).print();
+ ((Entry) en.nextElement()).print();
}
this.output.println("</changelog>");
this.output.flush();
@@ -633,7 +659,7 @@
{
try {
this.date = FULL_INPUT_DATE.parse(theDate);
- } catch(ParseException e) {
+ } catch (ParseException e) {
log("Bad date format [" + theDate + "].");
}
this.author = theAuthor;
@@ -662,7 +688,7 @@
Enumeration e = this.files.elements();
while (e.hasMoreElements()) {
- RCSFile file = (RCSFile)e.nextElement();
+ RCSFile file = (RCSFile) e.nextElement();
output.println("\t\t<file>");
output.println("\t\t\t<name>" + file.getName() + "</name>");
output.println("\t\t\t<revision>" + file.getRevision() +
@@ -676,6 +702,7 @@
private class RCSFile
{
private String name;
+
private String revision;
private RCSFile(String theName, String theRevision)
1.6 +12 -15 jakarta-cactus/src/ant/org/apache/cactus/ant/EnhydraRun.java
Index: EnhydraRun.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/src/ant/org/apache/cactus/ant/EnhydraRun.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- EnhydraRun.java 13 Jan 2002 14:59:53 -0000 1.5
+++ EnhydraRun.java 23 Jan 2002 22:31:33 -0000 1.6
@@ -53,10 +53,7 @@
*/
package org.apache.cactus.ant;
-import java.net.*;
-import java.io.*;
-import java.util.*;
-import java.lang.reflect.*;
+import java.lang.reflect.Method;
/**
* Starts/stop Enhydra by setting up a listener socket.
@@ -64,7 +61,7 @@
* @author <a href="mailto:digital@ix.net.au">Robert Leftwich</a>
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
*
- * @version $Id: EnhydraRun.java,v 1.5 2002/01/13 14:59:53 vmassol Exp $
+ * @version $Id: EnhydraRun.java,v 1.6 2002/01/23 22:31:33 vmassol Exp $
* @see AbstractServerRun
*/
public class EnhydraRun extends AbstractServerRun
@@ -81,11 +78,11 @@
*
* @param theArgs the command line arguments
*/
- public static void main(String[] theArgs)
- {
+ public static void main(String[] theArgs)
+ {
EnhydraRun enhydra = new EnhydraRun(theArgs);
enhydra.doRun();
- }
+ }
/**
* @param theArgs the command line arguments
@@ -99,36 +96,36 @@
* Start the Enhydra server. We use reflection so that the Enhydra jars do
* not need to be in the classpath to compile this class.
*/
- protected void doStartServer()
+ protected void doStartServer()
{
try {
Class enhydraClass =
Class.forName("com.lutris.multiServer.MultiServer");
Method initMethod = enhydraClass.getMethod("main",
- new Class[] {this.args.getClass()});
- initMethod.invoke(null, new Object[] {this.args});
+ new Class[]{this.args.getClass()});
+ initMethod.invoke(null, new Object[]{this.args});
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Cannot create instance of MultiServer");
}
- }
+ }
/**
* Stops the Enhydra server. We use reflection so that the Enhydra jars do
* not need to be in the classpath to compile this class.
*/
- protected void doStopServer()
+ protected void doStopServer()
{
try {
Class enhydraClass =
Class.forName("com.lutris.multiServer.MultiServer");
Method shutDownMethod = enhydraClass.getMethod("shutdown", null);
- shutDownMethod.invoke(null, null );
+ shutDownMethod.invoke(null, null);
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Cannot stop running instance of " +
"MultiServer");
}
- }
+ }
}
1.5 +79 -57 jakarta-cactus/src/ant/org/apache/cactus/ant/PathConvert.java
Index: PathConvert.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/src/ant/org/apache/cactus/ant/PathConvert.java,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -r1.4 -r1.5
--- PathConvert.java 13 Jan 2002 14:59:53 -0000 1.4
+++ PathConvert.java 23 Jan 2002 22:31:33 -0000 1.5
@@ -54,12 +54,13 @@
package org.apache.cactus.ant;
+import java.util.ArrayList;
+
import org.apache.tools.ant.BuildException;
import org.apache.tools.ant.Project;
import org.apache.tools.ant.Task;
-import org.apache.tools.ant.types.*;
-
-import java.util.*;
+import org.apache.tools.ant.types.Path;
+import org.apache.tools.ant.types.Reference;
/**
* This task converts path and classpath information to a specific target OS format.
@@ -70,7 +71,8 @@
*
* @author Larry Streepy <a href="mailto:streepy@healthlanguage.com">streepy@healthlanguage.com</a>
*/
-public class PathConvert extends Task {
+public class PathConvert extends Task
+{
/**
* Helper class, holds the nested <map> values. Elements will look like this:
@@ -78,19 +80,22 @@
* <p>
* When running on windows, the prefix comparison will be case insensitive.
*/
- public class MapEntry {
+ public class MapEntry
+ {
/**
* Set the "from" attribute of the map entry
*/
- public void setFrom( String from ) {
+ public void setFrom(String from)
+ {
this.from = from;
}
/**
* Set the "to" attribute of the map entry
*/
- public void setTo( String to ) {
+ public void setTo(String to)
+ {
this.to = to;
}
@@ -99,9 +104,10 @@
* @param elem Path element to process
* @return String Updated path element after mapping
*/
- public String apply( String elem ) {
- if( from == null || to == null ) {
- throw new BuildException( "Both 'from' and 'to' must be set in a map entry" );
+ public String apply(String elem)
+ {
+ if (from == null || to == null) {
+ throw new BuildException("Both 'from' and 'to' must be set in a map entry");
}
// If we're on windows, then do the comparison ignoring case
@@ -111,13 +117,13 @@
// If the element starts with the configured prefix, then convert the prefix
// to the configured 'to' value.
- if( cmpElem.startsWith( cmpFrom ) ) {
+ if (cmpElem.startsWith(cmpFrom)) {
int len = from.length();
- if( len >= elem.length() ) {
+ if (len >= elem.length()) {
elem = to;
} else {
- elem = to + elem.substring( len );
+ elem = to + elem.substring(len);
}
}
@@ -126,18 +132,20 @@
// Members
private String from = null;
+
private String to = null;
}
/**
* Create a nested PATH element
*/
- public Path createPath() {
+ public Path createPath()
+ {
- if( isReference() )
+ if (isReference())
throw noChildrenAllowed();
- if( path == null ) {
+ if (path == null) {
path = new Path(getProject());
}
return path.createPath();
@@ -146,22 +154,24 @@
/**
* Create a nested MAP element
*/
- public MapEntry createMap() {
+ public MapEntry createMap()
+ {
MapEntry entry = new MapEntry();
- prefixMap.add( entry );
+ prefixMap.add(entry);
return entry;
}
/**
* Set the value of the targetos attribute
*/
- public void setTargetos( String target ) {
+ public void setTargetos(String target)
+ {
targetOS = target.toLowerCase();
- if( ! targetOS.equals( "windows" ) && ! target.equals( "unix" ) ) {
- throw new BuildException( "targetos must be one of 'unix' or 'windows'" );
+ if (!targetOS.equals("windows") && !target.equals("unix")) {
+ throw new BuildException("targetos must be one of 'unix' or 'windows'");
}
// Currently, we deal with only two path formats: Unix and Windows
@@ -174,15 +184,17 @@
* Set the value of the proprty attribute - this is the property into which our
* converted path will be placed.
*/
- public void setProperty( String p ) {
+ public void setProperty(String p)
+ {
property = p;
}
/**
* Adds a reference to a PATH defined elsewhere.
*/
- public void setPathRef(Reference r) {
- if( path != null )
+ public void setPathRef(Reference r)
+ {
+ if (path != null)
throw noChildrenAllowed();
pathref = r;
@@ -191,17 +203,19 @@
/**
* Has the pathref attribute of this element been set?
*/
- public boolean isReference() {
+ public boolean isReference()
+ {
return pathref != null;
}
/**
* Do the execution.
*/
- public void execute() throws BuildException {
+ public void execute() throws BuildException
+ {
// If we are a reference, the create a Path from the reference
- if( isReference() ) {
+ if (isReference()) {
path = new Path(getProject()).createPath();
path.setRefid(pathref);
}
@@ -212,48 +226,48 @@
// And Unix is everything that is not Windows
String osname = System.getProperty("os.name").toLowerCase();
- onWindows = ( osname.indexOf("windows") >= 0 );
+ onWindows = (osname.indexOf("windows") >= 0);
- StringBuffer rslt = new StringBuffer( 100 );
+ StringBuffer rslt = new StringBuffer(100);
// If we're on the same platform type as the target, then there is no
// conversion work to do.
- if( onWindows != targetWindows ) {
+ if (onWindows != targetWindows) {
char pathSep = targetWindows ? ';' : ':';
// Get the list of path components in canonical form
String[] elems = path.list();
- for( int i=0; i < elems.length; i++ ) {
+ for (int i = 0; i < elems.length; i++) {
String elem = elems[i];
- elem = mapElement( elem ); // Apply the path prefix map
+ elem = mapElement(elem); // Apply the path prefix map
// Now convert the path and file separator characters from the
// current os to the target os.
- if( targetWindows ) {
- elem = elem.replace( '/', '\\' );
+ if (targetWindows) {
+ elem = elem.replace('/', '\\');
} else {
- elem = elem.replace( '\\', '/' );
+ elem = elem.replace('\\', '/');
}
- if( i != 0 ) rslt.append( pathSep );
- rslt.append( elem );
+ if (i != 0) rslt.append(pathSep);
+ rslt.append(elem);
}
} else {
- rslt.append( path.toString() ); // No additional work to do
+ rslt.append(path.toString()); // No additional work to do
}
// Place the result into the specified property
String value = rslt.toString();
- log( "Set property " + property + " = " + value, Project.MSG_VERBOSE );
+ log("Set property " + property + " = " + value, Project.MSG_VERBOSE);
- getProject().setProperty( property, value );
+ getProject().setProperty(property, value);
}
/**
@@ -268,17 +282,18 @@
* @param elem The path element to apply the map to
* @return String Updated element
*/
- private String mapElement( String elem ) {
+ private String mapElement(String elem)
+ {
int size = prefixMap.size();
- if( size == 0 ) {
+ if (size == 0) {
- if( targetWindows ) {
+ if (targetWindows) {
elem = "C:" + elem;
} else {
// If the element starts with a drive letter, remove it
- if( elem.charAt(1) == ':' )
+ if (elem.charAt(1) == ':')
elem = elem.substring(2);
}
@@ -286,14 +301,14 @@
// Iterate over the map entries and apply each one. Stop when one of the
// entries actually changes the element
- for( int i=0; i < size; i++ ) {
- MapEntry entry = (MapEntry)prefixMap.get(i);
- String newElem = entry.apply( elem );
+ for (int i = 0; i < size; i++) {
+ MapEntry entry = (MapEntry) prefixMap.get(i);
+ String newElem = entry.apply(elem);
// Note I'm using "!=" to see if we got a new object back from
// the apply method.
- if( newElem != elem ) {
+ if (newElem != elem) {
elem = newElem;
break; // We applied one, so we're done
}
@@ -307,34 +322,41 @@
* Validate that all our parameters have been properly initialized.
* @throws BuildException if something is not setup properly
*/
- private void validateSetup() throws BuildException {
+ private void validateSetup() throws BuildException
+ {
- if( path == null )
- throw new BuildException( "You must specify a path to convert" );
+ if (path == null)
+ throw new BuildException("You must specify a path to convert");
- if( targetOS == null )
- throw new BuildException( "You must specify a target OS" );
+ if (targetOS == null)
+ throw new BuildException("You must specify a target OS");
- if( property == null )
- throw new BuildException( "You must specify a property" );
+ if (property == null)
+ throw new BuildException("You must specify a property");
}
/**
* Creates an exception that indicates that this XML element must
* not have child elements if the pathrefid attribute is set.
*/
- private BuildException noChildrenAllowed() {
+ private BuildException noChildrenAllowed()
+ {
return new BuildException("You must not specify nested PATH elements when using pathref");
}
-
// Members
private Path path = null; // Path to be converted
+
private Reference pathref = null; // Reference to path to convert
+
private String targetOS = null; // The target OS type
+
private boolean targetWindows = false; // Set when targetOS is set
+
private boolean onWindows = false; // Set if we're running on windows
+
private String property = null; // The property to receive the results
+
private ArrayList prefixMap = new ArrayList(); // Path prefix map
}
1.7 +12 -14 jakarta-cactus/src/ant/org/apache/cactus/ant/ResinRun.java
Index: ResinRun.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/src/ant/org/apache/cactus/ant/ResinRun.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- ResinRun.java 13 Jan 2002 14:59:53 -0000 1.6
+++ ResinRun.java 23 Jan 2002 22:31:33 -0000 1.7
@@ -53,10 +53,8 @@
*/
package org.apache.cactus.ant;
-import java.net.*;
-import java.io.*;
-import java.util.*;
-import java.lang.reflect.*;
+import java.lang.reflect.Constructor;
+import java.lang.reflect.Method;
/**
* Starts/stop Resin by setting up a listener socket.
@@ -64,7 +62,7 @@
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
* @author <a href="mailto:digital@ix.net.au">Robert Leftwich</a>
*
- * @version $Id: ResinRun.java,v 1.6 2002/01/13 14:59:53 vmassol Exp $
+ * @version $Id: ResinRun.java,v 1.7 2002/01/23 22:31:33 vmassol Exp $
* @see AbstractServerRun
*/
public class ResinRun extends AbstractServerRun
@@ -81,11 +79,11 @@
*
* @param theArgs the command line arguments
*/
- public static void main(String[] theArgs)
- {
+ public static void main(String[] theArgs)
+ {
ResinRun resin = new ResinRun(theArgs);
resin.doRun();
- }
+ }
/**
* @param theArgs the command line arguments
@@ -99,18 +97,18 @@
* Start the Resin server. We use reflection so that the Resin jars do not
* need to be in the classpath to compile this class.
*/
- protected void doStartServer()
+ protected void doStartServer()
{
try {
Class resinClass =
Class.forName("com.caucho.server.http.ResinServer");
Constructor constructor = resinClass.getConstructor(
- new Class[] {this.args.getClass(), boolean.class});
+ new Class[]{this.args.getClass(), boolean.class});
this.resinServer = constructor.newInstance(
- new Object[] {this.args, new Boolean(true)});
+ new Object[]{this.args, new Boolean(true)});
Method initMethod = resinClass.getMethod("init",
- new Class[] {boolean.class});
- initMethod.invoke(this.resinServer, new Object[] {new Boolean(true)});
+ new Class[]{boolean.class});
+ initMethod.invoke(this.resinServer, new Object[]{new Boolean(true)});
} catch (Exception e) {
e.printStackTrace();
throw new RuntimeException("Cannot create instance of ResinServer");
@@ -121,7 +119,7 @@
* Stops the Resin server. We use reflection so that the Resin jars do not
* need to be in the classpath to compile this class.
*/
- protected void doStopServer()
+ protected void doStopServer()
{
try {
Method closeMethod =
1.7 +7 -9 jakarta-cactus/src/ant/org/apache/cactus/ant/RunServerTestsTask.java
Index: RunServerTestsTask.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/src/ant/org/apache/cactus/ant/RunServerTestsTask.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- RunServerTestsTask.java 13 Jan 2002 14:59:53 -0000 1.6
+++ RunServerTestsTask.java 23 Jan 2002 22:31:33 -0000 1.7
@@ -53,11 +53,9 @@
*/
package org.apache.cactus.ant;
-import java.net.*;
-import java.io.*;
-
-import org.apache.tools.ant.*;
-import org.apache.tools.ant.taskdefs.*;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.CallTarget;
/**
* Task to automate running in-container unit test. It has the following
@@ -84,7 +82,7 @@
*
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
*
- * @version $Id: RunServerTestsTask.java,v 1.6 2002/01/13 14:59:53 vmassol Exp $
+ * @version $Id: RunServerTestsTask.java,v 1.7 2002/01/23 22:31:33 vmassol Exp $
*/
public class RunServerTestsTask extends Task
{
@@ -96,7 +94,7 @@
/**
* The helper object used to start the server. We use a helper so that it
* can also be reused in the <code>StartServerTask</code> task. Indeed,
- * with Ant 1.3 and before there are classloaders issues with calling a
+ * with Ant 1.3 and before there are classloaders issues with calling a
* custom task from another custom task. Using a helper is a workaround.
*/
private StartServerHelper startHelper;
@@ -104,7 +102,7 @@
/**
* The helper object used to stop the server. We use a helper so that it
* can also be reused in the <code>StopServerTask</code> task. Indeed,
- * with Ant 1.3 and before there are classloaders issues with calling a
+ * with Ant 1.3 and before there are classloaders issues with calling a
* custom task from another custom task. Using a helper is a workaround.
*/
private StopServerHelper stopHelper;
@@ -157,7 +155,7 @@
private void callTests()
{
CallTarget callee;
- callee = (CallTarget)project.createTask("antcall");
+ callee = (CallTarget) project.createTask("antcall");
callee.setOwningTarget(target);
callee.setTaskName(getTaskName());
callee.setLocation(location);
1.9 +16 -11 jakarta-cactus/src/ant/org/apache/cactus/ant/StartServerHelper.java
Index: StartServerHelper.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/src/ant/org/apache/cactus/ant/StartServerHelper.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- StartServerHelper.java 13 Jan 2002 14:59:53 -0000 1.8
+++ StartServerHelper.java 23 Jan 2002 22:31:33 -0000 1.9
@@ -53,11 +53,15 @@
*/
package org.apache.cactus.ant;
-import java.net.*;
-import java.io.*;
-
-import org.apache.tools.ant.*;
-import org.apache.tools.ant.taskdefs.*;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.CallTarget;
/**
* A helper class for an Ant Task that does the following :
@@ -71,7 +75,7 @@
*
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
*
- * @version $Id: StartServerHelper.java,v 1.8 2002/01/13 14:59:53 vmassol Exp $
+ * @version $Id: StartServerHelper.java,v 1.9 2002/01/23 22:31:33 vmassol Exp $
*/
public class StartServerHelper implements Runnable
{
@@ -132,7 +136,7 @@
try {
HttpURLConnection connection =
- (HttpURLConnection)this.testURL.openConnection();
+ (HttpURLConnection) this.testURL.openConnection();
connection.connect();
readFully(connection);
connection.disconnect();
@@ -145,7 +149,7 @@
} catch (IOException e) {
// An error occurred. It just means the server is not running. Do
- // nothing
+ // nothing
}
// Call the target that starts the server, in another thread. The called
@@ -167,7 +171,7 @@
try {
HttpURLConnection connection =
- (HttpURLConnection)this.testURL.openConnection();
+ (HttpURLConnection) this.testURL.openConnection();
connection.connect();
readFully(connection);
connection.disconnect();
@@ -199,7 +203,8 @@
BufferedInputStream is =
new BufferedInputStream(connection.getInputStream());
byte[] buffer = new byte[256];
- while((is.read(buffer)) > 0) {}
+ while ((is.read(buffer)) > 0) {
+ }
is.close();
}
@@ -211,7 +216,7 @@
{
// Call the Ant target using the "antcall" task.
CallTarget callee;
- callee = (CallTarget)(this.task.getProject().createTask("antcall"));
+ callee = (CallTarget) (this.task.getProject().createTask("antcall"));
callee.setOwningTarget(this.task.getOwningTarget());
callee.setTaskName(this.task.getTaskName());
callee.setLocation(this.task.getLocation());
1.6 +3 -6 jakarta-cactus/src/ant/org/apache/cactus/ant/StartServerTask.java
Index: StartServerTask.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/src/ant/org/apache/cactus/ant/StartServerTask.java,v
retrieving revision 1.5
retrieving revision 1.6
diff -u -r1.5 -r1.6
--- StartServerTask.java 13 Jan 2002 14:59:53 -0000 1.5
+++ StartServerTask.java 23 Jan 2002 22:31:33 -0000 1.6
@@ -53,11 +53,8 @@
*/
package org.apache.cactus.ant;
-import java.net.*;
-import java.io.*;
-
-import org.apache.tools.ant.*;
-import org.apache.tools.ant.taskdefs.*;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
/**
* An Ant Task that does the following :
@@ -71,7 +68,7 @@
*
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
*
- * @version $Id: StartServerTask.java,v 1.5 2002/01/13 14:59:53 vmassol Exp $
+ * @version $Id: StartServerTask.java,v 1.6 2002/01/23 22:31:33 vmassol Exp $
*/
public class StartServerTask extends Task
{
1.9 +12 -9 jakarta-cactus/src/ant/org/apache/cactus/ant/StopServerHelper.java
Index: StopServerHelper.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/src/ant/org/apache/cactus/ant/StopServerHelper.java,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -r1.8 -r1.9
--- StopServerHelper.java 13 Jan 2002 14:59:53 -0000 1.8
+++ StopServerHelper.java 23 Jan 2002 22:31:33 -0000 1.9
@@ -53,11 +53,14 @@
*/
package org.apache.cactus.ant;
-import java.net.*;
-import java.io.*;
-
-import org.apache.tools.ant.*;
-import org.apache.tools.ant.taskdefs.*;
+import java.io.IOException;
+import java.net.HttpURLConnection;
+import java.net.MalformedURLException;
+import java.net.URL;
+
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
+import org.apache.tools.ant.taskdefs.CallTarget;
/**
* A helper class for an Ant task that does the following : stop a running
@@ -67,7 +70,7 @@
*
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
*
- * @version $Id: StopServerHelper.java,v 1.8 2002/01/13 14:59:53 vmassol Exp $
+ * @version $Id: StopServerHelper.java,v 1.9 2002/01/23 22:31:33 vmassol Exp $
*/
public class StopServerHelper implements Runnable
{
@@ -113,7 +116,7 @@
// Try connecting in case the server is already stopped.
try {
HttpURLConnection connection =
- (HttpURLConnection)this.testURL.openConnection();
+ (HttpURLConnection) this.testURL.openConnection();
connection.connect();
StartServerHelper.readFully(connection);
connection.disconnect();
@@ -138,7 +141,7 @@
try {
HttpURLConnection connection =
- (HttpURLConnection)this.testURL.openConnection();
+ (HttpURLConnection) this.testURL.openConnection();
connection.connect();
StartServerHelper.readFully(connection);
connection.disconnect();
@@ -174,7 +177,7 @@
{
// Call the Ant target using the "antcall" task.
CallTarget callee;
- callee = (CallTarget)(this.task.getProject().createTask("antcall"));
+ callee = (CallTarget) (this.task.getProject().createTask("antcall"));
callee.setOwningTarget(this.task.getOwningTarget());
callee.setTaskName(this.task.getTaskName());
callee.setLocation(this.task.getLocation());
1.7 +4 -7 jakarta-cactus/src/ant/org/apache/cactus/ant/StopServerTask.java
Index: StopServerTask.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/src/ant/org/apache/cactus/ant/StopServerTask.java,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -r1.6 -r1.7
--- StopServerTask.java 13 Jan 2002 14:59:53 -0000 1.6
+++ StopServerTask.java 23 Jan 2002 22:31:33 -0000 1.7
@@ -53,22 +53,19 @@
*/
package org.apache.cactus.ant;
-import java.net.*;
-import java.io.*;
-
-import org.apache.tools.ant.*;
-import org.apache.tools.ant.taskdefs.*;
+import org.apache.tools.ant.BuildException;
+import org.apache.tools.ant.Task;
/**
* Call an Ant stop target in another thread and wait for the servlet engine
* to be stopped by trying to continously connect to a test URL. If it succeeds
* it means the server is not stopped yet ! If the server was already running
- * when the start task was invoked, then it is not stopped when this tasks
+ * when the start task was invoked, then it is not stopped when this tasks
* executes.
*
* @author <a href="mailto:vmassol@apache.org">Vincent Massol</a>
*
- * @version $Id: StopServerTask.java,v 1.6 2002/01/13 14:59:53 vmassol Exp $
+ * @version $Id: StopServerTask.java,v 1.7 2002/01/23 22:31:33 vmassol Exp $
*/
public class StopServerTask extends Task
{
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>