public class InstanceComponentAdapter extends AbstractComponentAdapter implements LifecycleManager, LifecycleStrategy
Component adapter which wraps a component instance.
This component adapter supports both a LifecycleManager 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.
| Modifier and Type | Field and Description |
|---|---|
private java.lang.Object |
componentInstance |
private LifecycleStrategy |
lifecycleStrategy |
| Constructor and Description |
|---|
InstanceComponentAdapter(java.lang.Object componentKey,
java.lang.Object componentInstance) |
InstanceComponentAdapter(java.lang.Object componentKey,
java.lang.Object componentInstance,
LifecycleStrategy lifecycleStrategy) |
| Modifier and Type | Method and Description |
|---|---|
void |
dispose(java.lang.Object component)
Invoke the "dispose" method on the component instance if this is disposable.
|
void |
dispose(PicoContainer container)
Invoke the "dispose" method on the container's components.
|
java.lang.Object |
getComponentInstance(PicoContainer container)
Retrieve the component instance.
|
private static java.lang.Class |
getInstanceClass(java.lang.Object componentInstance) |
boolean |
hasLifecycle()
Test if a container's component has a lifecycle.
|
boolean |
hasLifecycle(java.lang.Class type)
Test if a component instance has a lifecycle.
|
void |
start(java.lang.Object component)
Invoke the "start" method on the component instance if this is startable.
|
void |
start(PicoContainer container)
Invoke the "start" method on the container's components.
|
void |
stop(java.lang.Object component)
Invoke the "stop" method on the component instance if this is stoppable.
|
void |
stop(PicoContainer container)
Invoke the "stop" method on the container's components.
|
void |
verify(PicoContainer container)
Verify that all dependencies for this adapter can be satisifed.
|
accept, checkTypeCompatibility, getComponentImplementation, getComponentKey, toStringchangeMonitor, currentMonitorprivate java.lang.Object componentInstance
private LifecycleStrategy lifecycleStrategy
public InstanceComponentAdapter(java.lang.Object componentKey,
java.lang.Object componentInstance)
throws AssignabilityRegistrationException,
NotConcreteRegistrationException
public InstanceComponentAdapter(java.lang.Object componentKey,
java.lang.Object componentInstance,
LifecycleStrategy lifecycleStrategy)
throws AssignabilityRegistrationException,
NotConcreteRegistrationException
private static java.lang.Class getInstanceClass(java.lang.Object componentInstance)
public java.lang.Object getComponentInstance(PicoContainer container)
ComponentAdapterCachingComponentAdapter will always return the
same instance.getComponentInstance in interface ComponentAdaptercontainer - the PicoContainer, that is used to resolve any possible dependencies of the instance.public void verify(PicoContainer container)
ComponentAdapterverify in interface ComponentAdaptercontainer - the PicoContainer, that is used to resolve any possible dependencies of the instance.public void start(PicoContainer container)
LifecycleManagerstart in interface LifecycleManagercontainer - the container to "start" its components' lifecyclepublic void stop(PicoContainer container)
LifecycleManagerstop in interface LifecycleManagercontainer - the container to "stop" its components' lifecyclepublic void dispose(PicoContainer container)
LifecycleManagerdispose in interface LifecycleManagercontainer - the container to "dispose" its components' lifecyclepublic boolean hasLifecycle()
LifecycleManagerhasLifecycle in interface LifecycleManagertrue if the component has a lifecyclepublic void start(java.lang.Object component)
LifecycleStrategystart in interface LifecycleStrategycomponent - the instance of the component to startpublic void stop(java.lang.Object component)
LifecycleStrategystop in interface LifecycleStrategycomponent - the instance of the component to stoppublic void dispose(java.lang.Object component)
LifecycleStrategydispose in interface LifecycleStrategycomponent - the instance of the component to disposepublic boolean hasLifecycle(java.lang.Class type)
LifecycleStrategyhasLifecycle in interface LifecycleStrategytype - the component's typetrue if the component has a lifecycle