net.sourceforge.idrs.utils.pool
Class ObjectPool
java.lang.Object
|
+--net.sourceforge.idrs.utils.pool.ObjectPool
- All Implemented Interfaces:
- java.io.Serializable
- Direct Known Subclasses:
- IDRSPool, JDBCPool
- public abstract class ObjectPool
- extends java.lang.Object
- implements java.io.Serializable
ObjectPool provides a mechanism for pooling objects and resources.
It must be subclassed to acocmplish specific pools; GenericPool
and JDBCPool are examples of such subclasses.
2 *
- See Also:
GenericPool
,
JDBCPool
, Serialized Form
Constructor Summary |
ObjectPool()
Creates an ObjectPool with the default params. |
ObjectPool(int objectMin,
int objectLimit,
long daysOpen,
long sleepTime,
java.lang.String path,
int trys)
Create an instance of ObjectPool |
ObjectPool(long daysOpen,
long sleepTime)
Create an ObjectPool with no object count limit. |
Methods inherited from class java.lang.Object |
, clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
out
protected java.io.PrintStream out
maxTrys
protected int maxTrys
daysOpen
protected long daysOpen
sleepTime
protected long sleepTime
DEFAULT_PATH
protected static final java.lang.String DEFAULT_PATH
DEFAULT_TRYS
protected static final int DEFAULT_TRYS
DEFAULT_DAYS_OPEN
protected static final long DEFAULT_DAYS_OPEN
DEFAULT_MIN_POOLSIZE
protected static final int DEFAULT_MIN_POOLSIZE
logPath
protected java.lang.String logPath
minn
protected int minn
pool
protected PooledObject[] pool
limit
protected int limit
count
protected int count
debug
protected boolean debug
DEFAULT_EXPIRATION
public static final long DEFAULT_EXPIRATION
DEFAULT_SLEEPTIME
public static final long DEFAULT_SLEEPTIME
MAX_POOLSIZE
public static final int MAX_POOLSIZE
DEFAULT_TIMEOUT
public static final long DEFAULT_TIMEOUT
ObjectPool
public ObjectPool()
throws java.lang.Exception
- Creates an ObjectPool with the default params.
ObjectPool
public ObjectPool(long daysOpen,
long sleepTime)
throws java.lang.Exception
- Create an ObjectPool with no object count limit.
ObjectPool
public ObjectPool(int objectMin,
int objectLimit,
long daysOpen,
long sleepTime,
java.lang.String path,
int trys)
throws java.lang.Exception
- Create an instance of ObjectPool
- Parameters:
expirationTime
- is the time in milliseconds that each object has to live.objectLimit
- is the total number of objects that are allowed in the pool at any time. If objectLimit is equal to or less than 0, it is assumed that the limit is Integer.MAX_VALUEsleepTime
- is the time in miliseconds that the pool skimming thread sleeps between 'reap' cycles
isDebugging
public boolean isDebugging()
setDebugging
public void setDebugging(boolean b)
logHeader
protected abstract void logHeader()
throws java.lang.Exception
create
protected abstract PooledObject create()
throws java.lang.Exception
validate
protected abstract boolean validate(PooledObject obj)
expire
protected abstract void expire(PooledObject obj)
checkOut
public java.lang.Object checkOut(int num)
throws java.lang.Exception
- Checkout cycles through the available objects and returns the first valid
object it finds. if there are no valid objects, checkOut will create
one, unless the client specified amount of objects have already been
created, and then it will block until it finds an appropriate object
getConnID
protected int getConnID(java.lang.Object obj)
checkIn
protected void checkIn(java.lang.Object obj)
throws java.lang.Exception
- Checks an object back into the pool.
checkIn
public void checkIn(java.lang.String DBName)
throws java.lang.Exception
shouldReset
protected boolean shouldReset(int index)
reset
protected abstract void reset(int index)