vmassol     01/04/14 07:54:50

  Modified:    cactus/src/ant/org/apache/commons/cactus/ant
                        StartServerHelper.java
  Log:
  check if server is already started. If so, does nothing (thanks to Philip Aston).
  
  Revision  Changes    Path
  1.2       +14 -0     
jakarta-commons/cactus/src/ant/org/apache/commons/cactus/ant/StartServerHelper.java
  
  Index: StartServerHelper.java
  ===================================================================
  RCS file: 
/home/cvs/jakarta-commons/cactus/src/ant/org/apache/commons/cactus/ant/StartServerHelper.java,v
  retrieving revision 1.1
  retrieving revision 1.2
  diff -u -r1.1 -r1.2
  --- StartServerHelper.java    2001/04/09 11:52:34     1.1
  +++ StartServerHelper.java    2001/04/14 14:54:49     1.2
  @@ -111,6 +111,20 @@
               throw new BuildException("A startTarget Ant target name must be 
specified");
           }
   
  +        // Try connecting in case the server is already running. If so, does
  +        // nothing
  +        try {
  +            HttpURLConnection connection = 
(HttpURLConnection)m_TestURL.openConnection();
  +            connection.connect();
  +            connection.disconnect();
  +
  +            // Server is already running. Make this task a no-op.
  +            return;
  +        } catch (IOException e) {
  +            // An error occurred. It just measn the server is not running. Do
  +            // nothing        
  +        }
  +
           // Call the target that starts the server, in another thread. The called
           // target must be blocking.
           Thread thread = new Thread(this);
  
  
  

Reply via email to