Package org.apache.commons.pool
Class PoolUtils.KeyedPoolableObjectFactoryAdaptor<K,V>
- java.lang.Object
-
- org.apache.commons.pool.PoolUtils.KeyedPoolableObjectFactoryAdaptor<K,V>
-
- All Implemented Interfaces:
KeyedPoolableObjectFactory<K,V>
- Enclosing class:
- PoolUtils
private static class PoolUtils.KeyedPoolableObjectFactoryAdaptor<K,V> extends java.lang.Object implements KeyedPoolableObjectFactory<K,V>
Adaptor class that turns a PoolableObjectFactory into a KeyedPoolableObjectFactory by ignoring keys.
-
-
Field Summary
Fields Modifier and Type Field Description private PoolableObjectFactory<V>
factory
Underlying PoolableObjectFactory
-
Constructor Summary
Constructors Constructor Description KeyedPoolableObjectFactoryAdaptor(PoolableObjectFactory<V> factory)
Create a new KeyedPoolableObjectFactoryAdaptor using the given PoolableObjectFactory to manage objects.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
activateObject(K key, V obj)
Activate the object, ignoring the key.void
destroyObject(K key, V obj)
Destroy the object, ignoring the key.V
makeObject(K key)
Create a new object instance, ignoring the keyvoid
passivateObject(K key, V obj)
Passivate the object, ignoring the key.java.lang.String
toString()
boolean
validateObject(K key, V obj)
Validate the object, ignoring the key
-
-
-
Field Detail
-
factory
private final PoolableObjectFactory<V> factory
Underlying PoolableObjectFactory
-
-
Constructor Detail
-
KeyedPoolableObjectFactoryAdaptor
KeyedPoolableObjectFactoryAdaptor(PoolableObjectFactory<V> factory) throws java.lang.IllegalArgumentException
Create a new KeyedPoolableObjectFactoryAdaptor using the given PoolableObjectFactory to manage objects.- Parameters:
factory
- wrapped PoolableObjectFactory- Throws:
java.lang.IllegalArgumentException
- if the factory is null
-
-
Method Detail
-
makeObject
public V makeObject(K key) throws java.lang.Exception
Create a new object instance, ignoring the key- Specified by:
makeObject
in interfaceKeyedPoolableObjectFactory<K,V>
- Parameters:
key
- ignored- Returns:
- newly created object instance
- Throws:
java.lang.Exception
- if there is a problem creating a new instance, this will be propagated to the code requesting an object.
-
destroyObject
public void destroyObject(K key, V obj) throws java.lang.Exception
Destroy the object, ignoring the key.- Specified by:
destroyObject
in interfaceKeyedPoolableObjectFactory<K,V>
- Parameters:
key
- ignoredobj
- instance to destroy- Throws:
java.lang.Exception
- should be avoided as it may be swallowed by the pool implementation.- See Also:
KeyedPoolableObjectFactory.validateObject(K, V)
,KeyedObjectPool.invalidateObject(K, V)
-
validateObject
public boolean validateObject(K key, V obj)
Validate the object, ignoring the key- Specified by:
validateObject
in interfaceKeyedPoolableObjectFactory<K,V>
- Parameters:
key
- ignoredobj
- object to validate- Returns:
- true if validation is successful
-
activateObject
public void activateObject(K key, V obj) throws java.lang.Exception
Activate the object, ignoring the key.- Specified by:
activateObject
in interfaceKeyedPoolableObjectFactory<K,V>
- Parameters:
key
- ignoredobj
- object to be activated- Throws:
java.lang.Exception
- if there is a problem activatingobj
, this exception may be swallowed by the pool.- See Also:
KeyedPoolableObjectFactory.destroyObject(K, V)
-
passivateObject
public void passivateObject(K key, V obj) throws java.lang.Exception
Passivate the object, ignoring the key.- Specified by:
passivateObject
in interfaceKeyedPoolableObjectFactory<K,V>
- Parameters:
key
- ignoredobj
- object to passivate- Throws:
java.lang.Exception
- if there is a problem passivatingobj
, this exception may be swallowed by the pool.- See Also:
KeyedPoolableObjectFactory.destroyObject(K, V)
-
toString
public java.lang.String toString()
- Overrides:
toString
in classjava.lang.Object
-
-