org.jacorb.notification.util

Class AbstractObjectPool

public abstract class AbstractObjectPool extends Object implements Runnable, Configurable

Abstract Base Class for Simple Pooling Mechanism. Subclasses must at least implement the method newInstance. To use a Object call lendObject. After use the Object must be returned with returnObject(Object). An Object must not be used after it has been returned to its pool! This class needs a two phase initialization: configure MUST be invoked before an instance can be used.

Version: $Id: AbstractObjectPool.java,v 1.22 2006/06/14 11:57:54 alphonse.bendt Exp $

Author: Alphonse Bendt

Field Summary
protected Configurationconfig_
static booleanDEBUG
static intINITIAL_SIZE_DEFAULT
protected Loggerlogger_
static intLOWER_WATERMARK_DEFAULT
static intMAXIMUM_SIZE_DEFAULT
static intMAXIMUM_WATERMARK_DEFAULT
static intSIZE_INCREASE_DEFAULT
static longSLEEP
time the cleaner thread sleeps between two cleanups
Constructor Summary
protected AbstractObjectPool(String name)
protected AbstractObjectPool(String name, int lowerWatermark, int sizeincrease, int initialsize, int maxWatermark, int maximumSize)
Method Summary
voidconfigure(Configuration conf)
voiddispose()
Release this Pool.
voiddoActivateObject(Object o)
Is called before Object is returned to Client (lendObject).
voiddoDestroyObject(Object o)
Is called if Pool is full and returned Object is discarded.
voiddoPassivateObject(Object o)
Is called after Object is returned to pool.
protected booleanisCreationAllowed()
check if it is allowed to create more instances.
ObjectlendObject()
lend an object from the pool.
abstract ObjectnewInstance()
This method is called by the Pool to create a new Instance.
protected voidpoolIsEmpty()
voidreturnObject(Object o)
return an Object to the pool.
voidrun()
StringtoString()

Field Detail

config_

protected Configuration config_

DEBUG

public static final boolean DEBUG

INITIAL_SIZE_DEFAULT

public static final int INITIAL_SIZE_DEFAULT

logger_

protected final Logger logger_

LOWER_WATERMARK_DEFAULT

public static final int LOWER_WATERMARK_DEFAULT

MAXIMUM_SIZE_DEFAULT

public static final int MAXIMUM_SIZE_DEFAULT

MAXIMUM_WATERMARK_DEFAULT

public static final int MAXIMUM_WATERMARK_DEFAULT

SIZE_INCREASE_DEFAULT

public static final int SIZE_INCREASE_DEFAULT

SLEEP

public static final long SLEEP
time the cleaner thread sleeps between two cleanups

Constructor Detail

AbstractObjectPool

protected AbstractObjectPool(String name)

AbstractObjectPool

protected AbstractObjectPool(String name, int lowerWatermark, int sizeincrease, int initialsize, int maxWatermark, int maximumSize)

Method Detail

configure

public void configure(Configuration conf)

dispose

public void dispose()
Release this Pool.

doActivateObject

public void doActivateObject(Object o)
Is called before Object is returned to Client (lendObject). No Op

doDestroyObject

public void doDestroyObject(Object o)
Is called if Pool is full and returned Object is discarded. No Op.

doPassivateObject

public void doPassivateObject(Object o)
Is called after Object is returned to pool. No Op.

isCreationAllowed

protected boolean isCreationAllowed()
check if it is allowed to create more instances. preCondition: lock pool_ must be held.

lendObject

public Object lendObject()
lend an object from the pool.

newInstance

public abstract Object newInstance()
This method is called by the Pool to create a new Instance. Subclasses must override appropiately .

poolIsEmpty

protected void poolIsEmpty()

returnObject

public void returnObject(Object o)
return an Object to the pool.

run

public void run()

toString

public String toString()