org.apache.cactus.container
Class ContainerRunner

java.lang.Object
  extended by org.apache.cactus.container.ContainerRunner

public final class ContainerRunner
extends java.lang.Object

Support class that handles the lifecycle of a container, which basically consists of startup and shutdown.

Version:
$Id: ContainerRunner.java 239130 2005-01-29 15:49:18Z vmassol $

Constructor Summary
ContainerRunner(ContainerWrapper theContainerWrapper)
          Constructor.
 
Method Summary
 java.lang.String getServerName()
          Returns the server name as reported in the 'Server' header of HTTP responses from the server.
 void setCheckInterval(long theCheckInterval)
          Sets the time interval to sleep between polling the container.
 void setLogger(org.codehaus.cargo.util.log.Logger theLogger)
          Sets the log to write to.
 void setShutDownWait(long theShutDownWait)
          Sets the time to wait after the container has been shut down.
 void setTimeout(long theTimeout)
          Sets the timeout after which to stop trying to call the container.
 void setURL(java.net.URL theTestURL)
          Sets the HTTP/HTTPS URL that will be continuously pinged to check if the container is running.
 void shutDownContainer()
          Method called by the task to perform the stopping of the container.
 void startUpContainer()
          Method called by the task to perform the startup of the container.
 int testConnectivity(java.net.URL theUrl)
          Tests whether we are able to connect to the HTTP server identified by the specified URL.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ContainerRunner

public ContainerRunner(ContainerWrapper theContainerWrapper)
Constructor.

Parameters:
theContainerWrapper - The container to run
Method Detail

getServerName

public java.lang.String getServerName()
Returns the server name as reported in the 'Server' header of HTTP responses from the server.

Returns:
The server name

startUpContainer

public void startUpContainer()
                      throws java.lang.IllegalStateException
Method called by the task to perform the startup of the container. This method takes care of starting the container in another thread, and polling the test URL to check whether startup has completed. As soon as the URL is available (or the timeout is exceeded), control is returned to the caller.

Throws:
java.lang.IllegalStateException - If the 'url' property is null

shutDownContainer

public void shutDownContainer()
                       throws java.lang.IllegalStateException
Method called by the task to perform the stopping of the container. This method takes care of stopping the container in another thread, and polling the test URL to check whether shutdown has completed. As soon as the URL stops responding, control is returned to the caller.

Throws:
java.lang.IllegalStateException - If the 'url' property is null

setCheckInterval

public void setCheckInterval(long theCheckInterval)
Sets the time interval to sleep between polling the container. The default interval is 500 milliseconds.

Parameters:
theCheckInterval - The interval in milliseconds

setLogger

public void setLogger(org.codehaus.cargo.util.log.Logger theLogger)
Sets the log to write to.

Parameters:
theLogger - The log to set

setShutDownWait

public void setShutDownWait(long theShutDownWait)
Sets the time to wait after the container has been shut down. The default time is 2 seconds.

Parameters:
theShutDownWait - The time to wait in milliseconds

setTimeout

public void setTimeout(long theTimeout)
Sets the timeout after which to stop trying to call the container. The default timeout is 3 minutes.

Parameters:
theTimeout - The timeout in milliseconds

setURL

public void setURL(java.net.URL theTestURL)
Sets the HTTP/HTTPS URL that will be continuously pinged to check if the container is running.

Parameters:
theTestURL - The URL to set

testConnectivity

public int testConnectivity(java.net.URL theUrl)
Tests whether we are able to connect to the HTTP server identified by the specified URL.

Parameters:
theUrl - The URL to check
Returns:
the HTTP response code or -1 if no connection could be established


Copyright © 2001-2009 The Apache Software Foundation. All Rights Reserved.