public abstract class AbstractBehavior<T> extends Object implements Behavior<T>, ComponentMonitorStrategy, LifecycleStrategy, Serializable
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.
ComponentAdapter.NOTHING| Modifier and Type | Field and Description |
|---|---|
protected ComponentAdapter<T> |
delegate |
| Constructor and Description |
|---|
AbstractBehavior(ComponentAdapter<T> delegate) |
| Modifier and Type | Method and Description |
|---|---|
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.
|
<U extends ComponentAdapter> |
findAdapterOfType(Class<U> adapterType)
Locates a component adapter of type componentAdapterType in the ComponentAdapter chain.
|
Class<? extends 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.
|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, waitgetDescriptorprotected final ComponentAdapter<T> delegate
public AbstractBehavior(ComponentAdapter<T> delegate)
public Object getComponentKey()
ComponentAdaptergetComponentKey in interface ComponentAdapter<T>public Class<? extends T> getComponentImplementation()
ComponentAdaptergetComponentImplementation in interface ComponentAdapter<T>public T getComponentInstance(PicoContainer container) throws PicoCompositionException
ComponentAdapterCached 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
ComponentAdapterCached 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
ComponentAdapterverify 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()
ComponentAdaptergetDelegate in interface ComponentAdapter<T>public final <U extends ComponentAdapter> U findAdapterOfType(Class<U> adapterType)
ComponentAdapterfindAdapterOfType 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)
ComponentAdapterPicoContainer, 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 ComponentMonitorStrategymonitor - the new ComponentMonitor to usepublic ComponentMonitor currentMonitor()
currentMonitor in interface ComponentMonitorStrategyPicoCompositionException - 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 LifecycleStrategycomponent - the instance of the component to startpublic void stop(Object component)
stop in interface LifecycleStrategycomponent - the instance of the component to stoppublic void dispose(Object component)
dispose in interface LifecycleStrategycomponent - the instance of the component to disposepublic boolean hasLifecycle(Class<?> type)
hasLifecycle in interface LifecycleStrategytype - the component's typetrue if the component has a lifecyclepublic boolean isLazy(ComponentAdapter<?> adapter)
LifecycleStrategyisLazy in interface LifecycleStrategyCopyright © 2003-2014 Codehaus. All Rights Reserved.