org.jacorb.notification.util
Class AbstractObjectPool

java.lang.Object
  extended by org.jacorb.notification.util.AbstractObjectPool
All Implemented Interfaces:
java.lang.Runnable, org.apache.avalon.framework.configuration.Configurable
Direct Known Subclasses:
AbstractTaskPool

public abstract class AbstractObjectPool
extends java.lang.Object
implements java.lang.Runnable, org.apache.avalon.framework.configuration.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
           
protected  org.apache.avalon.framework.logger.Logger logger_
           
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
 
Constructor Summary
protected AbstractObjectPool(java.lang.String name)
           
protected AbstractObjectPool(java.lang.String name, int threshold, int sizeincrease, int initialsize, int maxsize)
           
 
Method Summary
 void activateObject(java.lang.Object o)
          Is called before Object is returned to Client (lendObject).
 void configure(org.apache.avalon.framework.configuration.Configuration conf)
           
static void deregisterPool(AbstractObjectPool pool)
           
 void destroyObject(java.lang.Object o)
          Is called if Pool is full and Object is discarded.
 void dispose()
          Release this Pool.
 void init()
          Initialize this Pool.
 java.lang.Object lendObject()
          lend an object from the pool.
abstract  java.lang.Object newInstance()
          This method is called by the Pool to create a new Instance.
 void passivateObject(java.lang.Object o)
          Is called after Object is returned to pool.
 void returnObject(java.lang.Object o)
          return an Object to the pool.
 void run()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEBUG

public static final boolean DEBUG
See Also:
Constant Field Values

SLEEP

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

See Also:
Constant Field Values

LOWER_WATERMARK_DEFAULT

public static final int LOWER_WATERMARK_DEFAULT
See Also:
Constant Field Values

SIZE_INCREASE_DEFAULT

public static final int SIZE_INCREASE_DEFAULT
See Also:
Constant Field Values

INITIAL_SIZE_DEFAULT

public static final int INITIAL_SIZE_DEFAULT
See Also:
Constant Field Values

MAXIMUM_WATERMARK_DEFAULT

public static final int MAXIMUM_WATERMARK_DEFAULT
See Also:
Constant Field Values

logger_

protected org.apache.avalon.framework.logger.Logger logger_
Constructor Detail

AbstractObjectPool

protected AbstractObjectPool(java.lang.String name)

AbstractObjectPool

protected AbstractObjectPool(java.lang.String name,
                             int threshold,
                             int sizeincrease,
                             int initialsize,
                             int maxsize)
Method Detail

deregisterPool

public static void deregisterPool(AbstractObjectPool pool)

configure

public void configure(org.apache.avalon.framework.configuration.Configuration conf)
Specified by:
configure in interface org.apache.avalon.framework.configuration.Configurable

run

public void run()
Specified by:
run in interface java.lang.Runnable

init

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


dispose

public void dispose()
Release this Pool.


lendObject

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


returnObject

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


newInstance

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


passivateObject

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


activateObject

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


destroyObject

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