org.apache.avalon.fortress.impl.handler
Class PerThreadComponentHandler

java.lang.Object
  extended by org.apache.avalon.framework.logger.AbstractLogEnabled
      extended by org.apache.excalibur.instrument.AbstractLogEnabledInstrumentable
          extended by org.apache.avalon.fortress.impl.handler.AbstractComponentHandler
              extended by org.apache.avalon.fortress.impl.handler.PerThreadComponentHandler
All Implemented Interfaces:
ComponentHandler, org.apache.avalon.framework.activity.Disposable, org.apache.avalon.framework.activity.Initializable, org.apache.avalon.framework.logger.LogEnabled, org.apache.avalon.framework.service.Serviceable, org.apache.excalibur.instrument.Instrumentable

public final class PerThreadComponentHandler
extends AbstractComponentHandler

The PerThreadComponentHandler implements a singleton with a slight difference: one single instance per thread.

Since:
4.0
Author:
Excalibur Development Team

Field Summary
private static java.util.List m_instances
           
private static java.lang.ThreadLocal m_slot
           
 
Fields inherited from class org.apache.avalon.fortress.impl.handler.AbstractComponentHandler
m_disposed, m_factory, m_logger, m_loggerManager, m_prepared
 
Fields inherited from interface org.apache.excalibur.instrument.Instrumentable
EMPTY_INSTRUMENT_ARRAY, EMPTY_INSTRUMENTABLE_ARRAY
 
Constructor Summary
PerThreadComponentHandler()
           
 
Method Summary
protected  void doDispose()
          Dispose handler specific resources.
protected  java.lang.Object doGet()
          Get a reference of the desired Component
 void initialize()
           
 
Methods inherited from class org.apache.avalon.fortress.impl.handler.AbstractComponentHandler
dispose, disposeComponent, doPrepare, doPut, get, getComponentClass, newComponent, prepareHandler, put, service, toString
 
Methods inherited from class org.apache.excalibur.instrument.AbstractLogEnabledInstrumentable
addChildInstrumentable, addInstrument, getChildInstrumentables, getInstrumentableName, getInstruments, setInstrumentableName
 
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, wait, wait, wait
 

Field Detail

m_slot

private static java.lang.ThreadLocal m_slot

m_instances

private static java.util.List m_instances
Constructor Detail

PerThreadComponentHandler

public PerThreadComponentHandler()
Method Detail

initialize

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

doGet

protected java.lang.Object doGet()
                          throws java.lang.Exception
Get a reference of the desired Component

Specified by:
doGet in class AbstractComponentHandler
Returns:
the service
Throws:
java.lang.Exception - if unable to aquire service

doDispose

protected void doDispose()
Description copied from class: AbstractComponentHandler
Dispose handler specific resources. Subclasses should overide this to provide their own funcitonality.

Overrides:
doDispose in class AbstractComponentHandler