public class DecoratingComponentAdapter extends java.lang.Object implements ComponentAdapter, ComponentMonitorStrategy, LifecycleManager, LifecycleStrategy, java.io.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.
| Modifier and Type | Field and Description |
|---|---|
private ComponentAdapter |
delegate |
| Constructor and Description |
|---|
DecoratingComponentAdapter(ComponentAdapter 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.
|
ComponentMonitor |
currentMonitor()
Returns delegate's current monitor if the delegate supports
a component monitor strategy.
|
void |
dispose(java.lang.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 LifecycleManager
Invoke the "dispose" method on the container's components.
|
java.lang.Class |
getComponentImplementation()
Retrieve the class of the component.
|
java.lang.Object |
getComponentInstance(PicoContainer container)
Retrieve the component instance.
|
java.lang.Object |
getComponentKey()
Retrieve the key associated with the component.
|
ComponentAdapter |
getDelegate() |
private java.lang.String |
getPrintableClassName() |
boolean |
hasLifecycle()
Invokes delegate hasLifecylce method if the delegate is a LifecycleManager
Test if a container's component has a lifecycle.
|
boolean |
hasLifecycle(java.lang.Class type)
Invokes delegate hasLifecylce(Class) method if the delegate is a LifecycleStrategy
Test if a component instance has a lifecycle.
|
void |
start(java.lang.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 LifecycleManager
Invoke the "start" method on the container's components.
|
void |
stop(java.lang.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 LifecycleManager
Invoke the "stop" method on the container's components.
|
java.lang.String |
toString() |
void |
verify(PicoContainer container)
Verify that all dependencies for this adapter can be satisifed.
|
private ComponentAdapter delegate
public DecoratingComponentAdapter(ComponentAdapter delegate)
public java.lang.Object getComponentKey()
ComponentAdaptergetComponentKey in interface ComponentAdapterpublic java.lang.Class getComponentImplementation()
ComponentAdaptergetComponentImplementation in interface ComponentAdapterpublic java.lang.Object getComponentInstance(PicoContainer container) throws PicoInitializationException, PicoIntrospectionException
ComponentAdapterCachingComponentAdapter will always return the
same instance.getComponentInstance in interface ComponentAdaptercontainer - the PicoContainer, that is used to resolve any possible dependencies of the instance.PicoInitializationException - if the component could not be instantiated.PicoIntrospectionException - if the component has dependencies which could not be resolved, or
instantiation of the component lead to an ambigous situation within the
container.public void verify(PicoContainer container) throws PicoIntrospectionException
ComponentAdapterverify in interface ComponentAdaptercontainer - the PicoContainer, that is used to resolve any possible dependencies of the instance.PicoIntrospectionException - if one or more dependencies cannot be resolved.public ComponentAdapter getDelegate()
public void accept(PicoVisitor visitor)
ComponentAdapterPicoContainer, that
cascades the visitor also down to all its ComponentAdapter instances.accept in interface ComponentAdaptervisitor - the visitor.public void changeMonitor(ComponentMonitor monitor)
changeMonitor in interface ComponentMonitorStrategymonitor - the new ComponentMonitor to usepublic ComponentMonitor currentMonitor()
currentMonitor in interface ComponentMonitorStrategyPicoIntrospectionException - if no component monitor is found in delegatepublic void start(PicoContainer container)
start in interface LifecycleManagercontainer - the container to "start" its components' lifecyclepublic void stop(PicoContainer container)
stop in interface LifecycleManagercontainer - the container to "stop" its components' lifecyclepublic void dispose(PicoContainer container)
dispose in interface LifecycleManagercontainer - the container to "dispose" its components' lifecyclepublic boolean hasLifecycle()
hasLifecycle in interface LifecycleManagertrue if the component has a lifecyclepublic void start(java.lang.Object component)
start in interface LifecycleStrategycomponent - the instance of the component to startpublic void stop(java.lang.Object component)
stop in interface LifecycleStrategycomponent - the instance of the component to stoppublic void dispose(java.lang.Object component)
dispose in interface LifecycleStrategycomponent - the instance of the component to disposepublic boolean hasLifecycle(java.lang.Class type)
hasLifecycle in interface LifecycleStrategytype - the component's typetrue if the component has a lifecyclepublic java.lang.String toString()
toString in class java.lang.Objectprivate java.lang.String getPrintableClassName()