org.ws4d.java.util
Class ObjectPool

java.lang.Object
  extended by org.ws4d.java.util.ObjectPool

public class ObjectPool
extends java.lang.Object


Nested Class Summary
static interface ObjectPool.InstanceCreator
           
 
Constructor Summary
ObjectPool(ObjectPool.InstanceCreator creator)
          Creates a new pool with no limit on the maximum number of pooled objects and an initial pool size of 10.
ObjectPool(ObjectPool.InstanceCreator creator, int initialSize)
          Creates a new pool with no limit on the total number of pooled objects.
ObjectPool(ObjectPool.InstanceCreator creator, int initialSize, int maxSize)
          Creates a new pool with a maximum total number of pooled objects of maxSize.
 
Method Summary
 java.lang.Object acquire()
           
 void release(java.lang.Object o)
           
 
Methods inherited from class java.lang.Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectPool

public ObjectPool(ObjectPool.InstanceCreator creator)
Creates a new pool with no limit on the maximum number of pooled objects and an initial pool size of 10.

Parameters:
creator - the instance creator for creating new pooled objects

ObjectPool

public ObjectPool(ObjectPool.InstanceCreator creator,
                  int initialSize)
Creates a new pool with no limit on the total number of pooled objects.

Parameters:
creator - the instance creator for creating new pooled objects
initialSize - the initial pool size

ObjectPool

public ObjectPool(ObjectPool.InstanceCreator creator,
                  int initialSize,
                  int maxSize)
Creates a new pool with a maximum total number of pooled objects of maxSize. The pool will initially have a capacity of initialSize instances. New instances will be created by the specified creator.

Parameters:
creator - the instance creator for creating new pooled objects
initialSize - the initial pool size
maxSize - the maximum pool size; if -1, no limit on the pool size is imposed
Method Detail

acquire

public java.lang.Object acquire()

release

public void release(java.lang.Object o)