com.ibm.xcap.client
Class WorkerThreadPool

java.lang.Object
  extended by com.ibm.xcap.client.WorkerThreadPool

public class WorkerThreadPool
extends java.lang.Object

A general purpose object pool.


Field Summary
static java.lang.String CLASSNAME
          Classname
protected  java.lang.Object counterLock
          An object used for synchronization *
protected  java.lang.Object lock
          An object used for synchronization *
static java.util.logging.Logger LOGGER
          Logger for this class
protected  int maxSize
          Maximum size of the pool *
protected  int minSize
          Minimum size of the pool *
protected  java.util.Stack<java.lang.Object> pool
          A stack for pooling the objects *
protected  int threadCounter
          Number of threads currently created
protected  WorkerThreadFactory workerFactory
          The ObjectFactory used to create and destroy objects *
 
Constructor Summary
protected WorkerThreadPool()
          Empty constructor used for subclassing.
  WorkerThreadPool(WorkerThreadFactory workerFactory)
          Constructs a default ObjectPool.
  WorkerThreadPool(WorkerThreadFactory workerFactory, int minSize, int maxSize)
          Constructs an WorkerThreadPool with the specified number of minimum and maximum objects.
 
Method Summary
 void checkin(java.lang.Object o)
          Checkin an object back into the pool.
 java.lang.Object checkout()
          Checkout an object from the pool.
 void destroyAll()
          Clean up our resources
 int getMaxSize()
           
 int getMinSize()
           
 int getSize()
           
 int getThreadCount()
          Number of threads created
 void incThreadCount()
           
protected  void init(WorkerThreadFactory workerFactory, int minSize, int maxSize)
          Initializes an ObjectPool with the specified number of minimum and maximum objects.
 void setMaxSize(int maxSize)
           
 void setMinSize(int minSize)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

CLASSNAME

public static final java.lang.String CLASSNAME
Classname


LOGGER

public static final java.util.logging.Logger LOGGER
Logger for this class


lock

protected java.lang.Object lock
An object used for synchronization *


counterLock

protected java.lang.Object counterLock
An object used for synchronization *


minSize

protected int minSize
Minimum size of the pool *


maxSize

protected int maxSize
Maximum size of the pool *


threadCounter

protected int threadCounter
Number of threads currently created


pool

protected java.util.Stack<java.lang.Object> pool
A stack for pooling the objects *


workerFactory

protected WorkerThreadFactory workerFactory
The ObjectFactory used to create and destroy objects *

Constructor Detail

WorkerThreadPool

protected WorkerThreadPool()
Empty constructor used for subclassing. The init() method must be invoked by the subclass.


WorkerThreadPool

public WorkerThreadPool(WorkerThreadFactory workerFactory)
Constructs a default ObjectPool. Default min of 10 and a max of 100. objects.

Parameters:
objectFactory - The ObjectFactory used to create or destroy objects.

WorkerThreadPool

public WorkerThreadPool(WorkerThreadFactory workerFactory,
                        int minSize,
                        int maxSize)
Constructs an WorkerThreadPool with the specified number of minimum and maximum objects.

Parameters:
workerFactory - The WorkerThreadFactory used to create or destroy objects.
minSize - The minimum number of objects that are kept in the pool.
maxSize - The maximum number of objects that are kept in the pool.
Method Detail

init

protected void init(WorkerThreadFactory workerFactory,
                    int minSize,
                    int maxSize)
Initializes an ObjectPool with the specified number of minimum and maximum objects.

Parameters:
objectFactory - The ObjectFactory used to create or destroy objects.
minSize - The minimum number of objects that are kept in the pool.
maxSize - The maximum number of objects that are kept in the pool.

checkout

public java.lang.Object checkout()
Checkout an object from the pool. Remember to check the object back into the pool when done.

Returns:
Returns an object.

checkin

public void checkin(java.lang.Object o)
Checkin an object back into the pool.

Parameters:
o - An object to check back into the pool.

getMinSize

public int getMinSize()

getMaxSize

public int getMaxSize()

setMinSize

public void setMinSize(int minSize)

setMaxSize

public void setMaxSize(int maxSize)

getSize

public int getSize()

incThreadCount

public void incThreadCount()

getThreadCount

public int getThreadCount()
Number of threads created


destroyAll

public void destroyAll()
Clean up our resources