org.enhydra.jdbc.pool
Class GenericPool

java.lang.Object
  extended byorg.enhydra.jdbc.pool.GenericPool

public class GenericPool
extends java.lang.Object

GenericPool is the main class of the Pool. It works with any kind of object that's implement PoolHelper (must provide specific operation on the specific object) Objects stored in hashtables are GenerationObject object. These objects allow to store multiples things in them, in particular, the generation number to identify the generation of an object.


Field Summary
static int DEFAULT_DEADLOCKMAXWAIT
           
static int DEFAULT_DEADLOCKRETRYWAIT
           
static long DEFAULT_EXPIRATION
           
static int DEFAULT_MAXSIZE
           
static int DEFAULT_MINSIZE
           
static long DEFAULT_SLEEPTIME
           
protected  int generation
          Generation number.
protected  java.lang.Thread keeper
           
protected  PoolKeeper poolKeeper
           
 
Constructor Summary
GenericPool(PoolHelper helper)
          Creates an GenericPool with the default params.
GenericPool(PoolHelper helper, int initSize)
           
GenericPool(PoolHelper helper, int minSize, int maxSize, long lifeTime, long sleepTime)
          Constructor, set the two hashtables and set by default the other values
 
Method Summary
 void checkIn(java.lang.Object o)
          remove object from locked pool
 java.lang.Object checkOut(java.lang.String user, java.lang.String password)
          return pooled object
 boolean checkOwner(GenerationObject genObject, java.lang.String user, java.lang.String password)
           
protected  void cleanUp()
          Remove unusable objects from the pool, called by PoolKeeper Check the unlocked objects for expired members.
 int getCheckLevelObject()
           
 int getCount()
           
 long getDeadLockMaxWait()
           
 long getDeadLockRetryWait()
           
 int getGeneration()
           
 long getLifeTime()
           
 java.util.Hashtable getLockedObject()
           
 int getLockedObjectCount()
          returns the current number of objects that are locked
 int getMaxSize()
           
 int getMinSize()
           
 long getSleepTime()
           
 int getUnlockedObjectCount()
          returns the current number of objects that are unlocked
 boolean isDebug()
           
 boolean isGC()
           
 void minimumObject()
           
 void minimumObject(java.lang.String user, java.lang.String password)
           
 void nextGeneration(java.lang.Object obj)
          Allows to verify if objects from the pool - for the o generation - are valid or not.
 void removeLockedObject(java.lang.Object obj)
          removes an object for the locked pool, when an error has occurred
 void setCheckLevelObject(int level)
          level are accepted between 0 and 4
 void setDeadLockMaxWait(long deadLock)
           
 void setDeadLockRetryWait(long deadLockRetryWait)
           
 void setDebug(boolean debug)
           
 void setGC(boolean gc)
           
 void setGeneration(int generation)
           
 void setLifeTime(long lifeTime)
           
 void setLogger(Logger alog)
          Outputs a log message to the log writer.
 void setMaxSize(int max)
           
 void setMinSize(int min)
           
 void setSleepTime(long sleepTime)
           
 void start()
          Start method, to initialize independant values of the pool
 void stop()
          switch off the pool
 java.lang.String toString()
          returns information from the pool
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Field Detail

keeper

protected java.lang.Thread keeper

poolKeeper

protected PoolKeeper poolKeeper

generation

protected int generation
Generation number. When an error occurs, all objects of the same generation or earlier are dropped.


DEFAULT_EXPIRATION

public static final long DEFAULT_EXPIRATION
See Also:
Constant Field Values

DEFAULT_SLEEPTIME

public static final long DEFAULT_SLEEPTIME
See Also:
Constant Field Values

DEFAULT_MINSIZE

public static final int DEFAULT_MINSIZE
See Also:
Constant Field Values

DEFAULT_MAXSIZE

public static final int DEFAULT_MAXSIZE
See Also:
Constant Field Values

DEFAULT_DEADLOCKMAXWAIT

public static final int DEFAULT_DEADLOCKMAXWAIT
See Also:
Constant Field Values

DEFAULT_DEADLOCKRETRYWAIT

public static final int DEFAULT_DEADLOCKRETRYWAIT
See Also:
Constant Field Values
Constructor Detail

GenericPool

public GenericPool(PoolHelper helper)
Creates an GenericPool with the default params.


GenericPool

public GenericPool(PoolHelper helper,
                   int initSize)

GenericPool

public GenericPool(PoolHelper helper,
                   int minSize,
                   int maxSize,
                   long lifeTime,
                   long sleepTime)
Constructor, set the two hashtables and set by default the other values

Method Detail

start

public void start()
Start method, to initialize independant values of the pool


checkOwner

public boolean checkOwner(GenerationObject genObject,
                          java.lang.String user,
                          java.lang.String password)

checkOut

public java.lang.Object checkOut(java.lang.String user,
                                 java.lang.String password)
                          throws java.lang.Exception
return pooled object

Throws:
java.lang.Exception

minimumObject

public void minimumObject()

minimumObject

public void minimumObject(java.lang.String user,
                          java.lang.String password)

checkIn

public void checkIn(java.lang.Object o)
remove object from locked pool


setDebug

public void setDebug(boolean debug)

isDebug

public boolean isDebug()

setMinSize

public void setMinSize(int min)
                throws java.lang.Exception
Throws:
java.lang.Exception

setMaxSize

public void setMaxSize(int max)
                throws java.lang.Exception
Throws:
java.lang.Exception

setLifeTime

public void setLifeTime(long lifeTime)

setSleepTime

public void setSleepTime(long sleepTime)

setGeneration

public void setGeneration(int generation)

setGC

public void setGC(boolean gc)

setCheckLevelObject

public void setCheckLevelObject(int level)
level are accepted between 0 and 4


setDeadLockMaxWait

public void setDeadLockMaxWait(long deadLock)

setDeadLockRetryWait

public void setDeadLockRetryWait(long deadLockRetryWait)

getMinSize

public int getMinSize()

getMaxSize

public int getMaxSize()

getLifeTime

public long getLifeTime()

isGC

public boolean isGC()

getCount

public int getCount()

getSleepTime

public long getSleepTime()

getGeneration

public int getGeneration()

getCheckLevelObject

public int getCheckLevelObject()

stop

public void stop()
switch off the pool


getLockedObjectCount

public int getLockedObjectCount()
returns the current number of objects that are locked


getUnlockedObjectCount

public int getUnlockedObjectCount()
returns the current number of objects that are unlocked


getDeadLockMaxWait

public long getDeadLockMaxWait()

getDeadLockRetryWait

public long getDeadLockRetryWait()

toString

public java.lang.String toString()
returns information from the pool


cleanUp

protected void cleanUp()
Remove unusable objects from the pool, called by PoolKeeper Check the unlocked objects for expired members.


nextGeneration

public void nextGeneration(java.lang.Object obj)
Allows to verify if objects from the pool - for the o generation - are valid or not. (only for the unlocked pool, to avoid to allocate non-valid object


removeLockedObject

public void removeLockedObject(java.lang.Object obj)
removes an object for the locked pool, when an error has occurred


setLogger

public void setLogger(Logger alog)
Outputs a log message to the log writer.


getLockedObject

public java.util.Hashtable getLockedObject()