|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.pool2.BaseObjectPool<T>
T
- Type of element pooled in this pool.public abstract class BaseObjectPool<T>
A simple base implementation of ObjectPool
.
Optional operations are implemented to either do nothing, return a value
indicating it is unsupported or throw UnsupportedOperationException
.
This class is intended to be thread-safe.
Constructor Summary | |
---|---|
BaseObjectPool()
|
Method Summary | |
---|---|
void |
addObject()
Not supported in this base implementation.Always throws an UnsupportedOperationException , subclasses should override this
behavior. |
protected void |
assertOpen()
Throws an IllegalStateException when this pool has been
closed. |
abstract T |
borrowObject()
Obtains an instance from the pool. |
void |
clear()
Not supported in this base implementation. |
void |
close()
Close this pool. |
int |
getNumActive()
Not supported in this base implementation. |
int |
getNumIdle()
Not supported in this base implementation. |
abstract void |
invalidateObject(T obj)
Invalidates an object from the pool. |
boolean |
isClosed()
Has this pool instance been closed. |
abstract void |
returnObject(T obj)
Returns an instance to the pool. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BaseObjectPool()
Method Detail |
---|
public abstract T borrowObject() throws Exception
borrowObject
in interface ObjectPool<T>
Exception
- if an instance cannot be obtained from the poolpublic abstract void returnObject(T obj) throws Exception
returnObject
in interface ObjectPool<T>
obj
- instance to return to the pool
Exception
public abstract void invalidateObject(T obj) throws Exception
By contract, obj
must have been obtained
using borrowObject
.
This method should be used when an object that has been borrowed is determined (due to an exception or other problem) to be invalid.
invalidateObject
in interface ObjectPool<T>
obj
- a borrowed
instance to be disposed.
Exception
public int getNumIdle()
getNumIdle
in interface ObjectPool<T>
public int getNumActive()
getNumActive
in interface ObjectPool<T>
public void clear() throws Exception, UnsupportedOperationException
clear
in interface ObjectPool<T>
UnsupportedOperationException
Exception
public void addObject() throws Exception, UnsupportedOperationException
UnsupportedOperationException
, subclasses should override this
behavior.
addObject
in interface ObjectPool<T>
UnsupportedOperationException
Exception
- when PooledObjectFactory.makeObject()
fails.
IllegalStateException
- after ObjectPool.close()
has been called on this pool.public void close()
isClosed
and
assertOpen
.
close
in interface ObjectPool<T>
public final boolean isClosed()
true
when this pool has been closed.protected final void assertOpen() throws IllegalStateException
IllegalStateException
when this pool has been
closed.
IllegalStateException
- when this pool has been closed.isClosed()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |