|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.apache.commons.pool2.BaseKeyedPooledObjectFactory<K,V>
K
- The type of keys managed by this factory.V
- Type of element managed by this factory.public abstract class BaseKeyedPooledObjectFactory<K,V>
A base implementation of KeyedPooledObjectFactory
.
All operations defined here are essentially no-op's.
This class is immutable, and therefore thread-safe.
KeyedPooledObjectFactory
Constructor Summary | |
---|---|
BaseKeyedPooledObjectFactory()
|
Method Summary | |
---|---|
void |
activateObject(K key,
PooledObject<V> p)
Reinitialize an instance to be returned by the pool. |
abstract V |
create(K key)
Create an instance that can be served by the pool. |
void |
destroyObject(K key,
PooledObject<V> p)
Destroy an instance no longer needed by the pool. |
PooledObject<V> |
makeObject(K key)
Create an instance that can be served by the pool and wrap it in a PooledObject to be managed by the pool. |
void |
passivateObject(K key,
PooledObject<V> p)
Uninitialize an instance to be returned to the idle object pool. |
boolean |
validateObject(K key,
PooledObject<V> p)
Ensures that the instance is safe to be returned by the pool. |
abstract PooledObject<V> |
wrap(V value)
Wrap the provided instance with an implementation of PooledObject . |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public BaseKeyedPooledObjectFactory()
Method Detail |
---|
public abstract V create(K key) throws Exception
key
- the key used when constructing the object
Exception
public abstract PooledObject<V> wrap(V value)
PooledObject
.
value
- the instance to wrap
PooledObject
public PooledObject<V> makeObject(K key) throws Exception
KeyedPooledObjectFactory
PooledObject
to be managed by the pool.
makeObject
in interface KeyedPooledObjectFactory<K,V>
key
- the key used when constructing the object
PooledObject
wrapping an instance that can
be served by the pool.
Exception
- if there is a problem creating a new instance,
this will be propagated to the code requesting an object.public void destroyObject(K key, PooledObject<V> p) throws Exception
The default implementation is a no-op.
destroyObject
in interface KeyedPooledObjectFactory<K,V>
key
- the key used when selecting the instancep
- a PooledObject
wrapping the the instance to be destroyed
Exception
- should be avoided as it may be swallowed by
the pool implementation.KeyedPooledObjectFactory.validateObject(K, org.apache.commons.pool2.PooledObject)
,
KeyedObjectPool.invalidateObject(K, V)
public boolean validateObject(K key, PooledObject<V> p)
The default implementation always returns true.
validateObject
in interface KeyedPooledObjectFactory<K,V>
key
- the key used when selecting the objectp
- a PooledObject
wrapping the the instance to be validated
true
in the default implementationpublic void activateObject(K key, PooledObject<V> p) throws Exception
The default implementation is a no-op.
activateObject
in interface KeyedPooledObjectFactory<K,V>
key
- the key used when selecting the objectp
- a PooledObject
wrapping the the instance to be activated
Exception
- if there is a problem activating obj
,
this exception may be swallowed by the pool.KeyedPooledObjectFactory.destroyObject(K, org.apache.commons.pool2.PooledObject)
public void passivateObject(K key, PooledObject<V> p) throws Exception
The default implementation is a no-op.
passivateObject
in interface KeyedPooledObjectFactory<K,V>
key
- the key used when selecting the objectp
- a PooledObject
wrapping the the instance to be passivated
Exception
- if there is a problem passivating obj
,
this exception may be swallowed by the pool.KeyedPooledObjectFactory.destroyObject(K, org.apache.commons.pool2.PooledObject)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |