|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.pool.BaseObjectPool
public abstract class BaseObjectPool
A simple base implementation of ObjectPool
.
Optional operations are implemented to either do nothing, return a value
indicating it is unsupported or throw UnsupportedOperationException
.
Constructor Summary | |
---|---|
BaseObjectPool()
|
Method Summary | |
---|---|
void |
addObject()
Not supported in this base implementation. |
protected void |
assertOpen()
Throws an IllegalStateException when this pool has been closed. |
abstract java.lang.Object |
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(java.lang.Object obj)
Invalidates an object from the pool. |
boolean |
isClosed()
Has this pool instance been closed. |
abstract void |
returnObject(java.lang.Object obj)
Returns an instance to the pool. |
void |
setFactory(PoolableObjectFactory factory)
Deprecated. to be removed in pool 2.0 |
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 java.lang.Object borrowObject() throws java.lang.Exception
borrowObject
in interface ObjectPool
java.lang.Exception
- if an instance cannot be obtained from the poolpublic abstract void returnObject(java.lang.Object obj) throws java.lang.Exception
returnObject
in interface ObjectPool
obj
- instance to return to the pool
java.lang.Exception
public abstract void invalidateObject(java.lang.Object obj) throws java.lang.Exception
Invalidates an object from the pool.
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
obj
- a borrowed
instance to be disposed.
java.lang.Exception
public int getNumIdle() throws java.lang.UnsupportedOperationException
getNumIdle
in interface ObjectPool
java.lang.UnsupportedOperationException
public int getNumActive() throws java.lang.UnsupportedOperationException
getNumActive
in interface ObjectPool
java.lang.UnsupportedOperationException
public void clear() throws java.lang.Exception, java.lang.UnsupportedOperationException
clear
in interface ObjectPool
java.lang.UnsupportedOperationException
java.lang.Exception
public void addObject() throws java.lang.Exception, java.lang.UnsupportedOperationException
UnsupportedOperationException
,
subclasses should override this behavior.
addObject
in interface ObjectPool
java.lang.UnsupportedOperationException
java.lang.Exception
- when PoolableObjectFactory.makeObject()
fails.
java.lang.IllegalStateException
- after ObjectPool.close()
has been called on this pool.public void close() throws java.lang.Exception
isClosed
and assertOpen
.
close
in interface ObjectPool
java.lang.Exception
- deprecated: implementations should silently fail if not all resources can be freed.public void setFactory(PoolableObjectFactory factory) throws java.lang.IllegalStateException, java.lang.UnsupportedOperationException
UnsupportedOperationException
,
subclasses should override this behavior.
setFactory
in interface ObjectPool
factory
- the PoolableObjectFactory
java.lang.UnsupportedOperationException
java.lang.IllegalStateException
public final boolean isClosed()
true
when this pool has been closed.protected final void assertOpen() throws java.lang.IllegalStateException
IllegalStateException
when this pool has been closed.
java.lang.IllegalStateException
- when this pool has been closed.isClosed()
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |