|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.picocontainer.adapters.AbstractAdapter<T> org.picocontainer.adapters.InstanceAdapter<T>
public final class InstanceAdapter<T>
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.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.picocontainer.ComponentAdapter |
---|
ComponentAdapter.NOTHING |
Constructor Summary | |
---|---|
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)
|
Method Summary | |
---|---|
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. |
void |
verify(PicoContainer container)
Verify that all dependencies for this adapter can be satisfied. |
Methods inherited from class org.picocontainer.adapters.AbstractAdapter |
---|
accept, changeMonitor, checkTypeCompatibility, currentMonitor, findAdapterOfType, getComponentImplementation, getComponentInstance, getComponentKey, getDelegate, toString |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Constructor Detail |
---|
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)
Method Detail |
---|
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 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 type
true
if the component has a lifecyclepublic boolean isLazy(ComponentAdapter<?> adapter)
LifecycleStrategy
isLazy
in interface LifecycleStrategy
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |