public abstract class Pool<T> extends Object
Supremely useful with SQL connections. This does check for validity as a matter of course.
Created by Jeff Gaynor
on Mar 12, 2010 at 3:48:20 PM
Modifier and Type | Field and Description |
---|---|
static int |
INFINITE |
protected int |
inUse |
Constructor and Description |
---|
Pool() |
Modifier and Type | Method and Description |
---|---|
abstract T |
create()
Create a new, ready-to-use object for the pool
|
abstract void |
destroy(T object)
Destroy an object that is no longer needed.
|
boolean |
destroyAll() |
T |
doCreate() |
void |
doDestroy(T item)
Destroying an item reduces the number of in-use items.
|
int |
getMaxSize()
Get the maximum number of items
|
boolean |
isValid(T object)
Is this item still good? If not it will be removed from the
pool so a new one can be created.
|
T |
pop()
Pop an object off the stack if ther eis one, otherwise, create one.
|
void |
push(T object)
Check an object into the pool.
|
void |
setMaxSize(int c)
Set the maximum number of items.
|
public static final int INFINITE
protected int inUse
public abstract T create() throws PoolException
PoolException
public abstract void destroy(T object) throws PoolException
object
- the objectPoolException
public boolean isValid(T object) throws PoolException
PoolException
public T pop() throws PoolException
PoolException
public T doCreate() throws PoolException
PoolException
public void doDestroy(T item) throws PoolException
item
- the itemPoolException
public void setMaxSize(int c)
c
- public int getMaxSize()
public void push(T object) throws PoolException
object
- the objectPoolException
public boolean destroyAll()
Copyright © 2019. All Rights Reserved.