org.apache.commons.pool.impl

Class GenericObjectPool

public class GenericObjectPool extends BaseObjectPool implements ObjectPool

A configurable ObjectPool implementation.

When coupled with the appropriate PoolableObjectFactory, GenericObjectPool provides robust pooling functionality for arbitrary objects.

A GenericObjectPool provides a number of configurable parameters:

Optionally, one may configure the pool to examine and possibly evict objects as they sit idle in the pool. This is performed by an "idle object eviction" thread, which runs asychronously. The idle object eviction thread may be configured using the following attributes:

GenericObjectPool is not usable without a PoolableObjectFactory. A non-null factory must be provided either as a constructor argument or via a call to GenericObjectPool before the pool is used.

Version: $Revision: 390563 $ $Date: 2006-03-31 20:28:14 -0500 (Fri, 31 Mar 2006) $

Author: Rodney Waldhoff Dirk Verbeeck

See Also: GenericKeyedObjectPool

Nested Class Summary
static classGenericObjectPool.Config
A simple "struct" encapsulating the configuration information for a GenericObjectPool.
Field Summary
static intDEFAULT_MAX_ACTIVE
The default cap on the total number of active instances from the pool.
static intDEFAULT_MAX_IDLE
The default cap on the number of "sleeping" instances in the pool.
static longDEFAULT_MAX_WAIT
The default maximum amount of time (in millis) the GenericObjectPool method should block before throwing an exception when the pool is exhausted and the "when exhausted" action is WHEN_EXHAUSTED_BLOCK.
static longDEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
The default value for GenericObjectPool.
static intDEFAULT_MIN_IDLE
The default minimum number of "sleeping" instances in the pool before before the evictor thread (if active) spawns new objects.
static intDEFAULT_NUM_TESTS_PER_EVICTION_RUN
The default number of objects to examine per run in the idle object evictor.
static longDEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS
The default value for GenericObjectPool.
static booleanDEFAULT_TEST_ON_BORROW
The default "test on borrow" value.
static booleanDEFAULT_TEST_ON_RETURN
The default "test on return" value.
static booleanDEFAULT_TEST_WHILE_IDLE
The default "test while idle" value.
static longDEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
The default "time between eviction runs" value.
static byteDEFAULT_WHEN_EXHAUSTED_ACTION
The default "when exhausted action" for the pool.
static byteWHEN_EXHAUSTED_BLOCK
A "when exhausted action" type indicating that when the pool is exhausted (i.e., the maximum number of active objects has been reached), the GenericObjectPool method should block until a new object is available, or the maximum wait time has been reached.
static byteWHEN_EXHAUSTED_FAIL
A "when exhausted action" type indicating that when the pool is exhausted (i.e., the maximum number of active objects has been reached), the GenericObjectPool method should fail, throwing a NoSuchElementException.
static byteWHEN_EXHAUSTED_GROW
A "when exhausted action" type indicating that when the pool is exhausted (i.e., the maximum number of active objects has been reached), the GenericObjectPool method should simply create a new object anyway.
Constructor Summary
GenericObjectPool()
Create a new GenericObjectPool.
GenericObjectPool(PoolableObjectFactory factory)
Create a new GenericObjectPool using the specified values.
GenericObjectPool(PoolableObjectFactory factory, GenericObjectPool.Config config)
Create a new GenericObjectPool using the specified values.
GenericObjectPool(PoolableObjectFactory factory, int maxActive)
Create a new GenericObjectPool using the specified values.
GenericObjectPool(PoolableObjectFactory factory, int maxActive, byte whenExhaustedAction, long maxWait)
Create a new GenericObjectPool using the specified values.
GenericObjectPool(PoolableObjectFactory factory, int maxActive, byte whenExhaustedAction, long maxWait, boolean testOnBorrow, boolean testOnReturn)
Create a new GenericObjectPool using the specified values.
GenericObjectPool(PoolableObjectFactory factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle)
Create a new GenericObjectPool using the specified values.
GenericObjectPool(PoolableObjectFactory factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, boolean testOnBorrow, boolean testOnReturn)
Create a new GenericObjectPool using the specified values.
GenericObjectPool(PoolableObjectFactory factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, boolean testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle)
Create a new GenericObjectPool using the specified values.
GenericObjectPool(PoolableObjectFactory factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, int minIdle, boolean testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle)
Create a new GenericObjectPool using the specified values.
GenericObjectPool(PoolableObjectFactory factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, int minIdle, boolean testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle, long softMinEvictableIdleTimeMillis)
Create a new GenericObjectPool using the specified values.
Method Summary
voidaddObject()
Create an object, and place it into the pool. addObject() is useful for "pre-loading" a pool with idle objects.
ObjectborrowObject()
voidclear()
voidclose()
voidevict()
intgetMaxActive()
Returns the cap on the total number of active instances from my pool.
intgetMaxIdle()
Returns the cap on the number of "idle" instances in the pool.
longgetMaxWait()
Returns the maximum amount of time (in milliseconds) the GenericObjectPool method should block before throwing an exception when the pool is exhausted and the "when exhausted" action is WHEN_EXHAUSTED_BLOCK.
longgetMinEvictableIdleTimeMillis()
Returns the minimum amount of time an object may sit idle in the pool before it is eligable for eviction by the idle object evictor (if any).
intgetMinIdle()
Returns the minimum number of objects allowed in the pool before the evictor thread (if active) spawns new objects.
intgetNumActive()
intgetNumIdle()
intgetNumTestsPerEvictionRun()
Returns the max number of objects to examine during each run of the idle object evictor thread (if any).
longgetSoftMinEvictableIdleTimeMillis()
Returns the minimum amount of time an object may sit idle in the pool before it is eligable for eviction by the idle object evictor (if any), with the extra condition that at least "minIdle" amount of object remain in the pool.
booleangetTestOnBorrow()
When true, objects will be validated before being returned by the GenericObjectPool method.
booleangetTestOnReturn()
When true, objects will be validated before being returned to the pool within the GenericObjectPool.
booleangetTestWhileIdle()
When true, objects will be validated by the idle object evictor (if any).
longgetTimeBetweenEvictionRunsMillis()
Returns the number of milliseconds to sleep between runs of the idle object evictor thread.
bytegetWhenExhaustedAction()
Returns the action to take when the GenericObjectPool method is invoked when the pool is exhausted (the maximum number of "active" objects has been reached).
voidinvalidateObject(Object obj)
voidreturnObject(Object obj)
voidsetConfig(GenericObjectPool.Config conf)
Sets my configuration.
voidsetFactory(PoolableObjectFactory factory)
voidsetMaxActive(int maxActive)
Sets the cap on the total number of active instances from my pool.
voidsetMaxIdle(int maxIdle)
Sets the cap on the number of "idle" instances in the pool.
voidsetMaxWait(long maxWait)
Sets the maximum amount of time (in milliseconds) the GenericObjectPool method should block before throwing an exception when the pool is exhausted and the "when exhausted" action is WHEN_EXHAUSTED_BLOCK.
voidsetMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)
Sets the minimum amount of time an object may sit idle in the pool before it is eligable for eviction by the idle object evictor (if any).
voidsetMinIdle(int minIdle)
Sets the minimum number of objects allowed in the pool before the evictor thread (if active) spawns new objects.
voidsetNumTestsPerEvictionRun(int numTestsPerEvictionRun)
Sets the max number of objects to examine during each run of the idle object evictor thread (if any).
voidsetSoftMinEvictableIdleTimeMillis(long softMinEvictableIdleTimeMillis)
Sets the minimum amount of time an object may sit idle in the pool before it is eligable for eviction by the idle object evictor (if any), with the extra condition that at least "minIdle" amount of object remain in the pool.
voidsetTestOnBorrow(boolean testOnBorrow)
When true, objects will be validated before being returned by the GenericObjectPool method.
voidsetTestOnReturn(boolean testOnReturn)
When true, objects will be validated before being returned to the pool within the GenericObjectPool.
voidsetTestWhileIdle(boolean testWhileIdle)
When true, objects will be validated by the idle object evictor (if any).
voidsetTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)
Sets the number of milliseconds to sleep between runs of the idle object evictor thread.
voidsetWhenExhaustedAction(byte whenExhaustedAction)
Sets the action to take when the GenericObjectPool method is invoked when the pool is exhausted (the maximum number of "active" objects has been reached).

Field Detail

DEFAULT_MAX_ACTIVE

public static final int DEFAULT_MAX_ACTIVE
The default cap on the total number of active instances from the pool.

See Also: GenericObjectPool

DEFAULT_MAX_IDLE

public static final int DEFAULT_MAX_IDLE
The default cap on the number of "sleeping" instances in the pool.

See Also: GenericObjectPool GenericObjectPool

DEFAULT_MAX_WAIT

public static final long DEFAULT_MAX_WAIT
The default maximum amount of time (in millis) the GenericObjectPool method should block before throwing an exception when the pool is exhausted and the "when exhausted" action is WHEN_EXHAUSTED_BLOCK.

See Also: GenericObjectPool GenericObjectPool

DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS

public static final long DEFAULT_MIN_EVICTABLE_IDLE_TIME_MILLIS
The default value for GenericObjectPool.

See Also: GenericObjectPool GenericObjectPool

DEFAULT_MIN_IDLE

public static final int DEFAULT_MIN_IDLE
The default minimum number of "sleeping" instances in the pool before before the evictor thread (if active) spawns new objects.

See Also: GenericObjectPool GenericObjectPool

DEFAULT_NUM_TESTS_PER_EVICTION_RUN

public static final int DEFAULT_NUM_TESTS_PER_EVICTION_RUN
The default number of objects to examine per run in the idle object evictor.

See Also: GenericObjectPool GenericObjectPool GenericObjectPool GenericObjectPool

DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS

public static final long DEFAULT_SOFT_MIN_EVICTABLE_IDLE_TIME_MILLIS
The default value for GenericObjectPool.

See Also: GenericObjectPool GenericObjectPool

DEFAULT_TEST_ON_BORROW

public static final boolean DEFAULT_TEST_ON_BORROW
The default "test on borrow" value.

See Also: GenericObjectPool GenericObjectPool

DEFAULT_TEST_ON_RETURN

public static final boolean DEFAULT_TEST_ON_RETURN
The default "test on return" value.

See Also: GenericObjectPool GenericObjectPool

DEFAULT_TEST_WHILE_IDLE

public static final boolean DEFAULT_TEST_WHILE_IDLE
The default "test while idle" value.

See Also: GenericObjectPool GenericObjectPool GenericObjectPool GenericObjectPool

DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS

public static final long DEFAULT_TIME_BETWEEN_EVICTION_RUNS_MILLIS
The default "time between eviction runs" value.

See Also: GenericObjectPool GenericObjectPool

DEFAULT_WHEN_EXHAUSTED_ACTION

public static final byte DEFAULT_WHEN_EXHAUSTED_ACTION
The default "when exhausted action" for the pool.

See Also: WHEN_EXHAUSTED_BLOCK WHEN_EXHAUSTED_FAIL WHEN_EXHAUSTED_GROW GenericObjectPool

WHEN_EXHAUSTED_BLOCK

public static final byte WHEN_EXHAUSTED_BLOCK
A "when exhausted action" type indicating that when the pool is exhausted (i.e., the maximum number of active objects has been reached), the GenericObjectPool method should block until a new object is available, or the maximum wait time has been reached.

See Also: WHEN_EXHAUSTED_FAIL WHEN_EXHAUSTED_GROW GenericObjectPool GenericObjectPool GenericObjectPool

WHEN_EXHAUSTED_FAIL

public static final byte WHEN_EXHAUSTED_FAIL
A "when exhausted action" type indicating that when the pool is exhausted (i.e., the maximum number of active objects has been reached), the GenericObjectPool method should fail, throwing a NoSuchElementException.

See Also: WHEN_EXHAUSTED_BLOCK WHEN_EXHAUSTED_GROW GenericObjectPool

WHEN_EXHAUSTED_GROW

public static final byte WHEN_EXHAUSTED_GROW
A "when exhausted action" type indicating that when the pool is exhausted (i.e., the maximum number of active objects has been reached), the GenericObjectPool method should simply create a new object anyway.

See Also: WHEN_EXHAUSTED_FAIL WHEN_EXHAUSTED_GROW GenericObjectPool

Constructor Detail

GenericObjectPool

public GenericObjectPool()
Create a new GenericObjectPool.

GenericObjectPool

public GenericObjectPool(PoolableObjectFactory factory)
Create a new GenericObjectPool using the specified values.

Parameters: factory the (possibly null)PoolableObjectFactory to use to create, validate and destroy objects

GenericObjectPool

public GenericObjectPool(PoolableObjectFactory factory, GenericObjectPool.Config config)
Create a new GenericObjectPool using the specified values.

Parameters: factory the (possibly null)PoolableObjectFactory to use to create, validate and destroy objects config a non-null Config describing my configuration

GenericObjectPool

public GenericObjectPool(PoolableObjectFactory factory, int maxActive)
Create a new GenericObjectPool using the specified values.

Parameters: factory the (possibly null)PoolableObjectFactory to use to create, validate and destroy objects maxActive the maximum number of objects that can be borrowed from me at one time (see GenericObjectPool)

GenericObjectPool

public GenericObjectPool(PoolableObjectFactory factory, int maxActive, byte whenExhaustedAction, long maxWait)
Create a new GenericObjectPool using the specified values.

Parameters: factory the (possibly null)PoolableObjectFactory to use to create, validate and destroy objects maxActive the maximum number of objects that can be borrowed from me at one time (see GenericObjectPool) whenExhaustedAction the action to take when the pool is exhausted (see GenericObjectPool) maxWait the maximum amount of time to wait for an idle object when the pool is exhausted an and whenExhaustedAction is WHEN_EXHAUSTED_BLOCK (otherwise ignored) (see GenericObjectPool)

GenericObjectPool

public GenericObjectPool(PoolableObjectFactory factory, int maxActive, byte whenExhaustedAction, long maxWait, boolean testOnBorrow, boolean testOnReturn)
Create a new GenericObjectPool using the specified values.

Parameters: factory the (possibly null)PoolableObjectFactory to use to create, validate and destroy objects maxActive the maximum number of objects that can be borrowed from me at one time (see GenericObjectPool) whenExhaustedAction the action to take when the pool is exhausted (see GenericObjectPool) maxWait the maximum amount of time to wait for an idle object when the pool is exhausted an and whenExhaustedAction is WHEN_EXHAUSTED_BLOCK (otherwise ignored) (see GenericObjectPool) testOnBorrow whether or not to validate objects before they are returned by the GenericObjectPool method (see GenericObjectPool) testOnReturn whether or not to validate objects after they are returned to the GenericObjectPool method (see GenericObjectPool)

GenericObjectPool

public GenericObjectPool(PoolableObjectFactory factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle)
Create a new GenericObjectPool using the specified values.

Parameters: factory the (possibly null)PoolableObjectFactory to use to create, validate and destroy objects maxActive the maximum number of objects that can be borrowed from me at one time (see GenericObjectPool) whenExhaustedAction the action to take when the pool is exhausted (see GenericObjectPool) maxWait the maximum amount of time to wait for an idle object when the pool is exhausted an and whenExhaustedAction is WHEN_EXHAUSTED_BLOCK (otherwise ignored) (see GenericObjectPool) maxIdle the maximum number of idle objects in my pool (see GenericObjectPool)

GenericObjectPool

public GenericObjectPool(PoolableObjectFactory factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, boolean testOnBorrow, boolean testOnReturn)
Create a new GenericObjectPool using the specified values.

Parameters: factory the (possibly null)PoolableObjectFactory to use to create, validate and destroy objects maxActive the maximum number of objects that can be borrowed from me at one time (see GenericObjectPool) whenExhaustedAction the action to take when the pool is exhausted (see GenericObjectPool) maxWait the maximum amount of time to wait for an idle object when the pool is exhausted an and whenExhaustedAction is WHEN_EXHAUSTED_BLOCK (otherwise ignored) (see GenericObjectPool) maxIdle the maximum number of idle objects in my pool (see GenericObjectPool) testOnBorrow whether or not to validate objects before they are returned by the GenericObjectPool method (see GenericObjectPool) testOnReturn whether or not to validate objects after they are returned to the GenericObjectPool method (see GenericObjectPool)

GenericObjectPool

public GenericObjectPool(PoolableObjectFactory factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, boolean testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle)
Create a new GenericObjectPool using the specified values.

Parameters: factory the (possibly null)PoolableObjectFactory to use to create, validate and destroy objects maxActive the maximum number of objects that can be borrowed from me at one time (see GenericObjectPool) whenExhaustedAction the action to take when the pool is exhausted (see GenericObjectPool) maxWait the maximum amount of time to wait for an idle object when the pool is exhausted an and whenExhaustedAction is WHEN_EXHAUSTED_BLOCK (otherwise ignored) (see GenericObjectPool) maxIdle the maximum number of idle objects in my pool (see GenericObjectPool) testOnBorrow whether or not to validate objects before they are returned by the GenericObjectPool method (see GenericObjectPool) testOnReturn whether or not to validate objects after they are returned to the GenericObjectPool method (see GenericObjectPool) timeBetweenEvictionRunsMillis the amount of time (in milliseconds) to sleep between examining idle objects for eviction (see GenericObjectPool) numTestsPerEvictionRun the number of idle objects to examine per run within the idle object eviction thread (if any) (see GenericObjectPool) minEvictableIdleTimeMillis the minimum number of milliseconds an object can sit idle in the pool before it is eligable for evcition (see GenericObjectPool) testWhileIdle whether or not to validate objects in the idle object eviction thread, if any (see GenericObjectPool)

GenericObjectPool

public GenericObjectPool(PoolableObjectFactory factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, int minIdle, boolean testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle)
Create a new GenericObjectPool using the specified values.

Parameters: factory the (possibly null)PoolableObjectFactory to use to create, validate and destroy objects maxActive the maximum number of objects that can be borrowed from me at one time (see GenericObjectPool) whenExhaustedAction the action to take when the pool is exhausted (see GenericObjectPool) maxWait the maximum amount of time to wait for an idle object when the pool is exhausted an and whenExhaustedAction is WHEN_EXHAUSTED_BLOCK (otherwise ignored) (see GenericObjectPool) maxIdle the maximum number of idle objects in my pool (see GenericObjectPool) minIdle the minimum number of idle objects in my pool (see GenericObjectPool) testOnBorrow whether or not to validate objects before they are returned by the GenericObjectPool method (see GenericObjectPool) testOnReturn whether or not to validate objects after they are returned to the GenericObjectPool method (see GenericObjectPool) timeBetweenEvictionRunsMillis the amount of time (in milliseconds) to sleep between examining idle objects for eviction (see GenericObjectPool) numTestsPerEvictionRun the number of idle objects to examine per run within the idle object eviction thread (if any) (see GenericObjectPool) minEvictableIdleTimeMillis the minimum number of milliseconds an object can sit idle in the pool before it is eligable for evcition (see GenericObjectPool) testWhileIdle whether or not to validate objects in the idle object eviction thread, if any (see GenericObjectPool)

GenericObjectPool

public GenericObjectPool(PoolableObjectFactory factory, int maxActive, byte whenExhaustedAction, long maxWait, int maxIdle, int minIdle, boolean testOnBorrow, boolean testOnReturn, long timeBetweenEvictionRunsMillis, int numTestsPerEvictionRun, long minEvictableIdleTimeMillis, boolean testWhileIdle, long softMinEvictableIdleTimeMillis)
Create a new GenericObjectPool using the specified values.

Parameters: factory the (possibly null)PoolableObjectFactory to use to create, validate and destroy objects maxActive the maximum number of objects that can be borrowed from me at one time (see GenericObjectPool) whenExhaustedAction the action to take when the pool is exhausted (see GenericObjectPool) maxWait the maximum amount of time to wait for an idle object when the pool is exhausted an and whenExhaustedAction is WHEN_EXHAUSTED_BLOCK (otherwise ignored) (see GenericObjectPool) maxIdle the maximum number of idle objects in my pool (see GenericObjectPool) minIdle the minimum number of idle objects in my pool (see GenericObjectPool) testOnBorrow whether or not to validate objects before they are returned by the GenericObjectPool method (see GenericObjectPool) testOnReturn whether or not to validate objects after they are returned to the GenericObjectPool method (see GenericObjectPool) timeBetweenEvictionRunsMillis the amount of time (in milliseconds) to sleep between examining idle objects for eviction (see GenericObjectPool) numTestsPerEvictionRun the number of idle objects to examine per run within the idle object eviction thread (if any) (see GenericObjectPool) minEvictableIdleTimeMillis the minimum number of milliseconds an object can sit idle in the pool before it is eligable for evcition (see GenericObjectPool) testWhileIdle whether or not to validate objects in the idle object eviction thread, if any (see GenericObjectPool) softMinEvictableIdleTimeMillis the minimum number of milliseconds an object can sit idle in the pool before it is eligable for evcition with the extra condition that at least "minIdle" amount of object remain in the pool. (see GenericObjectPool)

Method Detail

addObject

public void addObject()
Create an object, and place it into the pool. addObject() is useful for "pre-loading" a pool with idle objects.

borrowObject

public Object borrowObject()

clear

public void clear()

close

public void close()

evict

public void evict()

getMaxActive

public int getMaxActive()
Returns the cap on the total number of active instances from my pool.

Returns: the cap on the total number of active instances from my pool.

See Also: GenericObjectPool

getMaxIdle

public int getMaxIdle()
Returns the cap on the number of "idle" instances in the pool.

Returns: the cap on the number of "idle" instances in the pool.

See Also: GenericObjectPool

getMaxWait

public long getMaxWait()
Returns the maximum amount of time (in milliseconds) the GenericObjectPool method should block before throwing an exception when the pool is exhausted and the "when exhausted" action is WHEN_EXHAUSTED_BLOCK. When less than 0, the GenericObjectPool method may block indefinitely.

See Also: GenericObjectPool GenericObjectPool WHEN_EXHAUSTED_BLOCK

getMinEvictableIdleTimeMillis

public long getMinEvictableIdleTimeMillis()
Returns the minimum amount of time an object may sit idle in the pool before it is eligable for eviction by the idle object evictor (if any).

See Also: GenericObjectPool GenericObjectPool

getMinIdle

public int getMinIdle()
Returns the minimum number of objects allowed in the pool before the evictor thread (if active) spawns new objects. (Note no objects are created when: numActive + numIdle >= maxActive)

Returns: The minimum number of objects.

See Also: GenericObjectPool

getNumActive

public int getNumActive()

getNumIdle

public int getNumIdle()

getNumTestsPerEvictionRun

public int getNumTestsPerEvictionRun()
Returns the max number of objects to examine during each run of the idle object evictor thread (if any).

See Also: GenericObjectPool GenericObjectPool

getSoftMinEvictableIdleTimeMillis

public long getSoftMinEvictableIdleTimeMillis()
Returns the minimum amount of time an object may sit idle in the pool before it is eligable for eviction by the idle object evictor (if any), with the extra condition that at least "minIdle" amount of object remain in the pool.

See Also: GenericObjectPool

getTestOnBorrow

public boolean getTestOnBorrow()
When true, objects will be validated before being returned by the GenericObjectPool method. If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another.

See Also: GenericObjectPool

getTestOnReturn

public boolean getTestOnReturn()
When true, objects will be validated before being returned to the pool within the GenericObjectPool.

See Also: GenericObjectPool

getTestWhileIdle

public boolean getTestWhileIdle()
When true, objects will be validated by the idle object evictor (if any). If an object fails to validate, it will be dropped from the pool.

See Also: GenericObjectPool GenericObjectPool

getTimeBetweenEvictionRunsMillis

public long getTimeBetweenEvictionRunsMillis()
Returns the number of milliseconds to sleep between runs of the idle object evictor thread. When non-positive, no idle object evictor thread will be run.

See Also: GenericObjectPool

getWhenExhaustedAction

public byte getWhenExhaustedAction()
Returns the action to take when the GenericObjectPool method is invoked when the pool is exhausted (the maximum number of "active" objects has been reached).

Returns: one of WHEN_EXHAUSTED_BLOCK, WHEN_EXHAUSTED_FAIL or WHEN_EXHAUSTED_GROW

See Also: GenericObjectPool

invalidateObject

public void invalidateObject(Object obj)

returnObject

public void returnObject(Object obj)

setConfig

public void setConfig(GenericObjectPool.Config conf)
Sets my configuration.

See Also: Config

setFactory

public void setFactory(PoolableObjectFactory factory)

setMaxActive

public void setMaxActive(int maxActive)
Sets the cap on the total number of active instances from my pool.

Parameters: maxActive The cap on the total number of active instances from my pool. Use a negative value for an infinite number of instances.

See Also: GenericObjectPool

setMaxIdle

public void setMaxIdle(int maxIdle)
Sets the cap on the number of "idle" instances in the pool.

Parameters: maxIdle The cap on the number of "idle" instances in the pool. Use a negative value to indicate an unlimited number of idle instances.

See Also: GenericObjectPool

setMaxWait

public void setMaxWait(long maxWait)
Sets the maximum amount of time (in milliseconds) the GenericObjectPool method should block before throwing an exception when the pool is exhausted and the "when exhausted" action is WHEN_EXHAUSTED_BLOCK. When less than 0, the GenericObjectPool method may block indefinitely.

See Also: GenericObjectPool GenericObjectPool WHEN_EXHAUSTED_BLOCK

setMinEvictableIdleTimeMillis

public void setMinEvictableIdleTimeMillis(long minEvictableIdleTimeMillis)
Sets the minimum amount of time an object may sit idle in the pool before it is eligable for eviction by the idle object evictor (if any). When non-positive, no objects will be evicted from the pool due to idle time alone.

See Also: GenericObjectPool GenericObjectPool

setMinIdle

public void setMinIdle(int minIdle)
Sets the minimum number of objects allowed in the pool before the evictor thread (if active) spawns new objects. (Note no objects are created when: numActive + numIdle >= maxActive)

Parameters: minIdle The minimum number of objects.

See Also: GenericObjectPool

setNumTestsPerEvictionRun

public void setNumTestsPerEvictionRun(int numTestsPerEvictionRun)
Sets the max number of objects to examine during each run of the idle object evictor thread (if any).

When a negative value is supplied, ceil(GenericObjectPool)/abs(GenericObjectPool) tests will be run. I.e., when the value is -n, roughly one nth of the idle objects will be tested per run.

See Also: GenericObjectPool GenericObjectPool

setSoftMinEvictableIdleTimeMillis

public void setSoftMinEvictableIdleTimeMillis(long softMinEvictableIdleTimeMillis)
Sets the minimum amount of time an object may sit idle in the pool before it is eligable for eviction by the idle object evictor (if any), with the extra condition that at least "minIdle" amount of object remain in the pool. When non-positive, no objects will be evicted from the pool due to idle time alone.

See Also: GenericObjectPool

setTestOnBorrow

public void setTestOnBorrow(boolean testOnBorrow)
When true, objects will be validated before being returned by the GenericObjectPool method. If the object fails to validate, it will be dropped from the pool, and we will attempt to borrow another.

See Also: GenericObjectPool

setTestOnReturn

public void setTestOnReturn(boolean testOnReturn)
When true, objects will be validated before being returned to the pool within the GenericObjectPool.

See Also: GenericObjectPool

setTestWhileIdle

public void setTestWhileIdle(boolean testWhileIdle)
When true, objects will be validated by the idle object evictor (if any). If an object fails to validate, it will be dropped from the pool.

See Also: GenericObjectPool GenericObjectPool

setTimeBetweenEvictionRunsMillis

public void setTimeBetweenEvictionRunsMillis(long timeBetweenEvictionRunsMillis)
Sets the number of milliseconds to sleep between runs of the idle object evictor thread. When non-positive, no idle object evictor thread will be run.

See Also: GenericObjectPool

setWhenExhaustedAction

public void setWhenExhaustedAction(byte whenExhaustedAction)
Sets the action to take when the GenericObjectPool method is invoked when the pool is exhausted (the maximum number of "active" objects has been reached).

Parameters: whenExhaustedAction the action code, which must be one of WHEN_EXHAUSTED_BLOCK, WHEN_EXHAUSTED_FAIL, or WHEN_EXHAUSTED_GROW

See Also: GenericObjectPool

Copyright © 2001-2003 Apache Software Foundation. Documenation generated August 23 2012.