org.apache.avalon.excalibur.pool
Class AbstractPool

java.lang.Object
  extended byorg.apache.avalon.framework.logger.AbstractLogEnabled
      extended byorg.apache.avalon.excalibur.pool.AbstractPool
All Implemented Interfaces:
LogEnabled, Pool, ThreadSafe
Direct Known Subclasses:
DefaultPool

public abstract class AbstractPool
extends AbstractLogEnabled
implements Pool, ThreadSafe

This is an Pool that caches Poolable objects for reuse.

Since:
4.0
Version:
CVS $Revision: 1.5 $ $Date: 2004/03/29 16:50:37 $
Author:
Avalon Development Team

Field Summary
static int DEFAULT_POOL_SIZE
           
protected  java.util.List m_active
           
protected  ObjectFactory m_factory
           
protected  boolean m_initialized
           
protected  int m_min
           
protected  EDU.oswego.cs.dl.util.concurrent.Mutex m_mutex
           
protected  org.apache.commons.collections.Buffer m_ready
           
 
Constructor Summary
AbstractPool(ObjectFactory factory)
          Create an AbstractPool.
 
Method Summary
abstract  Poolable get()
           
protected  void initialize()
           
protected  void internalGrow(int amount)
           
protected  void internalShrink(int amount)
           
protected  void lock()
           
protected  Poolable newPoolable()
          This is the method to override when you need to enforce creational policies.
abstract  void put(Poolable object)
           
protected  void removePoolable(Poolable poolable)
          This is the method to override when you need to enforce destructional policies.
 int size()
           
protected  void unlock()
           
 
Methods inherited from class org.apache.avalon.framework.logger.AbstractLogEnabled
enableLogging, getLogger, setupLogger, setupLogger, setupLogger
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

DEFAULT_POOL_SIZE

public static final int DEFAULT_POOL_SIZE
See Also:
Constant Field Values

m_factory

protected final ObjectFactory m_factory

m_active

protected java.util.List m_active

m_ready

protected org.apache.commons.collections.Buffer m_ready

m_mutex

protected EDU.oswego.cs.dl.util.concurrent.Mutex m_mutex

m_initialized

protected boolean m_initialized

m_min

protected int m_min
Constructor Detail

AbstractPool

public AbstractPool(ObjectFactory factory)
             throws java.lang.Exception
Create an AbstractPool. The pool requires a factory, and can optionally have a controller.

Method Detail

initialize

protected void initialize()
                   throws java.lang.Exception
Throws:
java.lang.Exception

lock

protected final void lock()
                   throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

unlock

protected final void unlock()
                     throws java.lang.InterruptedException
Throws:
java.lang.InterruptedException

newPoolable

protected Poolable newPoolable()
                        throws java.lang.Exception
This is the method to override when you need to enforce creational policies.

Throws:
java.lang.Exception

removePoolable

protected void removePoolable(Poolable poolable)
This is the method to override when you need to enforce destructional policies.


size

public final int size()

get

public abstract Poolable get()
                      throws java.lang.Exception
Specified by:
get in interface Pool
Throws:
java.lang.Exception

put

public abstract void put(Poolable object)
Specified by:
put in interface Pool

internalGrow

protected void internalGrow(int amount)
                     throws java.lang.Exception
Throws:
java.lang.Exception

internalShrink

protected void internalShrink(int amount)
                       throws java.lang.Exception
Throws:
java.lang.Exception


Copyright © 1997-2005 The Apache Software Foundation. All Rights Reserved.