Class PoolUtils.SynchronizedKeyedObjectPool<K,V>

java.lang.Object
org.apache.commons.pool.PoolUtils.SynchronizedKeyedObjectPool<K,V>
All Implemented Interfaces:
KeyedObjectPool<K,V>
Enclosing class:
PoolUtils

private static class PoolUtils.SynchronizedKeyedObjectPool<K,V> extends Object implements KeyedObjectPool<K,V>
A synchronized (thread-safe) KeyedObjectPool backed by the specified KeyedObjectPool.

Note: This should not be used on pool implementations that already provide proper synchronization such as the pools provided in the Commons Pool library. Wrapping a pool that waits for poolable objects to be returned before allowing another one to be borrowed with another layer of synchronization will cause liveliness issues or a deadlock.

  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    private final KeyedObjectPool<K,V>
    Underlying object pool
    private final Object
    Object whose monitor is used to synchronize methods on the wrapped pool.
  • Constructor Summary

    Constructors
    Constructor
    Description
    Create a new SynchronizedKeyedObjectPool wrapping the given pool
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    addObject(K key)
    Create an object using the factory or other implementation dependent mechanism, passivate it, and then place it in the idle object pool.
    Obtains an instance from this pool for the specified key.
    void
    Clears the pool, removing all pooled instances (optional operation).
    void
    clear(K key)
    Clears the specified pool, removing all pooled instances corresponding to the given key (optional operation).
    void
    Close this pool, and free any resources associated with it.
    int
    Returns the total number of instances current borrowed from this pool but not yet returned (optional operation).
    int
    Returns the number of instances currently borrowed from but not yet returned to the pool corresponding to the given key (optional operation).
    int
    Returns the total number of instances currently idle in this pool (optional operation).
    int
    Returns the number of instances corresponding to the given key currently idle in this pool (optional operation).
    void
    invalidateObject(K key, V obj)
    Invalidates an object from the pool.
    void
    returnObject(K key, V obj)
    Return an instance to the pool.
    void
    Deprecated.
    to be removed in pool 2.0

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait