org.alicebot.server.sql.pool
Class ObjectPool

java.lang.Object
  extended by org.alicebot.server.sql.pool.ObjectPool
Direct Known Subclasses:
DbAccessRefsPoolMgr

public abstract class ObjectPool
extends java.lang.Object

An abstract pool of objects that can be checked in and locked, checked out and unlocked.

Author:
Cristian Mircioiu

Constructor Summary
protected ObjectPool()
          Initializes the object pool with a default expiration time of one hour.
 
Method Summary
protected  void checkIn(java.lang.Object object)
          Checks in and unlocks an object.
protected  java.lang.Object checkOut()
          Checks out and locks the next available object in the pool.
protected  void cleanUp()
          Cleans up the pool by checking for expired objects.
protected abstract  java.lang.Object create()
          Creates a new object to store in the pool.
protected abstract  void expire(java.lang.Object object)
          Expires an object in the pool.
protected abstract  boolean validate(java.lang.Object object)
          Validates an object in the pool.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ObjectPool

protected ObjectPool()
Initializes the object pool with a default expiration time of one hour.

Method Detail

checkIn

protected void checkIn(java.lang.Object object)
Checks in and unlocks an object.

Parameters:
object - the object to check in and unlock.

checkOut

protected java.lang.Object checkOut()
Checks out and locks the next available object in the pool.

Returns:
the next available object in the pool

cleanUp

protected void cleanUp()
Cleans up the pool by checking for expired objects.


create

protected abstract java.lang.Object create()
Creates a new object to store in the pool.


expire

protected abstract void expire(java.lang.Object object)
Expires an object in the pool.


validate

protected abstract boolean validate(java.lang.Object object)
Validates an object in the pool.

Parameters:
object - the object to validate