nl.knowledgeplaza.util.pool
Class CollectionObjectPoolFactory<T>

java.lang.Object
  extended by nl.knowledgeplaza.util.pool.CollectionObjectPoolFactory<T>
All Implemented Interfaces:
PoolableObjectFactory<T>

public class CollectionObjectPoolFactory<T>
extends Object
implements PoolableObjectFactory<T>

This class is a simple implementation of an ObjectPoolFactory. A new instance of this class is provided with a list of values that are pooled. The instance can be handed over to a StackObjectPool or a RoundRobinObjectPool to provide pooling behaviour. Making a new object means that one object is removed from the list and handed over to the pool to be managed. If the list is empty, null will be returned. It is up to the pool to decide if it will then wait or abort. Objects are always considered valid, and no action is take to activate or destroy them. These methods can be overridden. Destroyed objects are added back to the list if RecycleObjects = true.

Version:
$Revision: 1.3 $

Field Summary
protected  boolean iRecycleObjects
           
static String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
 
Constructor Summary
CollectionObjectPoolFactory(Collection<T> data)
           
CollectionObjectPoolFactory(Collection<T> data, boolean recycle)
           
 
Method Summary
 void activateObject(T arg0)
           
 void destroyObject(T arg0)
          if RecycleObjects = true, objects are added back to the list
 boolean getRecycleObjects()
           
 T makeObject()
           
 void passivateObject(Object arg0)
           
 void setRecycleObjects(boolean value)
          RecycleObjects
 boolean validateObject(T arg0)
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOURCECODE_VERSION

public static final String SOURCECODE_VERSION
Standard variable for determining version of a class file.

See Also:
Constant Field Values

iRecycleObjects

protected boolean iRecycleObjects
Constructor Detail

CollectionObjectPoolFactory

public CollectionObjectPoolFactory(Collection<T> data)
Parameters:
data -

CollectionObjectPoolFactory

public CollectionObjectPoolFactory(Collection<T> data,
                                   boolean recycle)
Parameters:
data -
recycle -
Method Detail

setRecycleObjects

public void setRecycleObjects(boolean value)
RecycleObjects


getRecycleObjects

public boolean getRecycleObjects()

makeObject

public T makeObject()
Specified by:
makeObject in interface PoolableObjectFactory<T>

validateObject

public boolean validateObject(T arg0)
Specified by:
validateObject in interface PoolableObjectFactory<T>

activateObject

public void activateObject(T arg0)
Specified by:
activateObject in interface PoolableObjectFactory<T>

passivateObject

public void passivateObject(Object arg0)
Specified by:
passivateObject in interface PoolableObjectFactory<T>

destroyObject

public void destroyObject(T arg0)
if RecycleObjects = true, objects are added back to the list

Specified by:
destroyObject in interface PoolableObjectFactory<T>


Copyright © 2011 KnowledgePlaza. All Rights Reserved.