nl.knowledgeplaza.util.pool
Class BaseObjectPool

java.lang.Object
  extended by nl.knowledgeplaza.util.pool.BaseObjectPool
All Implemented Interfaces:
ObjectPool
Direct Known Subclasses:
PriorityObjectPool, RoundRobinObjectPool, StackObjectPool

public abstract class BaseObjectPool
extends java.lang.Object
implements ObjectPool

This class implements basic object pool logic. It can be placed into synchronized mode. In unsynchronized mode the implementations tries to keep the synchronisation code to a minimum to enable faster execution. In synchronized mode, all code is executed synchronized.

Version:
$Revision: 1.2 $
Author:
$Author: toeukpap $
See Also:

Nested Class Summary
 class BaseObjectPool.NotFromThisPoolException
           
 class BaseObjectPool.TimeOutException
           
 
Field Summary
protected  boolean iClose
           
protected  java.util.List iListOfHandedOutObjects
           
protected  java.util.List iListOfHandedOutObjectsSync
           
protected  boolean iShuttingDown
           
protected  boolean iSynchronized
           
protected  boolean itestOnBorrow
           
static int MAINTENANCE_PERIOD
           
static java.lang.String SOURCECODE_VERSION
          Standard variable for determining version of a class file.
static byte WHEN_EXHAUSTED_BLOCK
           
static byte WHEN_EXHAUSTED_FAIL
           
 
Constructor Summary
BaseObjectPool(org.apache.log4j.Logger log4j)
          Initialize
BaseObjectPool(PoolableObjectFactory pPoolableObjectFactory, org.apache.log4j.Logger log4j)
          Initialize
 
Method Summary
 void addObject()
           
 java.lang.Object borrowObject()
           
 void clear()
           
 void close()
          close
protected  void factoryActivateObject(java.lang.Object object)
           
protected  void factoryDestroyObject(java.lang.Object object)
           
protected  java.lang.Object factoryMakeObject()
           
protected  void factoryPassivateObject(java.lang.Object object)
           
protected  void factoryValidateObject(java.lang.Object object)
           
 void fill(java.util.Collection collection)
          Initialize
 PoolableObjectFactory getFactory()
          PoolableObjectFactory
 int getMaxActive()
          MaxActive
 int getMaxIdle()
          MaxIdle
 int getMaxWait()
          MaxWait
 java.lang.String getName()
          Name
 java.lang.String getNameDescription()
           
 int getNumActive()
           
 int getNumberOfObjectsScheduledForDestruction()
          number of objects scheduled for destruction
 int getNumIdle()
           
protected  java.util.Collection getPooledObjects()
          this method bolts synchronization onto the implementation
protected abstract  java.util.Collection getPooledObjectsImpl()
          this method allows read only access to the collection of handed out objects, used by the generic algorithm
 boolean getTestOnBorrow()
           
 byte getWhenExhaustedAction()
          WhenExhaustedAction
 void invalidateObject(java.lang.Object object)
           
 boolean isClosed()
           
 boolean isShuttingDown()
           
 boolean isSynchronized()
           
protected  void maintenance()
          perform maintenance on me
protected  java.lang.Object obtainPooledObject()
          this method bolts synchronization onto the implementation
protected abstract  java.lang.Object obtainPooledObjectImpl()
          this method obtains a pooled object, the implementation determines the behaviour (LIFO, FIFO, etc)
 void returnObject(java.lang.Object object)
           
protected  void returnPooledObject(java.lang.Object o)
          this method bolts synchronization onto the implementation
protected abstract  void returnPooledObjectImpl(java.lang.Object o)
          this method returns a pooled object, the implementation determines the behaviour (LIFO, FIFO, etc)
 void setFactory(PoolableObjectFactory value)
           
 void setMaxActive(int value)
           
 void setMaxIdle(int value)
           
 void setMaxWait(int value)
           
protected  void setName(java.lang.String value)
           
 void setSynchronized(boolean value)
          Synchronized
 void setTestOnBorrow(boolean value)
          testOnBorrow
 void setWhenExhaustedAction(byte value)
           
 void shutdown()
          shutdown
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

SOURCECODE_VERSION

public static final java.lang.String SOURCECODE_VERSION
Standard variable for determining version of a class file.

See Also:
Constant Field Values

iListOfHandedOutObjects

protected java.util.List iListOfHandedOutObjects

iListOfHandedOutObjectsSync

protected java.util.List iListOfHandedOutObjectsSync

iShuttingDown

protected boolean iShuttingDown

iSynchronized

protected boolean iSynchronized

iClose

protected boolean iClose

itestOnBorrow

protected boolean itestOnBorrow

WHEN_EXHAUSTED_FAIL

public static final byte WHEN_EXHAUSTED_FAIL
See Also:
Constant Field Values

WHEN_EXHAUSTED_BLOCK

public static final byte WHEN_EXHAUSTED_BLOCK
See Also:
Constant Field Values

MAINTENANCE_PERIOD

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

BaseObjectPool

public BaseObjectPool(org.apache.log4j.Logger log4j)
Initialize


BaseObjectPool

public BaseObjectPool(PoolableObjectFactory pPoolableObjectFactory,
                      org.apache.log4j.Logger log4j)
Initialize

Method Detail

getPooledObjectsImpl

protected abstract java.util.Collection getPooledObjectsImpl()
this method allows read only access to the collection of handed out objects, used by the generic algorithm


obtainPooledObjectImpl

protected abstract java.lang.Object obtainPooledObjectImpl()
this method obtains a pooled object, the implementation determines the behaviour (LIFO, FIFO, etc)


returnPooledObjectImpl

protected abstract void returnPooledObjectImpl(java.lang.Object o)
this method returns a pooled object, the implementation determines the behaviour (LIFO, FIFO, etc)


getPooledObjects

protected java.util.Collection getPooledObjects()
this method bolts synchronization onto the implementation


obtainPooledObject

protected java.lang.Object obtainPooledObject()
this method bolts synchronization onto the implementation


returnPooledObject

protected void returnPooledObject(java.lang.Object o)
this method bolts synchronization onto the implementation


getFactory

public PoolableObjectFactory getFactory()
PoolableObjectFactory


setFactory

public void setFactory(PoolableObjectFactory value)
Specified by:
setFactory in interface ObjectPool

shutdown

public void shutdown()
shutdown

Specified by:
shutdown in interface ObjectPool

isShuttingDown

public boolean isShuttingDown()

setSynchronized

public void setSynchronized(boolean value)
Synchronized

Specified by:
setSynchronized in interface ObjectPool

isSynchronized

public boolean isSynchronized()
Specified by:
isSynchronized in interface ObjectPool

close

public void close()
close

Specified by:
close in interface ObjectPool

isClosed

public boolean isClosed()

getMaxWait

public int getMaxWait()
MaxWait


setMaxWait

public void setMaxWait(int value)

getMaxActive

public int getMaxActive()
MaxActive


setMaxActive

public void setMaxActive(int value)

getMaxIdle

public int getMaxIdle()
MaxIdle


setMaxIdle

public void setMaxIdle(int value)

setTestOnBorrow

public void setTestOnBorrow(boolean value)
testOnBorrow


getTestOnBorrow

public boolean getTestOnBorrow()

getWhenExhaustedAction

public byte getWhenExhaustedAction()
WhenExhaustedAction


setWhenExhaustedAction

public void setWhenExhaustedAction(byte value)

getName

public java.lang.String getName()
Name


setName

protected void setName(java.lang.String value)

getNameDescription

public java.lang.String getNameDescription()

getNumberOfObjectsScheduledForDestruction

public int getNumberOfObjectsScheduledForDestruction()
number of objects scheduled for destruction


borrowObject

public java.lang.Object borrowObject()
Specified by:
borrowObject in interface ObjectPool

returnObject

public void returnObject(java.lang.Object object)
Specified by:
returnObject in interface ObjectPool

invalidateObject

public void invalidateObject(java.lang.Object object)
Specified by:
invalidateObject in interface ObjectPool

getNumActive

public int getNumActive()
                 throws java.lang.UnsupportedOperationException
Specified by:
getNumActive in interface ObjectPool
Throws:
java.lang.UnsupportedOperationException

getNumIdle

public int getNumIdle()
               throws java.lang.UnsupportedOperationException
Specified by:
getNumIdle in interface ObjectPool
Throws:
java.lang.UnsupportedOperationException

addObject

public void addObject()
Specified by:
addObject in interface ObjectPool

clear

public void clear()
           throws java.lang.UnsupportedOperationException
Specified by:
clear in interface ObjectPool
Throws:
java.lang.UnsupportedOperationException

fill

public void fill(java.util.Collection collection)
Initialize


factoryMakeObject

protected java.lang.Object factoryMakeObject()
Returns:

factoryActivateObject

protected void factoryActivateObject(java.lang.Object object)

factoryValidateObject

protected void factoryValidateObject(java.lang.Object object)

factoryPassivateObject

protected void factoryPassivateObject(java.lang.Object object)

factoryDestroyObject

protected void factoryDestroyObject(java.lang.Object object)

maintenance

protected void maintenance()
perform maintenance on me



Copyright © 2010. All Rights Reserved.