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/08/28 00:56:34 UTC
cvs commit: jakarta-cactus/anttasks/src/java/org/apache/cactus/ant StopServerHelper.java
vmassol 2002/08/27 15:56:34
Modified: anttasks/src/java/org/apache/cactus/ant
StopServerHelper.java
Log:
new coding conventions
Revision Changes Path
1.4 +44 -21 jakarta-cactus/anttasks/src/java/org/apache/cactus/ant/StopServerHelper.java
Index: StopServerHelper.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/anttasks/src/java/org/apache/cactus/ant/StopServerHelper.java,v
retrieving revision 1.3
retrieving revision 1.4
diff -u -r1.3 -r1.4
--- StopServerHelper.java 21 Jul 2002 11:48:58 -0000 1.3
+++ StopServerHelper.java 27 Aug 2002 22:56:34 -0000 1.4
@@ -57,6 +57,7 @@
package org.apache.cactus.ant;
import java.io.IOException;
+
import java.net.HttpURLConnection;
import java.net.MalformedURLException;
import java.net.URL;
@@ -106,64 +107,83 @@
public void execute() throws BuildException
{
// Verify that a test URL has been specified
- if (this.testURL == null) {
+ if (this.testURL == null)
+ {
throw new BuildException("A testURL attribute must be specified");
}
// Verify that a stop target has been specified
- if (this.stopTarget == null) {
+ if (this.stopTarget == null)
+ {
throw new BuildException("A stopTarget Ant target name must be "
+ "specified");
}
// Try connecting in case the server is already stopped.
- try {
- HttpURLConnection connection =
+ try
+ {
+ HttpURLConnection connection =
(HttpURLConnection) this.testURL.openConnection();
+
connection.connect();
StartServerHelper.readFully(connection);
connection.disconnect();
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
// Server is not running. Make this task a no-op.
return;
}
// Call the target that stops the server, in another thread.
Thread thread = new Thread(this);
+
thread.start();
// Wait a few ms more (just to make sure)
- try {
+ try
+ {
Thread.sleep(500);
- } catch (InterruptedException e) {
+ }
+ catch (InterruptedException e)
+ {
throw new BuildException("Interruption during sleep", e);
}
// Continuously try calling the test URL until it fails
- while (true) {
-
- try {
- HttpURLConnection connection =
+ while (true)
+ {
+ try
+ {
+ HttpURLConnection connection =
(HttpURLConnection) this.testURL.openConnection();
+
connection.connect();
StartServerHelper.readFully(connection);
connection.disconnect();
- } catch (IOException e) {
+ }
+ catch (IOException e)
+ {
break;
}
- try {
+ try
+ {
Thread.sleep(500);
- } catch (InterruptedException ee) {
+ }
+ catch (InterruptedException ee)
+ {
throw new BuildException("Interruption during sleep", ee);
}
-
}
// Wait a few ms more (just to be sure !)
- try {
+ try
+ {
Thread.sleep(500);
- } catch (InterruptedException e) {
+ }
+ catch (InterruptedException e)
+ {
throw new BuildException("Interruption during sleep", e);
}
@@ -180,6 +200,7 @@
{
// Call the Ant target using the "antcall" task.
CallTarget callee;
+
callee = (CallTarget) (this.task.getProject().createTask("antcall"));
callee.setOwningTarget(this.task.getOwningTarget());
callee.setTaskName(this.task.getTaskName());
@@ -197,9 +218,12 @@
*/
public void setTestURL(String theTestURL)
{
- try {
+ try
+ {
this.testURL = new URL(theTestURL);
- } catch (MalformedURLException e) {
+ }
+ catch (MalformedURLException e)
+ {
throw new BuildException("Bad URL [" + theTestURL + "]", e);
}
}
@@ -211,5 +235,4 @@
{
this.stopTarget = theStopTarget;
}
-
}
--
To unsubscribe, e-mail: <ma...@jakarta.apache.org>
For additional commands, e-mail: <ma...@jakarta.apache.org>