javapool.objects
Class ObjectPool
java.lang.Object
|
+--javapool.objects.ObjectPool
- public abstract class ObjectPool
- extends java.lang.Object
Class used to manage pools of objects. The specific object pools will extend this class
|
Constructor Summary |
ObjectPool(java.lang.String className,
int poolSize,
int maxPoolSize,
int poolBuffer,
int refreshFrequency,
int objectLifeSpan,
boolean doPing,
int deadObjectPingCount,
int reInstantiateObjectCount,
int maxIssueTime)
Constructor in child classes should called this method using the super () call. |
|
Method Summary |
java.lang.String |
getClassName()
Returns the name of the class handled by this ObjectPool |
java.lang.Object |
getObject()
Checks out and returns a free object. |
void |
printStats(java.io.BufferedWriter bw)
Prints the stats for this object pool |
void |
returnObject(java.lang.Object obj)
Restores an object back into the pool |
void |
shutdown()
Shuts down the object pool |
void |
startup()
Starts the object pool |
| Methods inherited from class java.lang.Object |
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
poolDead
public boolean poolDead
poolStopped
public boolean poolStopped
ObjectPool
public ObjectPool(java.lang.String className,
int poolSize,
int maxPoolSize,
int poolBuffer,
int refreshFrequency,
int objectLifeSpan,
boolean doPing,
int deadObjectPingCount,
int reInstantiateObjectCount,
int maxIssueTime)
- Constructor in child classes should called this method using the super () call. The constructor requires the following instantiation variables:
value 0: String className -> The name of the class that this ObjectPool will be maintaining (ie. Customer, Address, Truck, etc.). The name of
the specific object pool will be in the format className + "Pool.class"
value 1: int poolSize -> Defines the size of this pool
value 2: int maxPoolSize -> Defines the largest that this pool can grow
value 3: int poolBuffer -> Defines when the pool should be resized. There are two situations in which a pool is resized. First is when the # of
free objects is less than the buffer, at which time the poolSize is increased by the # specified by poolBuffer. The second occasion is when
the number of free objects exceeds the poolSize, at which time the poolSize is decreased by the # specified by poolBuffer.
value 4: int refreshFrequency -> Specifies the frequency in milliseconds for which the objects in this pool should be pinged. Object will not be
pinged if this value is set to 0. If it is not, then the object should contain an implementation of the public boolean ping () method which
returns true for a alive status and false for a dead status.
value 5: int objectLifeSpan -> Specifies the lifespan of the ojects in milliseconds. Object will never die if set to 0. If not, then the object
will be dereferenced and a new one instantiated to take it's place at the designated interval
value 6: boolean doPing -> Specifies rather or not this object has a ping method implemented. If false then the values for pingPrior,
refreshFrequency, deadObjectPingCount, and reInstantiateObjectCount will be insignificant.
value 7: int deadObjectPingCount -> Number of times an object should be pinged before it is released and the system attempts to create a new one
to take it's place
value 8: int reInstantiateObjectCount -> Number of times that an object should be re-instantiated after reaching the deadObjectPingCount before
this particular pool changes to a dead status (PoolDeadExceptions will be thrown in this status)
value 9: int maxIssueTime -> Specifies the max issue time for the pool to have an object checked out. Once this max time is reached, the object
should be released from the pool and another instantiated to take it's place. This value should always be specified as a safeguard
getClassName
public java.lang.String getClassName()
- Returns the name of the class handled by this ObjectPool
getObject
public java.lang.Object getObject()
throws PoolBusyException,
PoolDeadException,
PoolStoppedException
- Checks out and returns a free object. If no objects are free then a PoolBusyException is thrown
returnObject
public void returnObject(java.lang.Object obj)
throws ObjectNotInPoolException,
PoolDeadException,
PoolStoppedException
- Restores an object back into the pool
shutdown
public void shutdown()
- Shuts down the object pool
startup
public void startup()
- Starts the object pool
printStats
public void printStats(java.io.BufferedWriter bw)
- Prints the stats for this object pool