K - the type of the key to the resourceV - the type of the resource being pooled@InterfaceAudience.Private public class PoolMap<K,V> extends Object
PoolMap maps a key to a collection of values, the elements
 of which are managed by a pool. In effect, that collection acts as a shared
 pool of resources, access to which is closely controlled as per the semantics
 of the pool.
 
 In case the size of the pool is set to a non-zero positive number, that is
 used to cap the number of resources that a pool may contain for any given
 key. A size of Integer.MAX_VALUE is interpreted as an unbounded pool.
 
PoolMap is thread-safe. It does not remove elements automatically. Unused resources must be closed and removed explicitly.
| Modifier and Type | Class and Description | 
|---|---|
protected static interface  | 
PoolMap.Pool<R>  | 
static interface  | 
PoolMap.PoolResourceSupplier<R>  | 
static class  | 
PoolMap.PoolType  | 
| Constructor and Description | 
|---|
PoolMap(PoolMap.PoolType poolType,
       int poolMaxSize)  | 
| Modifier and Type | Method and Description | 
|---|---|
void | 
clear()  | 
protected PoolMap.Pool<V> | 
createPool()  | 
protected static <V> V | 
createResource(PoolMap.PoolResourceSupplier<V> supplier)  | 
V | 
getOrCreate(K key,
           PoolMap.PoolResourceSupplier<V> supplier)  | 
boolean | 
remove(K key,
      V value)  | 
List<V> | 
values()  | 
public PoolMap(PoolMap.PoolType poolType, int poolMaxSize)
public V getOrCreate(K key, PoolMap.PoolResourceSupplier<V> supplier) throws IOException
IOExceptionpublic void clear()
protected static <V> V createResource(PoolMap.PoolResourceSupplier<V> supplier) throws IOException
IOExceptionprotected PoolMap.Pool<V> createPool()
Copyright © 2007–2022 The Apache Software Foundation. All rights reserved.