|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object | +--org.gjt.rec.util.ObjectPool
This class implements an object pool. The pool is configured with an object factory and a capacity, although the capacity may be reconfigured at any time. Client code borrows objects from the pool and then returns them later. During this time, the client code has exclusive access to the object.
ObjectFactory
,
ObjectPool.Listener
Nested Class Summary | |
static interface |
ObjectPool.Listener
The interface implemented by objects that wish to be notified when they are removed from an object pool. |
static class |
ObjectPool.NotPooledException
Thrown to indicate that an object that was supposed to be contained in this object pool is in fact not. |
Field Summary | |
static String |
COPYRIGHT
|
static String |
LICENSE
|
static String |
REVISION
|
Constructor Summary | |
ObjectPool(ObjectFactory fact)
Constructs a new object pool with a particular object factory and the default capacity of 1. |
Method Summary | |
Object |
borrowObject()
Borrows an object from this object pool. |
Collection |
getAvailableObjects()
Determines the objects that are available for loan. |
int |
getCapacity()
Determines the current capacity of this object pool. |
Collection |
getLoanedObjects()
Determines the objects that are out on loan. |
void |
remove(Object obj)
Removes a particular object from this object pool. |
void |
returnObject(Object obj)
Returns a particular object to this object pool. |
void |
setCapacity(int newCapacity)
Sets the capacity of this object pool to a particular size. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
public static final String COPYRIGHT
public static final String LICENSE
public static final String REVISION
Constructor Detail |
public ObjectPool(ObjectFactory fact)
fact
- the object factory with which this object pool will
instantiate objects to populate itself
NullPointerException
- if (fact) is nullMethod Detail |
public int getCapacity()
public void setCapacity(int newCapacity)
newCapacity
- the new capacity of this object pool
IllegalArgumentException
- if the specified capacity is less
than onepublic Collection getAvailableObjects()
public Collection getLoanedObjects()
public Object borrowObject()
public void returnObject(Object obj)
obj
- the object to return to this pool
ObjectPool.NotPooledException
- if the supplied object was never part of
this object poolpublic void remove(Object obj)
obj
- the object that will no longer be loaned out
ObjectPool.NotPooledException
- if the supplied object is not part of this
pool
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |