org.jacorb.notification.util

Class AbstractObjectPool

Implemented Interfaces:
Configurable, Runnable
Known Direct Subclasses:
AbstractTaskPool

public abstract class AbstractObjectPool
extends java.lang.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!

Version:
$Id: AbstractObjectPool.java,v 1.7 2004/05/06 12:40:00 nicolas Exp $

Author:
Alphonse Bendt

Field Summary

static boolean
DEBUG
static int
INITIAL_SIZE_DEFAULT
static int
LOWER_WATERMARK_DEFAULT
static int
MAXIMUM_WATERMARK_DEFAULT
static int
SIZE_INCREASE_DEFAULT
static long
SLEEP
time the cleaner thread sleeps between two cleanups
protected Logger
logger_

Constructor Summary

AbstractObjectPool(String name)
AbstractObjectPool(String name, int threshold, int sizeincrease, int initialsize, int maxsize)

Method Summary

void
activateObject(Object o)
Is called before Object is returned to Client (lendObject).
void
configure(Configuration conf)
static void
deregisterPool(AbstractObjectPool pool)
void
destroyObject(Object o)
Is called if Pool is full and Object is discarded.
void
dispose()
Release this Pool.
void
init()
Initialize this Pool.
Object
lendObject()
lend an object from the pool.
Object
newInstance()
This method is called by the Pool to create a new Instance.
void
passivateObject(Object o)
Is called after Object is returned to pool.
void
returnObject(Object o)
return an Object to the pool.
void
run()

Field Details

DEBUG

public static final boolean DEBUG

Field Value:
false


INITIAL_SIZE_DEFAULT

public static final int INITIAL_SIZE_DEFAULT

Field Value:
100


LOWER_WATERMARK_DEFAULT

public static final int LOWER_WATERMARK_DEFAULT

Field Value:
30


MAXIMUM_WATERMARK_DEFAULT

public static final int MAXIMUM_WATERMARK_DEFAULT

Field Value:
1000


SIZE_INCREASE_DEFAULT

public static final int SIZE_INCREASE_DEFAULT

Field Value:
30


SLEEP

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

Field Value:
100L


logger_

protected Logger logger_

Constructor Details

AbstractObjectPool

protected AbstractObjectPool(String name)


AbstractObjectPool

protected AbstractObjectPool(String name,
                             int threshold,
                             int sizeincrease,
                             int initialsize,
                             int maxsize)

Method Details

activateObject

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


configure

public void configure(Configuration conf)


deregisterPool

public static void deregisterPool(AbstractObjectPool pool)


destroyObject

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


dispose

public void dispose()
Release this Pool.


init

public void init()
Initialize this Pool. An initial Number of Objects is created. Cleanup Thread is started.


lendObject

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


newInstance

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


passivateObject

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


returnObject

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


run

public void run()