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, getDelegate
public InstanceAdapter(Object componentKey, T componentInstance, LifecycleStrategy lifecycleStrategy, ComponentMonitor componentMonitor) throws PicoCompositionException
PicoCompositionException
public 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)
ComponentAdapter
Cached
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)
ComponentAdapter
verify
in interface ComponentAdapter<T>
container
- the PicoContainer
, that is used to resolve any possible dependencies of the instance.public String getDescriptor()
ComponentAdapter
getDescriptor
in interface ComponentAdapter<T>
public String toString()
toString
in class AbstractAdapter<T>
Object.toString()
public void start(PicoContainer container)
ComponentLifecycle
start
in interface ComponentLifecycle<T>
container
- the container to "start" the componentpublic void stop(PicoContainer container)
ComponentLifecycle
stop
in interface ComponentLifecycle<T>
container
- the container to "stop" the componentpublic void dispose(PicoContainer container)
ComponentLifecycle
dispose
in interface ComponentLifecycle<T>
container
- the container to "dispose" the componentpublic boolean componentHasLifecycle()
ComponentLifecycle
componentHasLifecycle
in interface ComponentLifecycle<T>
true
if the component has a lifecyclepublic boolean isStarted()
isStarted
in interface ComponentLifecycle<T>
public void start(Object component)
LifecycleStrategy
start
in interface LifecycleStrategy
component
- the instance of the component to startpublic void stop(Object component)
LifecycleStrategy
stop
in interface LifecycleStrategy
component
- the instance of the component to stoppublic void dispose(Object component)
LifecycleStrategy
dispose
in interface LifecycleStrategy
component
- the instance of the component to disposepublic boolean hasLifecycle(Class<?> type)
LifecycleStrategy
hasLifecycle
in interface LifecycleStrategy
type
- the component's typetrue
if the component has a lifecyclepublic boolean isLazy(ComponentAdapter<?> adapter)
LifecycleStrategy
isLazy
in interface LifecycleStrategy
Copyright © 2003–2016 Codehaus. All rights reserved.