| java.lang.Object org.picocontainer.DefaultPicoContainer
All known Subclasses: org.picocontainer.containers.TransientPicoContainer,
DefaultPicoContainer | public class DefaultPicoContainer implements MutablePicoContainer,ComponentMonitorStrategy,Serializable(Code) | |
The Standard
PicoContainer /
MutablePicoContainer implementation.
Constructing a container c with a parent p container will cause c to look up components
in p if they cannot be found inside c itself.
Using
Class objects as keys to the various registerXXX() methods makes
a subtle semantic difference:
If there are more than one registered components of the same type and one of them are
registered with a
java.lang.Class key of the corresponding type, this addComponent
will take precedence over other components during type resolution.
Another place where keys that are classes make a subtle difference is in
HiddenImplementation .
This implementation of
MutablePicoContainer also supports
ComponentMonitorStrategy .
author: Paul Hammant author: Aslak Hellesøy author: Jon Tirsén author: Thomas Heller author: Mauro Talevi |
Constructor Summary | |
public | DefaultPicoContainer(ComponentFactory componentFactory, PicoContainer parent) Creates a new container with a custom ComponentFactory 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 . | public | DefaultPicoContainer(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 . | public | DefaultPicoContainer(ComponentFactory componentFactory, LifecycleStrategy lifecycleStrategy, PicoContainer parent, ComponentMonitor componentMonitor) | public | DefaultPicoContainer(ComponentMonitor monitor, PicoContainer parent) | public | DefaultPicoContainer(ComponentMonitor monitor, LifecycleStrategy lifecycleStrategy, PicoContainer parent) | public | DefaultPicoContainer(LifecycleStrategy lifecycleStrategy, PicoContainer parent) | public | DefaultPicoContainer(ComponentFactory componentFactory) Creates a new container with a custom ComponentFactory and no parent container. | public | DefaultPicoContainer(ComponentMonitor monitor) | public | DefaultPicoContainer(PicoContainer parent) Creates a new container with a (caching)
AdaptingInjection and a parent container. | public | DefaultPicoContainer() Creates a new container with a
AdaptingBehavior and no parent container. |
Method Summary | |
public void | accept(PicoVisitor visitor) | public MutablePicoContainer | addAdapter(ComponentAdapter> componentAdapter) This method can be used to override the ComponentAdapter created by the
ComponentFactory passed to the constructor of this container. | public MutablePicoContainer | addAdapter(ComponentAdapter> componentAdapter, Properties properties) | protected MutablePicoContainer | addAdapterInternal(ComponentAdapter> componentAdapter) | public MutablePicoContainer | addChildContainer(PicoContainer child) | public MutablePicoContainer | addComponent(Object implOrInstance) The returned ComponentAdapter will be an
org.picocontainer.adapters.InstanceAdapter . | public MutablePicoContainer | addComponent(Object componentKey, Object componentImplementationOrInstance, Parameter... parameters) The returned ComponentAdapter will be instantiated by the
ComponentFactory passed to the container's constructor. | public MutablePicoContainer | addConfig(String name, Object val) | public MutablePicoContainer | as(Properties... properties) | public MutablePicoContainer | change(Properties... properties) | public void | changeMonitor(ComponentMonitor monitor) Changes monitor in the ComponentFactory, the component adapters
and the child containers, if these support a ComponentMonitorStrategy. | public ComponentMonitor | currentMonitor() Returns the first current monitor found in the ComponentFactory, the component adapters
and the child containers, if these support a ComponentMonitorStrategy. | public void | dispose() Dispose the components of this PicoContainer and all its logical child containers. | public Object | getComponent(Object componentKeyOrType) | public Object | getComponent(Object componentKeyOrType, Class<? extends Annotation> annotation) | public T | getComponent(Class<T> componentType) | public T | getComponent(Class<T> componentType, Class<? extends Annotation> binding) | final public ComponentAdapter> | getComponentAdapter(Object componentKey) | public ComponentAdapter<T> | getComponentAdapter(Class<T> componentType, NameBinding componentNameBinding) | public ComponentAdapter<T> | getComponentAdapter(Class<T> componentType, Class<? extends Annotation> binding) | public Collection<ComponentAdapter<?>> | getComponentAdapters() | public List<ComponentAdapter<T>> | getComponentAdapters(Class<T> componentType) | public List<ComponentAdapter<T>> | getComponentAdapters(Class<T> componentType, Class<? extends Annotation> binding) | protected Map<Object, ComponentAdapter<?>> | getComponentKeyToAdapterCache() | public List<Object> | getComponents() | public List<T> | getComponents(Class<T> componentType) | protected List<ComponentAdapter<?>> | getModifiableComponentAdapterList() | protected List<ComponentAdapter<?>> | getOrderedComponentAdapters() | public PicoContainer | getParent() | public MutablePicoContainer | makeChildContainer() | public boolean | removeChildContainer(PicoContainer child) | public ComponentAdapter<T> | removeComponent(Object componentKey) | public ComponentAdapter<T> | removeComponentByInstance(T componentInstance) | public void | start() Start the components of this PicoContainer and all its logical child containers.
The starting of the child container is only attempted if the parent
container start successfully. | public void | stop() Stop the components of this PicoContainer and all its logical child containers. |
DefaultPicoContainer | public DefaultPicoContainer(ComponentFactory componentFactory, PicoContainer parent)(Code) | | Creates a new container with a custom ComponentFactory 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. Parameters: parent - the parent container (used for component dependency lookups). |
DefaultPicoContainer | public DefaultPicoContainer(ComponentFactory componentFactory, LifecycleStrategy lifecycleStrategy, PicoContainer parent)(Code) | | 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. Parameters: lifecycleStrategy - the lifecycle strategy chosen for registeredinstance (not implementations!) Parameters: parent - the parent container (used for component dependency lookups). |
DefaultPicoContainer | public DefaultPicoContainer(ComponentMonitor monitor, PicoContainer parent)(Code) | | Creates a new container with the AdaptingInjection using a
custom ComponentMonitor
Parameters: monitor - the ComponentMonitor to use Parameters: parent - the parent container (used for component dependency lookups). |
DefaultPicoContainer | public DefaultPicoContainer(ComponentMonitor monitor, LifecycleStrategy lifecycleStrategy, PicoContainer parent)(Code) | | Creates a new container with the AdaptingInjection using a
custom ComponentMonitor and lifecycle strategy
Parameters: monitor - the ComponentMonitor to use Parameters: lifecycleStrategy - the lifecycle strategy to use. Parameters: parent - the parent container (used for component dependency lookups). |
DefaultPicoContainer | public DefaultPicoContainer(LifecycleStrategy lifecycleStrategy, PicoContainer parent)(Code) | | Creates a new container with the AdaptingInjection using a
custom lifecycle strategy
Parameters: lifecycleStrategy - the lifecycle strategy to use. Parameters: parent - the parent container (used for component dependency lookups). |
DefaultPicoContainer | public DefaultPicoContainer(ComponentFactory componentFactory)(Code) | | Creates a new container with a custom ComponentFactory and no parent container.
Parameters: componentFactory - the ComponentFactory to use. |
DefaultPicoContainer | public DefaultPicoContainer(ComponentMonitor monitor)(Code) | | Creates a new container with the AdaptingInjection using a
custom ComponentMonitor
Parameters: monitor - the ComponentMonitor to use |
DefaultPicoContainer | public DefaultPicoContainer(PicoContainer parent)(Code) | | Creates a new container with a (caching)
AdaptingInjection and a parent container.
Parameters: parent - the parent container (used for component dependency lookups). |
DefaultPicoContainer | public DefaultPicoContainer()(Code) | | Creates a new container with a
AdaptingBehavior and no parent container.
|
changeMonitor | public void changeMonitor(ComponentMonitor monitor)(Code) | | Changes monitor in the ComponentFactory, the component adapters
and the child containers, if these support a ComponentMonitorStrategy.
|
currentMonitor | public ComponentMonitor currentMonitor()(Code) | | Returns the first current monitor found in the ComponentFactory, the component adapters
and the child containers, if these support a ComponentMonitorStrategy.
throws: PicoCompositionException - if no component monitor is found in container or its children |
getComponent | public T getComponent(Class<T> componentType)(Code) | | |
getModifiableComponentAdapterList | protected List<ComponentAdapter<?>> getModifiableComponentAdapterList()(Code) | | the componentAdapters |
|
|