org.apache.cocoon.core.container.handler
Class ThreadSafeComponentHandler

java.lang.Object
  extended byorg.apache.cocoon.core.container.handler.AbstractComponentHandler
      extended byorg.apache.cocoon.core.container.handler.AbstractFactoryHandler
          extended byorg.apache.cocoon.core.container.handler.ThreadSafeComponentHandler
All Implemented Interfaces:
ComponentHandler

public class ThreadSafeComponentHandler
extends AbstractFactoryHandler

The ThreadSafeComponentHandler to make sure components are initialized and destroyed correctly.

Since:
2.2
Version:
$Id: ThreadSafeComponentHandler.java 312637 2005-10-10 13:00:42Z cziegeler $

Field Summary
 
Fields inherited from class org.apache.cocoon.core.container.handler.AbstractFactoryHandler
factory
 
Fields inherited from class org.apache.cocoon.core.container.handler.AbstractComponentHandler
disposed, logger
 
Constructor Summary
ThreadSafeComponentHandler(ComponentInfo info, Logger logger, ComponentFactory factory)
          Create a ThreadSafeComponentHandler which manages a single instance of an object return by the component factory.
 
Method Summary
 void dispose()
          Dispose of the ComponentHandler and any associated Pools and Factories.
protected  Object doGet()
          Get a reference of the desired Component
 void doInitialize()
           
protected  void doPut(Object component)
          Return a reference of the desired Component
 boolean isSingleton()
          Default here is to return false
 
Methods inherited from class org.apache.cocoon.core.container.handler.AbstractFactoryHandler
decommission
 
Methods inherited from class org.apache.cocoon.core.container.handler.AbstractComponentHandler
canBeDisposed, get, getComponentHandler, getComponentHandler, getInfo, initialize, put
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ThreadSafeComponentHandler

public ThreadSafeComponentHandler(ComponentInfo info,
                                  Logger logger,
                                  ComponentFactory factory)
Create a ThreadSafeComponentHandler which manages a single instance of an object return by the component factory.

Parameters:
logger - The logger to use
factory - The factory object which is responsible for creating the components managed by the handler.
Method Detail

isSingleton

public boolean isSingleton()
Description copied from class: AbstractComponentHandler
Default here is to return false

Specified by:
isSingleton in interface ComponentHandler
Overrides:
isSingleton in class AbstractComponentHandler

doInitialize

public void doInitialize()
                  throws Exception
Specified by:
doInitialize in class AbstractComponentHandler
Throws:
Exception

doGet

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

Specified by:
doGet in class AbstractComponentHandler
Returns:
a service
Throws:
Exception - if an error occurs

doPut

protected void doPut(Object component)
Return a reference of the desired Component

Specified by:
doPut in class AbstractComponentHandler
Parameters:
component - a Component value

dispose

public void dispose()
Dispose of the ComponentHandler and any associated Pools and Factories.

Specified by:
dispose in interface ComponentHandler
Overrides:
dispose in class AbstractComponentHandler


Copyright ? 1999-2005 The Apache Software Foundation. All Rights Reserved.