org.picocontainer.gems.adapters
Class ThreadLocalized<T>
java.lang.Object
org.picocontainer.behaviors.AbstractBehavior<T>
org.picocontainer.gems.adapters.ThreadLocalized<T>
- All Implemented Interfaces:
- Serializable, Behavior<T>, ComponentAdapter<T>, ComponentLifecycle<T>, ComponentMonitorStrategy, LifecycleStrategy
public final class ThreadLocalized<T>
- extends AbstractBehavior<T>
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 ThreadLocalizing
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
Methods inherited from class org.picocontainer.behaviors.AbstractBehavior |
accept, changeMonitor, componentHasLifecycle, currentMonitor, dispose, dispose, findAdapterOfType, getComponentImplementation, getComponentInstance, getComponentKey, getDelegate, hasLifecycle, isLazy, isStarted, start, start, stop, stop, toString, verify |
ThreadLocalized
public ThreadLocalized(ComponentAdapter<T> delegate,
ProxyFactory proxyFactory)
throws PicoCompositionException
- Construct a ThreadLocalized.
- Parameters:
delegate
- The ComponentAdapter
to delegate.proxyFactory
- The ProxyFactory
to use.
- Throws:
PicoCompositionException
- Thrown if the component does not implement any interface.
ThreadLocalized
public ThreadLocalized(ComponentAdapter<T> delegate)
throws PicoCompositionException
- Construct a ThreadLocalized using
Proxy
instances.
- Parameters:
delegate
- The ComponentAdapter
to delegate.
- Throws:
PicoCompositionException
- Thrown if the component does not implement any interface.
getComponentInstance
public T getComponentInstance(PicoContainer pico,
Type into)
throws PicoCompositionException
- Specified by:
getComponentInstance
in interface ComponentAdapter<T>
- Overrides:
getComponentInstance
in class AbstractBehavior<T>
- Throws:
PicoCompositionException
getDescriptor
public String getDescriptor()
Copyright © 2003-2010 Codehaus. All Rights Reserved.