|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object org.picocontainer.behaviors.AbstractBehavior<T>
public abstract class AbstractBehavior<T>
Component adapter which decorates another adapter.
This adapter supports a component monitor strategy
and will propagate change of monitor to the delegate if the delegate itself
support the monitor strategy.
This adapter also supports a lifecycle manager
and a
lifecycle strategy
if the delegate does.
Nested Class Summary |
---|
Nested classes/interfaces inherited from interface org.picocontainer.ComponentAdapter |
---|
ComponentAdapter.NOTHING |
Field Summary | |
---|---|
protected ComponentAdapter<T> |
delegate
|
Constructor Summary | |
---|---|
AbstractBehavior(ComponentAdapter<T> delegate)
|
Method Summary | ||
---|---|---|
void |
accept(PicoVisitor visitor)
Accepts a visitor for this ComponentAdapter. |
|
void |
changeMonitor(ComponentMonitor monitor)
Delegates change of monitor if the delegate supports a component monitor strategy. |
|
boolean |
componentHasLifecycle()
Invokes delegate hasLifecycle method if the delegate is a Behavior Test if a component honors a lifecycle. |
|
ComponentMonitor |
currentMonitor()
Returns delegate's current monitor if the delegate supports a component monitor strategy. |
|
void |
dispose(Object component)
Invokes delegate dispose method if the delegate is a LifecycleStrategy Invoke the "dispose" method on the component instance if this is disposable. |
|
void |
dispose(PicoContainer container)
Invokes delegate dispose method if the delegate is a Behavior Invoke the "dispose" method on the component. |
|
|
findAdapterOfType(Class<U> adapterType)
Locates a component adapter of type componentAdapterType in the ComponentAdapter chain. |
|
Class<T> |
getComponentImplementation()
Retrieve the class of the component. |
|
T |
getComponentInstance(PicoContainer container)
Retrieve the component instance. |
|
T |
getComponentInstance(PicoContainer container,
Type into)
Retrieve the component instance. |
|
Object |
getComponentKey()
Retrieve the key associated with the component. |
|
ComponentAdapter<T> |
getDelegate()
Component adapters may be nested in a chain, and this method is used to grab the next ComponentAdapter in the chain. |
|
boolean |
hasLifecycle(Class<?> type)
Invokes delegate hasLifecycle(Class) method if the delegate is a LifecycleStrategy 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)
Invokes delegate start method if the delegate is a LifecycleStrategy Invoke the "start" method on the component instance if this is startable. |
|
void |
start(PicoContainer container)
Invokes delegate start method if the delegate is a Behavior Invoke the "start" method on the component. |
|
void |
stop(Object component)
Invokes delegate stop method if the delegate is a LifecycleStrategy Invoke the "stop" method on the component instance if this is stoppable. |
|
void |
stop(PicoContainer container)
Invokes delegate stop method if the delegate is a Behavior Invoke the "stop" method on the component. |
|
String |
toString()
|
|
void |
verify(PicoContainer container)
Verify that all dependencies for this adapter can be satisfied. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
Methods inherited from interface org.picocontainer.ComponentAdapter |
---|
getDescriptor |
Field Detail |
---|
protected final ComponentAdapter<T> delegate
Constructor Detail |
---|
public AbstractBehavior(ComponentAdapter<T> delegate)
Method Detail |
---|
public Object getComponentKey()
ComponentAdapter
getComponentKey
in interface ComponentAdapter<T>
public Class<T> getComponentImplementation()
ComponentAdapter
getComponentImplementation
in interface ComponentAdapter<T>
public T getComponentInstance(PicoContainer container) throws PicoCompositionException
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.
PicoCompositionException
- if the component has dependencies which could not be resolved, or
instantiation of the component lead to an ambigous situation within the
container.public T getComponentInstance(PicoContainer container, Type into) throws PicoCompositionException
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.
PicoCompositionException
- if the component has dependencies which could not be resolved, or
instantiation of the component lead to an ambiguous situation within the
container.public void verify(PicoContainer container) throws PicoCompositionException
ComponentAdapter
verify
in interface ComponentAdapter<T>
container
- the PicoContainer
, that is used to resolve any possible dependencies of the instance.
PicoCompositionException
- if one or more dependencies cannot be resolved.public final ComponentAdapter<T> getDelegate()
ComponentAdapter
getDelegate
in interface ComponentAdapter<T>
public final <U extends ComponentAdapter> U findAdapterOfType(Class<U> adapterType)
ComponentAdapter
findAdapterOfType
in interface ComponentAdapter<T>
U
- the type of ComponentAdapter being located.adapterType
- the class of the adapter type being located. Never null.
public void accept(PicoVisitor visitor)
ComponentAdapter
PicoContainer
, that
cascades the visitor also down to all its ComponentAdapter instances.
accept
in interface ComponentAdapter<T>
visitor
- the visitor.public void changeMonitor(ComponentMonitor monitor)
changeMonitor
in interface ComponentMonitorStrategy
monitor
- the new ComponentMonitor to usepublic ComponentMonitor currentMonitor()
currentMonitor
in interface ComponentMonitorStrategy
PicoCompositionException
- if no component monitor is found in delegatepublic void start(PicoContainer container)
start
in interface ComponentLifecycle<T>
container
- the container to "start" the componentpublic void stop(PicoContainer container)
stop
in interface ComponentLifecycle<T>
container
- the container to "stop" the componentpublic void dispose(PicoContainer container)
dispose
in interface ComponentLifecycle<T>
container
- the container to "dispose" the componentpublic boolean componentHasLifecycle()
componentHasLifecycle
in interface ComponentLifecycle<T>
true
if the component has a lifecyclepublic boolean isStarted()
isStarted
in interface ComponentLifecycle<T>
public void start(Object component)
start
in interface LifecycleStrategy
component
- the instance of the component to startpublic void stop(Object component)
stop
in interface LifecycleStrategy
component
- the instance of the component to stoppublic void dispose(Object component)
dispose
in interface LifecycleStrategy
component
- the instance of the component to disposepublic boolean hasLifecycle(Class<?> type)
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
public String toString()
toString
in class Object
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |