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 jr...@apache.org on 2003/01/31 11:19:10 UTC
cvs commit: jakarta-cactus/petals/eclipse/src/java/org/apache/cactus/eclipse/containers/ant StartServerHelper.java
jruaux 2003/01/31 02:19:10
Modified: petals/eclipse/src/java/org/apache/cactus/eclipse/containers/ant
StartServerHelper.java
Log:
Added a time-out for container startup
Revision Changes Path
1.2 +19 -3 jakarta-cactus/petals/eclipse/src/java/org/apache/cactus/eclipse/containers/ant/StartServerHelper.java
Index: StartServerHelper.java
===================================================================
RCS file: /home/cvs/jakarta-cactus/petals/eclipse/src/java/org/apache/cactus/eclipse/containers/ant/StartServerHelper.java,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -r1.1 -r1.2
--- StartServerHelper.java 30 Jan 2003 15:37:08 -0000 1.1
+++ StartServerHelper.java 31 Jan 2003 10:19:10 -0000 1.2
@@ -62,7 +62,6 @@
import java.io.PrintWriter;
import java.net.HttpURLConnection;
import java.net.URL;
-
import org.apache.cactus.eclipse.ui.CactusMessages;
import org.apache.tools.ant.BuildException;
import org.eclipse.ant.core.AntRunner;
@@ -108,6 +107,11 @@
private boolean isServerAlreadyStarted = false;
/**
+ * Duration in which the container has to start.
+ */
+ private long timeOut = 20000;
+
+ /**
* @param theRunner the Ant runner that this helper is calling
*/
public StartServerHelper(AntRunner theRunner)
@@ -154,7 +158,9 @@
// target must be blocking.
Thread thread = new Thread(this);
+ long startTime = System.currentTimeMillis();
thread.start();
+
// Wait a few ms more (just to make sure the servlet engine is
// ready to accept connections)
sleep(1000);
@@ -164,6 +170,15 @@
// Continuously try calling the test URL until it succeeds
while (true)
{
+ // If startup timed out we throw an exception to cancel the launch
+ boolean timeOver =
+ (System.currentTimeMillis() - startTime) > timeOut;
+ if (timeOver)
+ {
+ throw new BuildException(
+ CactusMessages.getString(
+ "CactusLaunch.message.start.timeout"));
+ }
// If the user cancelled the start
if (pm.isCanceled())
{
@@ -179,7 +194,8 @@
}
break;
}
-
+
+
// Wait a few ms more (just to be sure !)
sleep(500);
---------------------------------------------------------------------
To unsubscribe, e-mail: cactus-dev-unsubscribe@jakarta.apache.org
For additional commands, e-mail: cactus-dev-help@jakarta.apache.org