com.partnersoft.v3x.data
Class ObjectPool

java.lang.Object
  extended by com.partnersoft.v3x.data.ObjectPool

public abstract class ObjectPool
extends java.lang.Object

A pool for generic reuseable objects.


Constructor Summary
ObjectPool()
           
ObjectPool(int poolSize)
           
 
Method Summary
abstract  java.lang.Object allocateObject()
           
 java.lang.Object catchObject()
          Grabs an object from the pool; allocates if necessary.
 int getNumberOfObjects()
          Gets the current pool size.
 int getPoolSize()
          Maximum number of objects pooled.
 void releaseObject(java.lang.Object usedUpObject)
          Releases a object back to the pool.
 void setPoolSize(int newMax)
          Set maximum number of objects in pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectPool

public ObjectPool(int poolSize)

ObjectPool

public ObjectPool()
Method Detail

getPoolSize

public int getPoolSize()
Maximum number of objects pooled.


setPoolSize

public void setPoolSize(int newMax)
Set maximum number of objects in pool. Clears pool if new max is larger than current pool size.


getNumberOfObjects

public int getNumberOfObjects()
Gets the current pool size.


allocateObject

public abstract java.lang.Object allocateObject()

catchObject

public java.lang.Object catchObject()
Grabs an object from the pool; allocates if necessary. Be sure to release it with releaseObject() when you're done with it so it can go back into the pool, eh? And don't go hanging onto a reference and modifying it while someone else is trying to use it, or I'll come find you and run over your garden gnomes with my truck.


releaseObject

public void releaseObject(java.lang.Object usedUpObject)
Releases a object back to the pool. Discards it if we already have a full pool or if it's size doesn't match our current poolSize.