org.globus.wsrf.container
Class ServiceThreadPool

java.lang.Object
  extended byorg.globus.wsrf.container.ServiceThreadPool
Direct Known Subclasses:
GSIServiceThreadPool

public class ServiceThreadPool
extends java.lang.Object

This class is responsible for managing a set of threads. New threads can be added to the pool at any given time.


Field Summary
protected  ServiceDispatcher dispatcher
           
private static org.globus.util.I18n i18n
           
private static org.apache.commons.logging.Log logger
           
private  java.util.ArrayList serviceThreads
           
 
Constructor Summary
ServiceThreadPool(ServiceDispatcher dispatcher)
           
 
Method Summary
protected  ServiceThread createThread()
           
 int getThreads()
          Returns the current number of service threads in the pool.
 boolean hasThread(java.lang.Thread thread)
          Checks the specified thread is in the pool.
private  boolean isDone()
           
 void postReload()
          Puts ServiceThreads in post reload mode.
 void preReload(int timeout)
          Puts ServiceThreads in reload mode and waits until they finish executing the current request (if any) or the given timeout expires.
 void removeThread(ServiceThread thread)
          Removes the specified thread from the pool.
 int startThreads(int threads)
          Creates the specified number of threads and adds them to the pool.
 void stopThreads()
          Requests all of the service threads to stop.
 void stopThreads(int numThreads)
          Requests the specified number of service threads to stop.
 void waitForThreads()
          Blocks until the thread pool is empty.
 void waitForThreads(int timeout)
          Blocks until the thread pool is empty or until the given timeout elapses.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

logger

private static final org.apache.commons.logging.Log logger

i18n

private static org.globus.util.I18n i18n

serviceThreads

private java.util.ArrayList serviceThreads

dispatcher

protected ServiceDispatcher dispatcher
Constructor Detail

ServiceThreadPool

public ServiceThreadPool(ServiceDispatcher dispatcher)
Method Detail

startThreads

public int startThreads(int threads)
Creates the specified number of threads and adds them to the pool.


createThread

protected ServiceThread createThread()

getThreads

public int getThreads()
Returns the current number of service threads in the pool.


preReload

public void preReload(int timeout)
Puts ServiceThreads in reload mode and waits until they finish executing the current request (if any) or the given timeout expires. Putting ServiceThreads in reload mode causes them to return "Service Unavailable" to any request.


postReload

public void postReload()
Puts ServiceThreads in post reload mode. Putting ServiceThreads in post reload mode causes them to refresh their caches, update context classloader, and its Axis engine and start normally answering to the requests.


stopThreads

public void stopThreads(int numThreads)
Requests the specified number of service threads to stop.


stopThreads

public void stopThreads()
Requests all of the service threads to stop.


removeThread

public void removeThread(ServiceThread thread)
Removes the specified thread from the pool.


hasThread

public boolean hasThread(java.lang.Thread thread)
Checks the specified thread is in the pool.


waitForThreads

public void waitForThreads()
                    throws java.lang.InterruptedException
Blocks until the thread pool is empty.

Throws:
java.lang.InterruptedException

waitForThreads

public void waitForThreads(int timeout)
                    throws java.lang.InterruptedException
Blocks until the thread pool is empty or until the given timeout elapses.

Throws:
java.lang.InterruptedException

isDone

private boolean isDone()