|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||
java.lang.Objectorg.jcreme.pool.ObjectPool
This class represents a pool of objects. That is a number of objects that are shared in an application as a limited resource. This is a lazy implementation, it builds the pooled objects as needed through the use of the buildObject method. This class must be derived to provide an actual implementation of the buildNew method.
| Constructor Summary | |
protected |
ObjectPool(int minSize,
int maxSize)
Creates a new instance of ObjectPool If the minSize is greater than the maxSize, it is reduced to the maxSize. |
| Method Summary | |
protected abstract java.lang.Object |
buildNew()
This method enabled to build a new object when needed. |
protected java.util.Collection |
getFreeObjects()
Gives access to the freeObjects Stack. |
protected java.lang.Object |
getObject()
This method enables to get an object from the ObjectPool. |
protected java.lang.Object |
getObject(int waitingPeriod)
This method enables to get an object from the ObjectPool. |
protected java.lang.Object |
getObjectFromFree()
This method enables to retrieve an object from the freeObjects stack. |
protected java.lang.Object |
getObjectFromFree(int waitingPeriod)
This method enables to retrieve an object from the freeObjects stack. |
protected java.lang.Object |
getObjectFromUsed(java.lang.Object o)
This method enables to remove an object from the usedObjects list. |
protected java.util.Collection |
getUsedObjects()
Gives access to the usedObjects Vector. |
protected void |
initPool()
This method makes as many calls to buildNew as minSize. |
protected void |
putInFreeObjects(java.lang.Object o)
This method enabled to return an object to the freeObjects stack. |
protected void |
putInUsedObjects(java.lang.Object o)
This method enabled to register an object to the usedObjects list. |
protected void |
releaseObject(java.lang.Object obj)
This method enables to return an object to the ObjectPool. |
protected abstract void |
removeOld(java.lang.Object obj)
This method enabled to remove an old object when needed. |
void |
setMaximumSize(int maxSize)
This method enables to change the maximum size of the ConnectionPool. |
void |
setMinimumSize(int minSize)
This method enables to change the minimum size of the ConnectionPool. |
| Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
| Constructor Detail |
protected ObjectPool(int minSize,
int maxSize)
minSize - the initial size of the pool.maxSize - the maximum size of the pool.| Method Detail |
protected final void initPool()
protected abstract java.lang.Object buildNew()
protected abstract void removeOld(java.lang.Object obj)
obj - the object to remove.
protected java.lang.Object getObjectFromFree()
throws java.lang.InterruptedException
java.lang.InterruptedException - if the wait for a free object was interrupted.
protected java.lang.Object getObjectFromFree(int waitingPeriod)
throws java.lang.InterruptedException
waitingPeriod - the time the method is allowed to wait for an object from the
pool.
java.lang.InterruptedException - if the wait for a free object was interrupted.protected java.lang.Object getObjectFromUsed(java.lang.Object o)
o - the object to remove from the usedObjects.
protected void putInFreeObjects(java.lang.Object o)
o - the object to return to the stack.protected void putInUsedObjects(java.lang.Object o)
o - the object to add to the usedObjects list.protected java.lang.Object getObject()
protected java.lang.Object getObject(int waitingPeriod)
waitingPeriod - the number of millisecond the method will wait for an object
to be freed.
protected void releaseObject(java.lang.Object obj)
obj - the object to release.protected java.util.Collection getFreeObjects()
protected java.util.Collection getUsedObjects()
public void setMinimumSize(int minSize)
minSize - the new minimum size to apply.public void setMaximumSize(int maxSize)
maxSize - the new maximum size to apply.
|
|||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||||||