org.jacorb.notification.util
Class AbstractObjectPool

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

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! This class needs a two phase initialization: configure MUST be invoked before an instance can be used.

Version:
$Id: AbstractObjectPool.java,v 1.21 2005/11/11 19:39:15 alphonse.bendt Exp $
Author:
Alphonse Bendt

Field Summary
protected  org.apache.avalon.framework.configuration.Configuration config_
           
static boolean DEBUG
           
static int INITIAL_SIZE_DEFAULT
           
protected  org.apache.avalon.framework.logger.Logger logger_
           
static int LOWER_WATERMARK_DEFAULT
           
static int MAXIMUM_SIZE_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 lowerWatermark, int sizeincrease, int initialsize, int maxWatermark, int maximumSize)
           
 
Method Summary
 void configure(org.apache.avalon.framework.configuration.Configuration conf)
           
 void dispose()
          Release this Pool.
 void doActivateObject(java.lang.Object o)
          Is called before Object is returned to Client (lendObject).
 void doDestroyObject(java.lang.Object o)
          Is called if Pool is full and returned Object is discarded.
 void doPassivateObject(java.lang.Object o)
          Is called after Object is returned to pool.
protected  boolean isCreationAllowed()
          check if it is allowed to create more instances.
 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.
protected  void poolIsEmpty()
           
 void returnObject(java.lang.Object o)
          return an Object to the pool.
 void run()
           
 java.lang.String toString()
           
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, 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

MAXIMUM_SIZE_DEFAULT

public static final int MAXIMUM_SIZE_DEFAULT
See Also:
Constant Field Values

logger_

protected final org.apache.avalon.framework.logger.Logger logger_

config_

protected org.apache.avalon.framework.configuration.Configuration config_
Constructor Detail

AbstractObjectPool

protected AbstractObjectPool(java.lang.String name)

AbstractObjectPool

protected AbstractObjectPool(java.lang.String name,
                             int lowerWatermark,
                             int sizeincrease,
                             int initialsize,
                             int maxWatermark,
                             int maximumSize)
Method Detail

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

dispose

public void dispose()
Release this Pool.


lendObject

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


isCreationAllowed

protected boolean isCreationAllowed()
check if it is allowed to create more instances.


poolIsEmpty

protected void poolIsEmpty()

returnObject

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


toString

public java.lang.String toString()

newInstance

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


doPassivateObject

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


doActivateObject

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


doDestroyObject

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