|
PooliT v2.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.ascentphase.poolit.poolers.TimeoutPooler
This Pooler will keep objects in its pool for a specified amount of time. When an object is put into the pool, it is marked with the time it is inserted. If the object stays in the pool longer than a specified period, it will be removed from the pool. A separate daemon thread is created with the pool which will periodic scan through the objects in the pool to see if there time there has exceed the limit. If there are no objects left in the pool and a fetch() is called, the pool will call the associated PoolHandler to create a new object.
| Field Summary | |
protected org.ascentphase.poolit.poolers.TimeoutPooler.Cleanup |
cleaner
|
protected PoolHandler |
handler
|
| Constructor Summary | |
TimeoutPooler(java.lang.Class name,
int size,
long timeout,
long interval)
Creates a TimeoutPooler for the specified class and size. |
|
TimeoutPooler(PoolHandler handler,
int size,
long timeout,
long interval)
Creates a TimeoutPooler with the specified Handler and size. |
|
| Method Summary | |
void |
cleanup()
Examines each object to see if any of them needs to be removed because there time limit has exceeded. |
void |
close()
Releases all objects in the pool and any resources held by these objects. |
java.lang.Object |
fetch()
Retrieves an object from the pool. |
protected void |
fillPool(int size)
Called by the constructor to fill the pool to the size specified. |
long |
getCleanupInterval()
|
long |
getTimeout()
Returns the amount of time (in msec.) that an object is allowed to remain unused in the pool before it is removed. |
void |
release(java.lang.Object o)
Returns an object to the pool. |
void |
setCleanupInterval(long cleanupInterval)
|
void |
setTimeout(long time)
Sets the amount of time (in msec.) that an object is allowed to remain unused in the pool before it is removed. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Field Detail |
protected PoolHandler handler
protected org.ascentphase.poolit.poolers.TimeoutPooler.Cleanup cleaner
| Constructor Detail |
public TimeoutPooler(java.lang.Class name,
int size,
long timeout,
long interval)
throws CreateException
name - the class to be pooledsize - the initial size of the pooltimeout - the time the object will stay in the pool (in msec.)interval - the interval which the cleanup thread is run (in msec.)
public TimeoutPooler(PoolHandler handler,
int size,
long timeout,
long interval)
throws CreateException
handler - the Handler this pool will usesize - the initial size of the pooltimeout - the time the object will stay in the pool (in msec.)interval - the interval which the cleanup thread is run (in msec.)| Method Detail |
public java.lang.Object fetch()
throws FetchException
Pooler
fetch in interface PoolerFetchException - if the pooler is unable to return an object from
the pool.public void release(java.lang.Object o)
Pooler
release in interface Poolero - the objectpublic void cleanup()
protected void fillPool(int size)
throws CreateException
size - number of objects to create
CreateExceptionpublic long getTimeout()
public void setTimeout(long time)
time - public void close()
Pooler
close in interface PoolerPooler.close()public long getCleanupInterval()
public void setCleanupInterval(long cleanupInterval)
cleanupInterval -
|
PooliT v2.0 | |||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||