T
- the type of objects held in this poolObjectPool<T>
GenericObjectPool
, SoftReferenceObjectPool
, StackObjectPool
public abstract class BaseObjectPool<T> extends java.lang.Object implements ObjectPool<T>
ObjectPool
.
Optional operations are implemented to either do nothing, return a value
indicating it is unsupported or throw UnsupportedOperationException
.Constructor | Description |
---|---|
BaseObjectPool() |
Modifier and Type | Method | Description |
---|---|---|
void |
addObject() |
Not supported in this base implementation.
|
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.
|
public void addObject() throws java.lang.Exception, java.lang.UnsupportedOperationException
UnsupportedOperationException
,
subclasses should override this behavior.addObject
in interface ObjectPool<T>
java.lang.UnsupportedOperationException
java.lang.Exception
- when PoolableObjectFactory.makeObject()
fails.java.lang.IllegalStateException
- after ObjectPool.close()
has been called on this pool.public abstract T borrowObject() throws java.lang.Exception
borrowObject
in interface ObjectPool<T>
java.lang.Exception
- if an instance cannot be obtained from the poolpublic void clear() throws java.lang.Exception, java.lang.UnsupportedOperationException
clear
in interface ObjectPool<T>
java.lang.UnsupportedOperationException
java.lang.Exception
public void close() throws java.lang.Exception
isClosed
and assertOpen
.close
in interface ObjectPool<T>
java.lang.Exception
- deprecated: implementations should silently fail if not all resources can be freed.public int getNumActive() throws java.lang.UnsupportedOperationException
getNumActive
in interface ObjectPool<T>
java.lang.UnsupportedOperationException
public int getNumIdle() throws java.lang.UnsupportedOperationException
getNumIdle
in interface ObjectPool<T>
java.lang.UnsupportedOperationException
public abstract void invalidateObject(T 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<T>
obj
- a borrowed
instance to be disposed.java.lang.Exception
public final boolean isClosed()
true
when this pool has been closed.public abstract void returnObject(T obj) throws java.lang.Exception
returnObject
in interface ObjectPool<T>
obj
- instance to return to the pooljava.lang.Exception
Copyright © 2001-2012 Apache Software Foundation. Documenation generated September 14 2017.