Package com.complexible.common.pool
Class PoolConfig<T,E extends java.lang.Exception>
- java.lang.Object
-
- com.complexible.common.pool.PoolConfig<T,E>
-
- Direct Known Subclasses:
ApachePoolConfig
,ConnectionPoolConfig
public abstract class PoolConfig<T,E extends java.lang.Exception> extends java.lang.Object
Abstract configuration for a
Pool
- Since:
- 0.5.1
- Version:
- 0.7
- Author:
- Michael Grove
-
-
Constructor Summary
Constructors Modifier Constructor Description protected
PoolConfig()
-
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description PoolConfig<T,E>
blockAtCapacity(long theTime, java.util.concurrent.TimeUnit theUnit)
Set the amount of time to wait to obtain an object.abstract Pool<T,E>
create()
Create the PoolPoolConfig<T,E>
expiration(long theTime, java.util.concurrent.TimeUnit theUnit)
Specifes the minimum amount of time something should remain idle for before it is eligible to be expired.PoolConfig<T,E>
failAtCapacity()
Configure the pool to fail to obtain an object if you are atmaxPool(int)
objects.PoolConfig<T,E>
growAtCapacity()
Configure the pool to grow if it is atmaxPool(int)
objects, effectively rendering the max moot.PoolConfig<T,E>
maxIdle(int theMaxIdle)
The maximum number of objects which are allowed to sit idle in the pool.PoolConfig<T,E>
maxPool(int theMax)
Set the maximum number of objects that can be active in the pool (leased or idle).PoolConfig<T,E>
minPool(int theMin)
Set the minimum size of the pool, ie, the number of objects to start with.PoolConfig<T,E>
noExpiration()
Set that entries should not timeout/expire while idle
-
-
-
Method Detail
-
maxIdle
public PoolConfig<T,E> maxIdle(int theMaxIdle)
The maximum number of objects which are allowed to sit idle in the pool. The default is -1, which means there is no limit of idle objects.- Parameters:
theMaxIdle
- the max idle- Returns:
- this object
-
maxPool
public PoolConfig<T,E> maxPool(int theMax)
Set the maximum number of objects that can be active in the pool (leased or idle). The default is 1000- Parameters:
theMax
- the max- Returns:
- this object
-
minPool
public PoolConfig<T,E> minPool(int theMin)
Set the minimum size of the pool, ie, the number of objects to start with. Default is 0.- Parameters:
theMin
- the min pool size- Returns:
- this object
-
growAtCapacity
public PoolConfig<T,E> growAtCapacity()
Configure the pool to grow if it is atmaxPool(int)
objects, effectively rendering the max moot.- Returns:
- this object
-
failAtCapacity
public PoolConfig<T,E> failAtCapacity()
Configure the pool to fail to obtain an object if you are atmaxPool(int)
objects.- Returns:
- this object
-
blockAtCapacity
public PoolConfig<T,E> blockAtCapacity(long theTime, java.util.concurrent.TimeUnit theUnit)
Set the amount of time to wait to obtain an object. This will havePool.obtain()
block the specified amount of time until an object can be obtained. If the max is reached, obtain will return null. The default is that it will block indefinitely (-1 value for theTime).- Parameters:
theTime
- the time to waittheUnit
- the unit of time- Returns:
- this object
-
noExpiration
public PoolConfig<T,E> noExpiration()
Set that entries should not timeout/expire while idle- Returns:
- this object
-
expiration
public PoolConfig<T,E> expiration(long theTime, java.util.concurrent.TimeUnit theUnit)
Specifes the minimum amount of time something should remain idle for before it is eligible to be expired. The default is 30 minutes- Parameters:
theTime
- the amount of timetheUnit
- the unit of time- Returns:
- this configuration
-
-