|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||
A pooling interface.
ObjectPool defines a trivially simple pooling interface. The only
required methods are borrowObject and returnObject.
Example of use:
Object obj = null;
try {
obj = pool.borrowObject();
//...use the object...
} catch(Exception e) {
//...handle any exceptions...
} finally {
// make sure the object is returned to the pool
if(null != obj) {
pool.returnObject(obj);
}
} |
BaseObjectPool for a simple base implementation.
| Method Summary | |
Object |
borrowObject()
Obtain an instance from my pool. |
void |
clear()
Clears any objects sitting idle in the pool, releasing any associated resources (optional operation). |
void |
close()
Close this pool, and free any resources associated with it. |
int |
getNumActive()
Return the number of instances currently borrowed from my pool (optional operation). |
int |
getNumIdle()
Return the number of instances currently idle in my pool (optional operation). |
void |
returnObject(Object obj)
Return an instance to my pool. |
void |
setFactory(PoolableObjectFactory factory)
Sets the factory I use
to create new instances (optional operation). |
| Method Detail |
public Object borrowObject()
throws Exception
returnObject
or a related method as defined in an implementation
or sub-interface.
The behaviour of this method when the pool has been exhausted is not specified (although it may be specified by implementations).
Exception
public void clear()
throws Exception,
UnsupportedOperationException
UnsupportedOperationException - if this implementation does not support the operation
Exception
public void close()
throws Exception
Exception
public int getNumActive()
throws UnsupportedOperationException
UnsupportedOperationException - if this implementation does not support the operation
public int getNumIdle()
throws UnsupportedOperationException
borrowed
without creating any new instances.
UnsupportedOperationException - if this implementation does not support the operation
public void returnObject(Object obj)
throws Exception
borrowObject
or a related method as defined in an implementation
or sub-interface.
obj - a borrowed instance to be returned.
Exception
public void setFactory(PoolableObjectFactory factory)
throws IllegalStateException,
UnsupportedOperationException
factory I use
to create new instances (optional operation).
factory - the PoolableObjectFactory I use to create new instances.
IllegalStateException - when the factory cannot be set at this time
UnsupportedOperationException - if this implementation does not support the operation
|
|||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | ||||||