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`

public class Stored<T> extends AbstractBehavior<T>

See Also:
  - Serialized Form

## Nested Class Summary

Nested Classes
Modifier and Type
Class
Description
`static class`
`Stored.Instance<T>`

## Nested classes/interfaces inherited from interface org.picocontainer.ComponentAdapter

`ComponentAdapter.NOTHING`

## Field Summary

### Fields inherited from class org.picocontainer.behaviors.AbstractBehavior

`delegate`

## Constructor Summary

Constructors
Constructor
Description
`Stored(ComponentAdapter<T> delegate, ObjectReference<Stored.Instance<T>> reference)`

## Method Summary

Modifier and Type
Method
Description
`boolean`
`componentHasLifecycle()`
Invokes 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.
`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, Type into)`
Retrieve the component instance.
`String`
`getDescriptor()`
Get a string key descriptor of the component adapter for use in toString()
`protected String`
`getLifecycleDescriptor()`
`T`
`getStoredObject()`
Retrieves the stored reference.
`boolean`
`isStarted()`
`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, getComponentInstance, getComponentKey, getDelegate, hasLifecycle, isLazy, start, stop, toString, verify`

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait`

## Constructor Details

### Stored

public Stored(ComponentAdapter<T> delegate, ObjectReference<Stored.Instance<T>> reference)

## Method Details

### 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 `ComponentLifecycle<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 `ComponentLifecycle<T>`
Overrides:
  `dispose` in class `AbstractBehavior<T>`
Parameters:
  `container` - the container to "dispose" the component

### getStoredObject

public T 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

public T getComponentInstance(PicoContainer container, Type into) 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.
  `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

public String getDescriptor()
Description copied from interface: `ComponentAdapter`
Get a string key descriptor of the component adapter for use in toString()

Returns:
  the descriptor

### getLifecycleDescriptor

protected String getLifecycleDescriptor()

### 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 `ComponentLifecycle<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 `ComponentLifecycle<T>`
Overrides:
  `stop` in class `AbstractBehavior<T>`
Parameters:
  `container` - the container to "stop" the component

### isStarted

public boolean isStarted()

Specified by:
  `isStarted` in interface `ComponentLifecycle<T>`
Overrides:
  `isStarted` in class `AbstractBehavior<T>`