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, toString
changeMonitor, currentMonitor
private 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)
ComponentAdapter
CachingComponentAdapter
will always return the
same instance.getComponentInstance
in interface ComponentAdapter
container
- the PicoContainer
, that is used to resolve any possible dependencies of the instance.public void verify(PicoContainer container)
ComponentAdapter
verify
in interface ComponentAdapter
container
- the PicoContainer
, that is used to resolve any possible dependencies of the instance.public void start(PicoContainer container)
LifecycleManager
start
in interface LifecycleManager
container
- the container to "start" its components' lifecyclepublic void stop(PicoContainer container)
LifecycleManager
stop
in interface LifecycleManager
container
- the container to "stop" its components' lifecyclepublic void dispose(PicoContainer container)
LifecycleManager
dispose
in interface LifecycleManager
container
- the container to "dispose" its components' lifecyclepublic boolean hasLifecycle()
LifecycleManager
hasLifecycle
in interface LifecycleManager
true
if the component has a lifecyclepublic void start(java.lang.Object component)
LifecycleStrategy
start
in interface LifecycleStrategy
component
- the instance of the component to startpublic void stop(java.lang.Object component)
LifecycleStrategy
stop
in interface LifecycleStrategy
component
- the instance of the component to stoppublic void dispose(java.lang.Object component)
LifecycleStrategy
dispose
in interface LifecycleStrategy
component
- the instance of the component to disposepublic boolean hasLifecycle(java.lang.Class type)
LifecycleStrategy
hasLifecycle
in interface LifecycleStrategy
type
- the component's typetrue
if the component has a lifecycle