public final class InstanceAdapter<T> extends AbstractAdapter<T> implements ComponentLifecycle<T>, LifecycleStrategy
Component adapter which wraps a component instance.
This component adapter supports both a Behavior and a
LifecycleStrategy to control the lifecycle of the component.
The lifecycle manager methods simply delegate to the lifecycle strategy methods
on the component instance.
ComponentAdapter.NOTHING| Constructor and Description |
|---|
InstanceAdapter(Object componentKey,
T componentInstance) |
InstanceAdapter(Object componentKey,
T componentInstance,
ComponentMonitor componentMonitor) |
InstanceAdapter(Object componentKey,
T componentInstance,
LifecycleStrategy lifecycleStrategy) |
InstanceAdapter(Object componentKey,
T componentInstance,
LifecycleStrategy lifecycleStrategy,
ComponentMonitor componentMonitor) |
| Modifier and Type | Method and Description |
|---|---|
boolean |
componentHasLifecycle()
Test if a component honors a lifecycle.
|
void |
dispose(Object component)
Invoke the "dispose" method on the component instance if this is disposable.
|
void |
dispose(PicoContainer container)
Invoke the "dispose" method on the component.
|
T |
getComponentInstance(PicoContainer container,
Type into)
Retrieve the component instance.
|
String |
getDescriptor()
Get a string key descriptor of the component adapter for use in toString()
|
boolean |
hasLifecycle(Class<?> type)
Test if a component instance has a lifecycle.
|
boolean |
isLazy(ComponentAdapter<?> adapter)
Is a component eager (not lazy) in that it should start when start() or equivalent is called,
or lazy (it will only start on first getComponent() ).
|
boolean |
isStarted() |
void |
start(Object component)
Invoke the "start" method on the component instance if this is startable.
|
void |
start(PicoContainer container)
Invoke the "start" method on the component.
|
void |
stop(Object component)
Invoke the "stop" method on the component instance if this is stoppable.
|
void |
stop(PicoContainer container)
Invoke the "stop" method on the component.
|
String |
toString() |
void |
verify(PicoContainer container)
Verify that all dependencies for this adapter can be satisfied.
|
accept, changeMonitor, checkTypeCompatibility, currentMonitor, findAdapterOfType, getComponentImplementation, getComponentInstance, getComponentKey, getDelegatepublic InstanceAdapter(Object componentKey, T componentInstance, LifecycleStrategy lifecycleStrategy, ComponentMonitor componentMonitor) throws PicoCompositionException
PicoCompositionExceptionpublic InstanceAdapter(Object componentKey, T componentInstance)
public InstanceAdapter(Object componentKey, T componentInstance, LifecycleStrategy lifecycleStrategy)
public InstanceAdapter(Object componentKey, T componentInstance, ComponentMonitor componentMonitor)
public T getComponentInstance(PicoContainer container, Type into)
ComponentAdapterCached will always return the
same instance.getComponentInstance in interface ComponentAdapter<T>container - the PicoContainer, that is used to resolve any possible dependencies of the instance.into - the class that is about to be injected into. Use ComponentAdapter.NOTHING.class if this is not important to you.public void verify(PicoContainer container)
ComponentAdapterverify in interface ComponentAdapter<T>container - the PicoContainer, that is used to resolve any possible dependencies of the instance.public String getDescriptor()
ComponentAdaptergetDescriptor in interface ComponentAdapter<T>public String toString()
toString in class AbstractAdapter<T>Object.toString()public void start(PicoContainer container)
ComponentLifecyclestart in interface ComponentLifecycle<T>container - the container to "start" the componentpublic void stop(PicoContainer container)
ComponentLifecyclestop in interface ComponentLifecycle<T>container - the container to "stop" the componentpublic void dispose(PicoContainer container)
ComponentLifecycledispose in interface ComponentLifecycle<T>container - the container to "dispose" the componentpublic boolean componentHasLifecycle()
ComponentLifecyclecomponentHasLifecycle in interface ComponentLifecycle<T>true if the component has a lifecyclepublic boolean isStarted()
isStarted in interface ComponentLifecycle<T>public void start(Object component)
LifecycleStrategystart in interface LifecycleStrategycomponent - the instance of the component to startpublic void stop(Object component)
LifecycleStrategystop in interface LifecycleStrategycomponent - the instance of the component to stoppublic void dispose(Object component)
LifecycleStrategydispose in interface LifecycleStrategycomponent - the instance of the component to disposepublic boolean hasLifecycle(Class<?> type)
LifecycleStrategyhasLifecycle in interface LifecycleStrategytype - the component's typetrue if the component has a lifecyclepublic boolean isLazy(ComponentAdapter<?> adapter)
LifecycleStrategyisLazy in interface LifecycleStrategyCopyright © 2003-2014 Codehaus. All Rights Reserved.