org.apache.avalon.excalibur.pool
Class SingleThreadedPool

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.avalon.excalibur.pool.SingleThreadedPool
All Implemented Interfaces:
org.apache.avalon.excalibur.pool.Pool, org.apache.avalon.excalibur.pool.Resizable, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.thread.SingleThreaded

public class SingleThreadedPool
extends org.apache.avalon.framework.logger.AbstractLogEnabled
implements org.apache.avalon.excalibur.pool.Pool, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.thread.SingleThreaded, org.apache.avalon.excalibur.pool.Resizable, org.apache.avalon.framework.activity.Disposable

This is an Pool that caches Poolable objects for reuse.

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

Field Summary
protected  org.apache.avalon.excalibur.pool.PoolController m_controller
           
protected  int m_count
           
protected  org.apache.avalon.excalibur.pool.ObjectFactory m_factory
           
protected  int m_initial
           
protected  boolean m_initialized
           
protected  int m_maximum
           
protected  org.apache.avalon.excalibur.pool.Poolable[] m_pool
           
 
Constructor Summary
SingleThreadedPool(java.lang.Class clazz, int initial, int maximum)
           
SingleThreadedPool(org.apache.avalon.excalibur.pool.ObjectFactory factory, int initial, int maximum)
           
SingleThreadedPool(org.apache.avalon.excalibur.pool.ObjectFactory factory, org.apache.avalon.excalibur.pool.PoolController controller, int initial, int maximum)
           
 
Method Summary
 void dispose()
          Dispose the pool and decommission any Poolables.
 void fill(int fillSize)
          This fills the pool to the size specified in parameter.
 org.apache.avalon.excalibur.pool.Poolable get()
          Retrieve an object from pool.
 int getCapacity()
          Return the total number of slots in Pool
 void grow(int increase)
          This fills the pool by the size specified in parameter.
 void initialize()
           
 void put(org.apache.avalon.excalibur.pool.Poolable poolable)
          Place an object in pool.
 void shrink(int decrease)
          This shrinks the pool by parameter size.
 int size()
          Get the number of used slots in Pool
 
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

m_initialized

protected boolean m_initialized

m_count

protected int m_count

m_pool

protected org.apache.avalon.excalibur.pool.Poolable[] m_pool

m_factory

protected org.apache.avalon.excalibur.pool.ObjectFactory m_factory

m_controller

protected org.apache.avalon.excalibur.pool.PoolController m_controller

m_maximum

protected int m_maximum

m_initial

protected int m_initial
Constructor Detail

SingleThreadedPool

public SingleThreadedPool(java.lang.Class clazz,
                          int initial,
                          int maximum)
                   throws java.lang.Exception
Throws:
java.lang.Exception

SingleThreadedPool

public SingleThreadedPool(org.apache.avalon.excalibur.pool.ObjectFactory factory,
                          int initial,
                          int maximum)
                   throws java.lang.Exception
Throws:
java.lang.Exception

SingleThreadedPool

public SingleThreadedPool(org.apache.avalon.excalibur.pool.ObjectFactory factory,
                          org.apache.avalon.excalibur.pool.PoolController controller,
                          int initial,
                          int maximum)
                   throws java.lang.Exception
Throws:
java.lang.Exception
Method Detail

initialize

public void initialize()
                throws java.lang.Exception
Specified by:
initialize in interface org.apache.avalon.framework.activity.Initializable
Throws:
java.lang.Exception

get

public org.apache.avalon.excalibur.pool.Poolable get()
                                              throws java.lang.Exception
Retrieve an object from pool.

Specified by:
get in interface org.apache.avalon.excalibur.pool.Pool
Returns:
an object from Pool
Throws:
java.lang.Exception

put

public void put(org.apache.avalon.excalibur.pool.Poolable poolable)
Place an object in pool.

Specified by:
put in interface org.apache.avalon.excalibur.pool.Pool
Parameters:
poolable - the object to be placed in pool

getCapacity

public final int getCapacity()
Return the total number of slots in Pool

Returns:
the total number of slots

size

public final int size()
Get the number of used slots in Pool

Returns:
the number of used slots

fill

public final void fill(int fillSize)
                throws java.lang.Exception
This fills the pool to the size specified in parameter.

Throws:
java.lang.Exception

grow

public final void grow(int increase)
This fills the pool by the size specified in parameter.

Specified by:
grow in interface org.apache.avalon.excalibur.pool.Resizable

shrink

public final void shrink(int decrease)
This shrinks the pool by parameter size.

Specified by:
shrink in interface org.apache.avalon.excalibur.pool.Resizable

dispose

public void dispose()
Dispose the pool and decommission any Poolables.

Specified by:
dispose in interface org.apache.avalon.framework.activity.Disposable


Copyright © 1997-2009 Apache Software Foundation. All Rights Reserved.