Methods inherited from class java.lang.Object

Constructor Detail

PoolUtils

public PoolUtils()

PoolUtils instances should NOT be constructed in standard programming.
Instead, the class should be used procedurally: PoolUtils.adapt(aPool);.
This constructor is public to permit tools that require a JavaBean
instance to operate.

Method Detail

checkRethrow

public static void checkRethrow(java.lang.Throwable t)

Should the supplied Throwable be re-thrown (eg if it is an instance of
one of the Throwables that should never be swallowed). Used by the pool
error handling for operations that throw exceptions that normally need to
be ignored.

Parameters:

t - The Throwable to check

Throws:

java.lang.ThreadDeath - if that is passed in

java.lang.VirtualMachineError - if that is passed in

checkMinIdle

Periodically check the idle object count for the pool. At most one idle
object will be added per period. If there is an exception when calling
ObjectPool.addObject() then no more checks will be performed.

checkMinIdle

Periodically check the idle object count for the key in the keyedPool. At
most one idle object will be added per period. If there is an exception
when calling KeyedObjectPool.addObject(Object) then no more
checks for that key will be performed.

period - the frequency to check the number of idle objects in a
keyedPool, see Timer.schedule(TimerTask, long, long).

Returns:

a Map of key and TimerTask pairs that will
periodically check the pools idle object count.

Throws:

java.lang.IllegalArgumentException - when keyedPool, keys, or any of the
values in the collection is null or when
minIdle is negative or when period
isn't valid for Timer.schedule(TimerTask, long, long)
.

synchronizedPool

Returns a synchronized (thread-safe) ObjectPool backed by the specified
ObjectPool.

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.

Type Parameters:

T - the type of objects in the pool

Parameters:

pool - the ObjectPool to be "wrapped" in a synchronized ObjectPool.

Returns:

a synchronized view of the specified ObjectPool.

synchronizedPool

Returns 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.

Type Parameters:

K - the type of the pool key

V - the type of pool entries

Parameters:

keyedPool - the KeyedObjectPool to be "wrapped" in a synchronized
KeyedObjectPool.

erodingPool

Returns a pool that adaptively decreases its size when idle objects are
no longer needed. This is intended as an always thread-safe alternative
to using an idle object evictor provided by many pool implementations.
This is also an effective way to shrink FIFO ordered pools that
experience load spikes.

Type Parameters:

T - the type of objects in the pool

Parameters:

pool - the ObjectPool to be decorated so it shrinks its idle count
when possible.

Returns:

a pool that adaptively decreases its size when idle objects are
no longer needed.

erodingPool

Returns a pool that adaptively decreases its size when idle objects are
no longer needed. This is intended as an always thread-safe alternative
to using an idle object evictor provided by many pool implementations.
This is also an effective way to shrink FIFO ordered pools that
experience load spikes.

The factor parameter provides a mechanism to tweak the rate at which the
pool tries to shrink its size. Values between 0 and 1 cause the pool to
try to shrink its size more often. Values greater than 1 cause the pool
to less frequently try to shrink its size.

Type Parameters:

T - the type of objects in the pool

Parameters:

pool - the ObjectPool to be decorated so it shrinks its idle count
when possible.

factor - a positive value to scale the rate at which the pool tries to
reduce its size. If 0 < factor < 1 then the pool
shrinks more aggressively. If 1 < factor then the pool
shrinks less aggressively.

Returns:

a pool that adaptively decreases its size when idle objects are
no longer needed.

erodingPool

Returns a pool that adaptively decreases its size when idle objects are
no longer needed. This is intended as an always thread-safe alternative
to using an idle object evictor provided by many pool implementations.
This is also an effective way to shrink FIFO ordered pools that
experience load spikes.

Type Parameters:

K - the type of the pool key

V - the type of pool entries

Parameters:

keyedPool - the KeyedObjectPool to be decorated so it shrinks its idle
count when possible.

Returns:

a pool that adaptively decreases its size when idle objects are
no longer needed.

erodingPool

Returns a pool that adaptively decreases its size when idle objects are
no longer needed. This is intended as an always thread-safe alternative
to using an idle object evictor provided by many pool implementations.
This is also an effective way to shrink FIFO ordered pools that
experience load spikes.

The factor parameter provides a mechanism to tweak the rate at which the
pool tries to shrink its size. Values between 0 and 1 cause the pool to
try to shrink its size more often. Values greater than 1 cause the pool
to less frequently try to shrink its size.

Type Parameters:

K - the type of the pool key

V - the type of pool entries

Parameters:

keyedPool - the KeyedObjectPool to be decorated so it shrinks its idle
count when possible.

factor - a positive value to scale the rate at which the pool tries to
reduce its size. If 0 < factor < 1 then the pool
shrinks more aggressively. If 1 < factor then the pool
shrinks less aggressively.

Returns:

a pool that adaptively decreases its size when idle objects are
no longer needed.

erodingPool

Returns a pool that adaptively decreases its size when idle objects are
no longer needed. This is intended as an always thread-safe alternative
to using an idle object evictor provided by many pool implementations.
This is also an effective way to shrink FIFO ordered pools that
experience load spikes.

The factor parameter provides a mechanism to tweak the rate at which the
pool tries to shrink its size. Values between 0 and 1 cause the pool to
try to shrink its size more often. Values greater than 1 cause the pool
to less frequently try to shrink its size.

The perKey parameter determines if the pool shrinks on a whole pool basis
or a per key basis. When perKey is false, the keys do not have an effect
on the rate at which the pool tries to shrink its size. When perKey is
true, each key is shrunk independently.

Type Parameters:

K - the type of the pool key

V - the type of pool entries

Parameters:

keyedPool - the KeyedObjectPool to be decorated so it shrinks its idle
count when possible.

factor - a positive value to scale the rate at which the pool tries to
reduce its size. If 0 < factor < 1 then the pool
shrinks more aggressively. If 1 < factor then the pool
shrinks less aggressively.

perKey - when true, each key is treated independently.

Returns:

a pool that adaptively decreases its size when idle objects are
no longer needed.