Package org.picocontainer.containers

# Class TieringPicoContainer

java.lang.Object
org.picocontainer.DefaultPicoContainer
org.picocontainer.containers.TieringPicoContainer

All Implemented Interfaces:
  `Serializable`, `ComponentMonitorStrategy`, `Converting`, `Disposable`, `MutablePicoContainer`, `PicoContainer`, `Startable`

public class TieringPicoContainer extends DefaultPicoContainer

See Also:
  - Serialized Form

## Nested Class Summary

## Nested classes/interfaces inherited from class org.picocontainer.DefaultPicoContainer

`DefaultPicoContainer.KnowsContainerAdapter<T>, DefaultPicoContainer.LateInstance`

## Field Summary

### Fields inherited from class org.picocontainer.DefaultPicoContainer

`componentFactory, componentMonitor, lifecycleStrategy, orderedComponentAdapters`

## Constructor Summary

Constructors
Constructor
Description
`TieringPicoContainer()`
Creates a new container with a `AdaptingBehavior` and no parent container.
`TieringPicoContainer(ComponentFactory componentFactory)`
Creates a new container with a custom ComponentFactory and no parent container.
`TieringPicoContainer(ComponentFactory componentFactory, LifecycleStrategy lifecycleStrategy, PicoContainer parent)`
Creates a new container with a custom ComponentFactory, LifecycleStrategy for instance registration, and a parent container.
`TieringPicoContainer(ComponentFactory componentFactory, LifecycleStrategy lifecycleStrategy, PicoContainer parent, ComponentMonitor componentMonitor)`
`TieringPicoContainer(ComponentMonitor monitor)`
Creates a new container with the AdaptingInjection using a custom ComponentMonitor
`TieringPicoContainer(ComponentMonitor monitor, LifecycleStrategy lifecycleStrategy, PicoContainer parent)`
Creates a new container with the AdaptingInjection using a custom ComponentMonitor and lifecycle strategy
`TieringPicoContainer(ComponentMonitor monitor, PicoContainer parent)`
Creates a new container with the AdaptingInjection using a custom ComponentMonitor
`TieringPicoContainer(LifecycleStrategy lifecycleStrategy, PicoContainer parent)`
Creates a new container with the AdaptingInjection using a custom lifecycle strategy
`TieringPicoContainer(PicoContainer parent)`
Creates a new container with a (caching) `AdaptingInjection` and a parent container.

## Method Summary

Modifier and Type
Method
Description
`PicoContainer`
`getParent()`
Retrieve the parent container of this container.
`MutablePicoContainer`
`makeChildContainer()`
Make a child container, using both the same implementation of MutablePicoContainer as the parent and identical behaviors as well.

### Methods inherited from class org.picocontainer.DefaultPicoContainer

`accept, addAdapter, addAdapter, addAdapterInternal, addChildContainer, addComponent, addComponent, addConfig, as, change, changeMonitor, currentMonitor, decorateComponent, dispose, getComponent, getComponent, getComponent, getComponent, getComponent, getComponentAdapter, getComponentAdapter, getComponentAdapter, getComponentAdapters, getComponentAdapters, getComponentAdapters, getComponentKeyToAdapterCache, getComponents, getComponents, getConverters, getLifecycleState, getModifiableComponentAdapterList, getName, getOrderedComponentAdapters, instantiateComponentAsIsStartable, potentiallyStartAdapter, removeChildContainer, removeComponent, removeComponentByInstance, setLifecycleState, setName, start, stop, toString`

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

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

## Constructor Details

### TieringPicoContainer

public TieringPicoContainer(ComponentFactory componentFactory, LifecycleStrategy lifecycleStrategy, PicoContainer parent)
Creates a new container with a custom ComponentFactory, LifecycleStrategy for instance registration, and a parent container. Important note about caching: If you intend the components to be cached, you should pass in a factory that creates `Cached` instances, such as for example `Caching`. Caching can delegate to other ComponentAdapterFactories.

Parameters:
  `componentFactory` - the factory to use for creation of ComponentAdapters.
  `lifecycleStrategy` - the lifecycle strategy chosen for registered instance (not implementations!)
  `parent` - the parent container (used for component dependency lookups).

### TieringPicoContainer

public TieringPicoContainer(ComponentFactory componentFactory, LifecycleStrategy lifecycleStrategy, PicoContainer parent, ComponentMonitor componentMonitor)

### TieringPicoContainer

public TieringPicoContainer(ComponentMonitor monitor, PicoContainer parent)
Creates a new container with the AdaptingInjection using a custom ComponentMonitor

Parameters:
  `monitor` - the ComponentMonitor to use
  `parent` - the parent container (used for component dependency lookups).

### TieringPicoContainer

public TieringPicoContainer(ComponentMonitor monitor, LifecycleStrategy lifecycleStrategy, PicoContainer parent)
Creates a new container with the AdaptingInjection using a custom ComponentMonitor and lifecycle strategy

Parameters:
  `monitor` - the ComponentMonitor to use
  `lifecycleStrategy` - the lifecycle strategy to use.
  `parent` - the parent container (used for component dependency lookups).

### TieringPicoContainer

public TieringPicoContainer(LifecycleStrategy lifecycleStrategy, PicoContainer parent)
Creates a new container with the AdaptingInjection using a custom lifecycle strategy

Parameters:
  `lifecycleStrategy` - the lifecycle strategy to use.
  `parent` - the parent container (used for component dependency lookups).

### TieringPicoContainer

public TieringPicoContainer(ComponentFactory componentFactory)
Creates a new container with a custom ComponentFactory and no parent container.

Parameters:
  `componentFactory` - the ComponentFactory to use.

### TieringPicoContainer

public TieringPicoContainer(ComponentMonitor monitor)
Creates a new container with the AdaptingInjection using a custom ComponentMonitor

Parameters:
  `monitor` - the ComponentMonitor to use

### TieringPicoContainer

public TieringPicoContainer(PicoContainer parent)
Creates a new container with a (caching) `AdaptingInjection` and a parent container.

Parameters:
  `parent` - the parent container (used for component dependency lookups).

### TieringPicoContainer

public TieringPicoContainer()
Creates a new container with a `AdaptingBehavior` and no parent container.

## Method Details

### getParent

public PicoContainer getParent()
Description copied from class: `DefaultPicoContainer`
Retrieve the parent container of this container.

Specified by:
  `getParent` in interface `PicoContainer`
Overrides:
  `getParent` in class `DefaultPicoContainer`
Returns:
  a `PicoContainer` instance, or `null` if this container does not have a parent.

### makeChildContainer

public MutablePicoContainer makeChildContainer()
Description copied from interface: `MutablePicoContainer`
Make a child container, using both the same implementation of MutablePicoContainer as the parent and identical behaviors as well. It will have a reference to this as parent. This will list the resulting MPC as a child. Lifecycle events will be cascaded from parent to child as a consequence of this.

Note that for long-lived parent containers, you need to unregister child containers made with this call before disposing or you will leak memory. (Experience speaking here! )

Incorrect Example:

       MutablePicoContainer parent = new PicoBuilder().withCaching().withLifecycle().build();
       MutablePicoContainer child = parent.makeChildContainer();
       child = null; //Child still retains in memory because parent still holds reference.

Correct Example:

       MutablePicoContainer parent = new PicoBuilder().withCaching().withLifecycle().build();
       MutablePicoContainer child = parent.makeChildContainer();
       parent.removeChildContainer(child); //Remove the bi-directional references.
       child = null;

Specified by:
  `makeChildContainer` in interface `MutablePicoContainer`
Overrides:
  `makeChildContainer` in class `DefaultPicoContainer`
Returns:
  the new child container.