org.picocontainer.gems.adapters
Class ThreadLocalComponentAdapter

java.lang.Object
  extended by org.picocontainer.defaults.DecoratingComponentAdapter
      extended by org.picocontainer.gems.adapters.ThreadLocalComponentAdapter
All Implemented Interfaces:
Serializable, ComponentAdapter, ComponentMonitorStrategy, LifecycleStrategy, LifecycleManager

public class ThreadLocalComponentAdapter
extends DecoratingComponentAdapter

A ComponentAdapter that realizes a ThreadLocal component instance.

The adapter creates proxy instances, that will create the necessary instances on-the-fly invoking the methods of the instance. Use this adapter, if you are instantiating your components in a single thread, but should be different when accessed from different threads. See ThreadLocalComponentAdapterFactory for details.

Note: Because this implementation uses a Proxy, you can only access the methods exposed by the implemented interfaces of your component.

Author:
Jörg Schaible
See Also:
Serialized Form

Constructor Summary
ThreadLocalComponentAdapter(ComponentAdapter delegate)
          Construct a ThreadLocalComponentAdapter using Proxy instances.
ThreadLocalComponentAdapter(ComponentAdapter delegate, ProxyFactory proxyFactory)
          Construct a ThreadLocalComponentAdapter.
 
Method Summary
 Object getComponentInstance(PicoContainer pico)
           
 
Methods inherited from class org.picocontainer.defaults.DecoratingComponentAdapter
accept, changeMonitor, currentMonitor, dispose, dispose, getComponentImplementation, getComponentKey, getDelegate, hasLifecycle, hasLifecycle, start, start, stop, stop, toString, verify
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ThreadLocalComponentAdapter

public ThreadLocalComponentAdapter(ComponentAdapter delegate,
                                   ProxyFactory proxyFactory)
                            throws PicoIntrospectionException
Construct a ThreadLocalComponentAdapter.

Parameters:
delegate - The ComponentAdapter to delegate.
proxyFactory - The ProxyFactory to use.
Throws:
PicoIntrospectionException - Thrown if the component does not implement any interface.

ThreadLocalComponentAdapter

public ThreadLocalComponentAdapter(ComponentAdapter delegate)
                            throws PicoIntrospectionException
Construct a ThreadLocalComponentAdapter using Proxy instances.

Parameters:
delegate - The ComponentAdapter to delegate.
Throws:
PicoIntrospectionException - Thrown if the component does not implement any interface.
Method Detail

getComponentInstance

public Object getComponentInstance(PicoContainer pico)
                            throws PicoInitializationException,
                                   PicoIntrospectionException,
                                   AssignabilityRegistrationException,
                                   NotConcreteRegistrationException
Specified by:
getComponentInstance in interface ComponentAdapter
Overrides:
getComponentInstance in class DecoratingComponentAdapter
Throws:
PicoInitializationException
PicoIntrospectionException
AssignabilityRegistrationException
NotConcreteRegistrationException


Copyright © 2003-2010 Codehaus. All Rights Reserved.