org.apache.avalon.excalibur.thread.impl
Class BasicThreadPool

java.lang.Object
  extended by org.apache.excalibur.thread.impl.AbstractThreadPool
      extended by org.apache.avalon.excalibur.thread.impl.BasicThreadPool
All Implemented Interfaces:
org.apache.avalon.excalibur.pool.ObjectFactory, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.logger.LogEnabled, org.apache.excalibur.thread.ThreadPool

 class BasicThreadPool
extends AbstractThreadPool
implements org.apache.avalon.excalibur.pool.ObjectFactory, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.activity.Disposable, org.apache.excalibur.thread.ThreadPool

The ThreadPool that binds to Legacy Pooling implementation.

Author:
Avalon Development Team

Field Summary
private  org.apache.avalon.framework.logger.Logger m_logger
          The logger to use for debugging purposes.
private  org.apache.avalon.excalibur.pool.Pool m_pool
          The underlying pool.
 
Constructor Summary
BasicThreadPool(java.lang.ThreadGroup threadGroup, java.lang.String name, org.apache.avalon.excalibur.pool.Pool pool)
          Create a new ThreadPool with specified capacity.
 
Method Summary
 void decommission(java.lang.Object object)
           
 void dispose()
          Dispose of underlying pool and cleanup resources.
 void enableLogging(org.apache.avalon.framework.logger.Logger logger)
          Setup Logging.
 org.apache.excalibur.thread.ThreadControl execute(org.apache.avalon.framework.activity.Executable work)
          Run work in separate thread.
 java.lang.Class getCreatedClass()
          Return the class of poolable instance.
protected  WorkerThread getWorker()
          Retrieve a worker thread from pool.
 java.lang.Object newInstance()
          Create new Poolable instance.
protected  WorkerThread newWorkerThread(java.lang.String name)
          Overide newWorkerThread to provide a WorkerThread that is Poolable and LogEnabled.
protected  void releaseWorker(WorkerThread worker)
          Release worker back into pool.
 
Methods inherited from class org.apache.excalibur.thread.impl.AbstractThreadPool
createWorker, destroyWorker, execute, execute, getName, getThreadGroup
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 
Methods inherited from interface org.apache.excalibur.thread.ThreadPool
execute, execute
 

Field Detail

m_pool

private org.apache.avalon.excalibur.pool.Pool m_pool
The underlying pool.


m_logger

private org.apache.avalon.framework.logger.Logger m_logger
The logger to use for debugging purposes.

Constructor Detail

BasicThreadPool

public BasicThreadPool(java.lang.ThreadGroup threadGroup,
                       java.lang.String name,
                       org.apache.avalon.excalibur.pool.Pool pool)
                throws java.lang.Exception
Create a new ThreadPool with specified capacity.

Parameters:
threadGroup - the thread group used in pool
name - the name of pool (used in naming threads)
pool - the underling pool
Throws:
java.lang.Exception - if unable to create pool
Method Detail

enableLogging

public void enableLogging(org.apache.avalon.framework.logger.Logger logger)
Setup Logging.

Specified by:
enableLogging in interface org.apache.avalon.framework.logger.LogEnabled
Parameters:
logger - the logger

dispose

public void dispose()
Dispose of underlying pool and cleanup resources.

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

newInstance

public java.lang.Object newInstance()
Create new Poolable instance.

Specified by:
newInstance in interface org.apache.avalon.excalibur.pool.ObjectFactory
Returns:
the new Poolable instance

newWorkerThread

protected WorkerThread newWorkerThread(java.lang.String name)
Overide newWorkerThread to provide a WorkerThread that is Poolable and LogEnabled.

Overrides:
newWorkerThread in class AbstractThreadPool
Parameters:
name - the name of WorkerThread
Returns:
the created WorkerThread

decommission

public void decommission(java.lang.Object object)
Specified by:
decommission in interface org.apache.avalon.excalibur.pool.ObjectFactory

getCreatedClass

public java.lang.Class getCreatedClass()
Return the class of poolable instance.

Specified by:
getCreatedClass in interface org.apache.avalon.excalibur.pool.ObjectFactory
Returns:
the class of poolable instance.

execute

public org.apache.excalibur.thread.ThreadControl execute(org.apache.avalon.framework.activity.Executable work)
Run work in separate thread. Return a valid ThreadControl to control work thread.

Parameters:
work - the work to be executed.
Returns:
the ThreadControl

getWorker

protected WorkerThread getWorker()
Retrieve a worker thread from pool.

Specified by:
getWorker in class AbstractThreadPool
Returns:
the worker thread retrieved from pool

releaseWorker

protected void releaseWorker(WorkerThread worker)
Release worker back into pool. FIX ME: do we want to verify if it is interrupted or interrupt the worker thread?

Specified by:
releaseWorker in class AbstractThreadPool
Parameters:
worker - the worker (Should be a SimpleWorkerThread).