Package org.picocontainer.behaviors
Class Stored<T>
java.lang.Object
org.picocontainer.behaviors.AbstractBehavior<T>
org.picocontainer.behaviors.Stored<T>
- All Implemented Interfaces:
Serializable,Behavior<T>,ComponentAdapter<T>,ComponentLifecycle<T>,ComponentMonitorStrategy,LifecycleStrategy
- Direct Known Subclasses:
Cached,ThreadCached
- See Also:
-
Nested Class Summary
Nested ClassesNested classes/interfaces inherited from interface org.picocontainer.ComponentAdapter
ComponentAdapter.NOTHING -
Field Summary
Fields inherited from class org.picocontainer.behaviors.AbstractBehavior
delegate -
Constructor Summary
ConstructorsConstructorDescriptionStored(ComponentAdapter<T> delegate, ObjectReference<Stored.Instance<T>> reference) -
Method Summary
Modifier and TypeMethodDescriptionbooleanInvokes delegate hasLifecycle method if the delegate is a Behavior Invokes delegate hasLifecycle method if the delegate is a Behavior Test if a component honors a lifecycle.voiddispose(PicoContainer container) Disposes the cached component instance Invokes delegate dispose method if the delegate is a Behavior Invoke the "dispose" method on the component.voidflush()Flushes the cache.getComponentInstance(PicoContainer container, Type into) Retrieve the component instance.Get a string key descriptor of the component adapter for use in toString()protected StringRetrieves the stored reference.booleanvoidstart(PicoContainer container) Starts the cached component instance Invokes delegate start method if the delegate is a Behavior Invoke the "start" method on the component.voidstop(PicoContainer container) Stops the cached component instance Invokes delegate stop method if the delegate is a Behavior Invoke the "stop" method on the component.Methods inherited from class org.picocontainer.behaviors.AbstractBehavior
accept, changeMonitor, currentMonitor, dispose, findAdapterOfType, getComponentImplementation, getComponentInstance, getComponentKey, getDelegate, hasLifecycle, isLazy, start, stop, toString, verify
-
Constructor Details
-
Stored
-
-
Method Details
-
componentHasLifecycle
public boolean componentHasLifecycle()Description copied from class:AbstractBehaviorInvokes delegate hasLifecycle method if the delegate is a Behavior Test if a component honors a lifecycle.- Specified by:
componentHasLifecyclein interfaceComponentLifecycle<T>- Overrides:
componentHasLifecyclein classAbstractBehavior<T>- Returns:
trueif the component has a lifecycle
-
dispose
Disposes the cached component instance Invokes delegate dispose method if the delegate is a Behavior Invoke the "dispose" method on the component.- Specified by:
disposein interfaceComponentLifecycle<T>- Overrides:
disposein classAbstractBehavior<T>- Parameters:
container- the container to "dispose" the component
-
getStoredObject
Retrieves the stored reference. May be null if it has never been set, or possibly if the reference has been flushed.- Returns:
- the stored object or null.
-
flush
public void flush()Flushes the cache. If the component instance is started is will stop and dispose it before flushing the cache. -
getComponentInstance
Description copied from interface:ComponentAdapterRetrieve the component instance. This method will usually create a new instance each time it is called, but that is not required. For example,Cachedwill always return the same instance.- Specified by:
getComponentInstancein interfaceComponentAdapter<T>- Overrides:
getComponentInstancein classAbstractBehavior<T>- Parameters:
container- thePicoContainer, 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.- Returns:
- the component instance.
- Throws:
PicoCompositionException- if the component has dependencies which could not be resolved, or instantiation of the component lead to an ambiguous situation within the container.
-
getDescriptor
Description copied from interface:ComponentAdapterGet a string key descriptor of the component adapter for use in toString()- Returns:
- the descriptor
-
getLifecycleDescriptor
-
start
Starts the cached component instance Invokes delegate start method if the delegate is a Behavior Invoke the "start" method on the component.- Specified by:
startin interfaceComponentLifecycle<T>- Overrides:
startin classAbstractBehavior<T>- Parameters:
container- the container to "start" the component
-
stop
Stops the cached component instance Invokes delegate stop method if the delegate is a Behavior Invoke the "stop" method on the component.- Specified by:
stopin interfaceComponentLifecycle<T>- Overrides:
stopin classAbstractBehavior<T>- Parameters:
container- the container to "stop" the component
-
isStarted
public boolean isStarted()- Specified by:
isStartedin interfaceComponentLifecycle<T>- Overrides:
isStartedin classAbstractBehavior<T>
-