Interface KeyedObjectPool<K,V>

Type Parameters:
K - The type of keys maintained by this pool.
V - Type of element pooled in this pool.
All Superinterfaces:
AutoCloseable, Closeable
All Known Implementing Classes:
GenericKeyedObjectPool

public interface KeyedObjectPool<K,V> extends Closeable
A "keyed" pooling interface.

A keyed pool maintains a pool of instances for each key value.

Example of use:

 Object obj = null;
 Object key = "Key";

 try {
     obj = pool.borrowObject(key);
     //...use the object...
 } catch (Exception e) {
     // invalidate the object
     pool.invalidateObject(key, obj);
     // do not return the object to the pool twice
     obj = null;
 } finally {
     // make sure the object is returned to the pool
     if (null != obj) {
         pool.returnObject(key, obj);
     }
 }

KeyedObjectPool implementations may choose to store at most one instance per key value, or may choose to maintain a pool of instances for each key (essentially creating a Map of pools).

See GenericKeyedObjectPool for an implementation.

Since:
2.0
See Also: