|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||
java.lang.Objectorg.picocontainer.defaults.DecoratingComponentAdapter
org.picocontainer.defaults.CachingComponentAdapter
public class CachingComponentAdapter
ComponentAdapter implementation that caches the component instance.
This adapter supports components with a lifecycle, as it is a lifecycle manager
which will apply the delegate's lifecycle strategy to the cached component instance.
The lifecycle state is maintained so that the component instance behaves in the expected way:
it can't be started if already started, it can't be started or stopped if disposed, it can't
be stopped if not started, it can't be disposed if already disposed.
| Field Summary | |
|---|---|
private boolean |
delegateHasLifecylce
|
private boolean |
disposed
|
private ObjectReference |
instanceReference
|
private boolean |
started
|
| Constructor Summary | |
|---|---|
CachingComponentAdapter(ComponentAdapter delegate)
|
|
CachingComponentAdapter(ComponentAdapter delegate,
ObjectReference instanceReference)
|
|
| Method Summary | |
|---|---|
void |
dispose(PicoContainer container)
Disposes the cached component instance Invokes delegate dispose method if the delegate is a LifecycleManager Invoke the "dispose" method on the container's components. |
void |
flush()
Flushes the cache. |
java.lang.Object |
getComponentInstance(PicoContainer container)
Retrieve the component instance. |
boolean |
hasLifecycle()
Invokes delegate hasLifecylce method if the delegate is a LifecycleManager Test if a container's component has a lifecycle. |
void |
start(PicoContainer container)
Starts the cached component instance Invokes delegate start method if the delegate is a LifecycleManager Invoke the "start" method on the container's components. |
void |
stop(PicoContainer container)
Stops the cached component instance Invokes delegate stop method if the delegate is a LifecycleManager Invoke the "stop" method on the container's components. |
| Methods inherited from class org.picocontainer.defaults.DecoratingComponentAdapter |
|---|
accept, changeMonitor, currentMonitor, dispose, getComponentImplementation, getComponentKey, getDelegate, hasLifecycle, start, stop, toString, verify |
| Methods inherited from class java.lang.Object |
|---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait |
| Field Detail |
|---|
private ObjectReference instanceReference
private boolean disposed
private boolean started
private boolean delegateHasLifecylce
| Constructor Detail |
|---|
public CachingComponentAdapter(ComponentAdapter delegate)
public CachingComponentAdapter(ComponentAdapter delegate,
ObjectReference instanceReference)
| Method Detail |
|---|
public java.lang.Object getComponentInstance(PicoContainer container)
throws PicoInitializationException,
PicoIntrospectionException,
AssignabilityRegistrationException,
NotConcreteRegistrationException
ComponentAdapterCachingComponentAdapter will always return the
same instance.
getComponentInstance in interface ComponentAdaptergetComponentInstance in class DecoratingComponentAdaptercontainer - 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.
AssignabilityRegistrationException
NotConcreteRegistrationExceptionpublic void flush()
public void start(PicoContainer container)
start in interface LifecycleManagerstart in class DecoratingComponentAdaptercontainer - the container to "start" its components' lifecyclepublic void stop(PicoContainer container)
stop in interface LifecycleManagerstop in class DecoratingComponentAdaptercontainer - the container to "stop" its components' lifecyclepublic void dispose(PicoContainer container)
dispose in interface LifecycleManagerdispose in class DecoratingComponentAdaptercontainer - the container to "dispose" its components' lifecyclepublic boolean hasLifecycle()
DecoratingComponentAdapter
hasLifecycle in interface LifecycleManagerhasLifecycle in class DecoratingComponentAdaptertrue if the component has a lifecycle
|
||||||||||
| PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
| SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD | |||||||||