public abstract class BaseObjectPool extends Object implements ObjectPool
ObjectPool.
Optional operations are implemented to either do nothing, return a value
indicating it is unsupported or throw UnsupportedOperationException.| Constructor and Description |
|---|
BaseObjectPool() |
| Modifier and Type | Method and Description |
|---|---|
void |
addObject()
Not supported in this base implementation.
|
protected void |
assertOpen()
Throws an
IllegalStateException when this pool has been closed. |
abstract 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(Object obj)
Invalidates an object from the pool.
|
protected boolean |
isClosed()
Has this pool instance been closed.
|
abstract void |
returnObject(Object obj)
Returns an instance to the pool.
|
void |
setFactory(PoolableObjectFactory factory)
Deprecated.
to be removed in pool 2.0
|
public abstract Object borrowObject() throws Exception
borrowObject in interface ObjectPoolException - if an instance cannot be obtained from the poolpublic abstract void returnObject(Object obj) throws Exception
returnObject in interface ObjectPoolobj - instance to return to the poolException - if an error occurspublic abstract void invalidateObject(Object obj) throws 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 ObjectPoolobj - a borrowed instance to be disposed.Exception - if an error occurspublic int getNumIdle()
throws UnsupportedOperationException
getNumIdle in interface ObjectPoolUnsupportedOperationException - if not supportedpublic int getNumActive()
throws UnsupportedOperationException
getNumActive in interface ObjectPoolUnsupportedOperationException - if not supportedpublic void clear()
throws Exception,
UnsupportedOperationException
clear in interface ObjectPoolUnsupportedOperationException - if not supportedExceptionpublic void addObject()
throws Exception,
UnsupportedOperationException
UnsupportedOperationException,
subclasses should override this behavior.addObject in interface ObjectPoolUnsupportedOperationException - if not supportedExceptionpublic void close()
throws Exception
isClosed and assertOpen.close in interface ObjectPoolExceptionpublic void setFactory(PoolableObjectFactory factory) throws IllegalStateException, UnsupportedOperationException
UnsupportedOperationException,
subclasses should override this behavior.setFactory in interface ObjectPoolfactory - the PoolableObjectFactoryUnsupportedOperationException - if an error occursIllegalStateException - If an error occursprotected 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()Copyright © 2017. All rights reserved.