org.picocontainer.behaviors
Class Stored<T>

java.lang.Object
  extended by org.picocontainer.behaviors.AbstractBehavior<T>
      extended by org.picocontainer.behaviors.Stored<T>
Type Parameters:
T -
All Implemented Interfaces:
Serializable, Behavior<T>, ComponentAdapter<T>, ComponentMonitorStrategy, LifecycleStrategy
Direct Known Subclasses:
Cached, ThreadCached

public abstract class Stored<T>
extends AbstractBehavior<T>

abstract base behaviour for all behaviours wishing to store their component in "awkward places" ( object references )

Author:
Konstantin Pribluda
See Also:
Serialized Form

Field Summary
protected  boolean delegateHasLifecylce
           
protected  boolean disposed
           
protected  ObjectReference<T> instanceReference
           
protected  boolean started
           
 
Fields inherited from class org.picocontainer.behaviors.AbstractBehavior
delegate
 
Constructor Summary
Stored(ComponentAdapter<T> delegate, ObjectReference<T> reference)
           
 
Method Summary
 boolean componentHasLifecycle()
          Invokes delegate hasLifecycle method if the delegate is a Behavior Test if a component honors a lifecycle.
 void dispose(PicoContainer container)
          Disposes the cached component instance Invokes delegate dispose method if the delegate is a Behavior Invoke the "dispose" method on the component.
 void flush()
          Flushes the cache.
 T getComponentInstance(PicoContainer container)
          Retrieve the component instance.
 void start(PicoContainer container)
          Starts the cached component instance Invokes delegate start method if the delegate is a Behavior Invoke the "start" method on the component.
 void stop(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, 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

delegateHasLifecylce

protected final boolean delegateHasLifecylce

disposed

protected boolean disposed

instanceReference

protected final ObjectReference<T> instanceReference

started

protected boolean started
Constructor Detail

Stored

public Stored(ComponentAdapter<T> delegate,
              ObjectReference<T> reference)
Method Detail

componentHasLifecycle

public boolean componentHasLifecycle()
Description copied from class: AbstractBehavior
Invokes delegate hasLifecycle method if the delegate is a Behavior Test if a component honors a lifecycle.

Specified by:
componentHasLifecycle in interface Behavior<T>
Overrides:
componentHasLifecycle in class AbstractBehavior<T>
Returns:
true if the component has a lifecycle

dispose

public void dispose(PicoContainer container)
Disposes the cached component instance Invokes delegate dispose method if the delegate is a Behavior Invoke the "dispose" method on the component.

Specified by:
dispose in interface Behavior<T>
Overrides:
dispose in class AbstractBehavior<T>
Parameters:
container - the container to "dispose" the component

flush

public void flush()
Flushes the cache. If the component instance is started is will stop and dispose it before flushing the cache.


getComponentInstance

public T getComponentInstance(PicoContainer container)
                       throws PicoCompositionException
Description copied from interface: ComponentAdapter
Retrieve the component instance. This method will usually create a new instance each time it is called, but that is not required. For example, Cached will always return the same instance.

Specified by:
getComponentInstance in interface ComponentAdapter<T>
Overrides:
getComponentInstance in class AbstractBehavior<T>
Parameters:
container - the PicoContainer, that is used to resolve any possible dependencies of the instance.
Returns:
the component instance.
Throws:
PicoCompositionException - if the component could not be instantiated.

start

public void start(PicoContainer container)
Starts the cached component instance Invokes delegate start method if the delegate is a Behavior Invoke the "start" method on the component.

Specified by:
start in interface Behavior<T>
Overrides:
start in class AbstractBehavior<T>
Parameters:
container - the container to "start" the component

stop

public void stop(PicoContainer container)
Stops the cached component instance Invokes delegate stop method if the delegate is a Behavior Invoke the "stop" method on the component.

Specified by:
stop in interface Behavior<T>
Overrides:
stop in class AbstractBehavior<T>
Parameters:
container - the container to "stop" the component


Copyright © 2003-2007 Codehaus. All Rights Reserved.