T - the PooledObject typepublic abstract class AbstractPool<T extends PooledObject<?>>
extends java.lang.Object
| Modifier and Type | Field and Description |
|---|---|
protected int |
initialSize |
protected int |
maxSize |
protected java.util.List<T> |
pool |
| Modifier | Constructor and Description |
|---|---|
protected |
AbstractPool(int initialSize,
int maxSize) |
| Modifier and Type | Method and Description |
|---|---|
protected abstract T |
create(java.lang.Object... args)
Create an object for the pool.
|
void |
release(T pooledObject)
Release the provided object and return it to the pool.
|
T |
request(java.lang.Object... args)
Requests an object
<T> from the pool. |
protected abstract void |
reset(T pooledObject)
Reset the provided object so it can be returned to the pool for reuse.
|
protected final java.util.List<T extends PooledObject<?>> pool
protected final int initialSize
protected final int maxSize
public T request(java.lang.Object... args)
<T> from the pool. Adds a new instance to
the pool if the pool is empty.args - the arguments to pass to the create method, or to help
select an object from the pool.PooledObject from the pool.java.lang.IllegalStateException - if the number of active instances exceeds
the configured sizepublic void release(T pooledObject)
pooledObject - the object to return to the poolprotected abstract T create(java.lang.Object... args)
args - the arguments to be provided to the create method.<T> for the pool.protected abstract void reset(T pooledObject)
pooledObject - the object