public class ThreadLocalComponentAdapter
extends org.picocontainer.defaults.DecoratingComponentAdapter
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.
Modifier and Type | Class and Description |
---|---|
private static class |
ThreadLocalComponentAdapter.ThreadLocalInvoker |
Modifier and Type | Field and Description |
---|---|
private java.lang.Class[] |
interfaces |
private com.thoughtworks.proxy.ProxyFactory |
proxyFactory |
Constructor and Description |
---|
ThreadLocalComponentAdapter(org.picocontainer.ComponentAdapter delegate)
Construct a ThreadLocalComponentAdapter using
Proxy instances. |
ThreadLocalComponentAdapter(org.picocontainer.ComponentAdapter delegate,
com.thoughtworks.proxy.ProxyFactory proxyFactory)
Construct a ThreadLocalComponentAdapter.
|
Modifier and Type | Method and Description |
---|---|
java.lang.Object |
getComponentInstance(org.picocontainer.PicoContainer pico) |
private java.lang.Class[] |
getInterfaces() |
private transient java.lang.Class[] interfaces
private com.thoughtworks.proxy.ProxyFactory proxyFactory
public ThreadLocalComponentAdapter(org.picocontainer.ComponentAdapter delegate, com.thoughtworks.proxy.ProxyFactory proxyFactory) throws org.picocontainer.PicoIntrospectionException
delegate
- The ComponentAdapter
to delegate.proxyFactory
- The ProxyFactory
to use.org.picocontainer.PicoIntrospectionException
- Thrown if the component does not implement any interface.public ThreadLocalComponentAdapter(org.picocontainer.ComponentAdapter delegate) throws org.picocontainer.PicoIntrospectionException
Proxy
instances.delegate
- The ComponentAdapter
to delegate.org.picocontainer.PicoIntrospectionException
- Thrown if the component does not implement any interface.public java.lang.Object getComponentInstance(org.picocontainer.PicoContainer pico) throws org.picocontainer.PicoInitializationException, org.picocontainer.PicoIntrospectionException, org.picocontainer.defaults.AssignabilityRegistrationException, org.picocontainer.defaults.NotConcreteRegistrationException
getComponentInstance
in interface org.picocontainer.ComponentAdapter
getComponentInstance
in class org.picocontainer.defaults.DecoratingComponentAdapter
org.picocontainer.PicoInitializationException
org.picocontainer.PicoIntrospectionException
org.picocontainer.defaults.AssignabilityRegistrationException
org.picocontainer.defaults.NotConcreteRegistrationException
private final java.lang.Class[] getInterfaces()