Package org.picocontainer
Class DefaultPicoContainer
- java.lang.Object
-
- org.picocontainer.DefaultPicoContainer
-
- All Implemented Interfaces:
java.io.Serializable,ComponentMonitorStrategy,Converting,Disposable,MutablePicoContainer,PicoContainer,Startable
- Direct Known Subclasses:
TieringPicoContainer,TransientPicoContainer
public class DefaultPicoContainer extends java.lang.Object implements MutablePicoContainer, Converting, ComponentMonitorStrategy, java.io.Serializable
The StandardPicoContainer/MutablePicoContainerimplementation. 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. UsingClassobjects 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 aClasskey 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 inHiddenImplementation. This implementation ofMutablePicoContaineralso supportsComponentMonitorStrategy.- Author:
- Paul Hammant, Aslak Hellesøy, Jon Tirsén, Thomas Heller, Mauro Talevi
- See Also:
- Serialized Form
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static classDefaultPicoContainer.KnowsContainerAdapter<T>static classDefaultPicoContainer.LateInstance
-
Field Summary
Fields Modifier and Type Field Description protected ComponentFactorycomponentFactoryComponent factory instance.protected ComponentMonitorcomponentMonitorComponent monitor instance.protected LifecycleStrategylifecycleStrategyLifecycle strategy instance.protected java.util.List<ComponentAdapter<?>>orderedComponentAdapters
-
Constructor Summary
Constructors Constructor Description DefaultPicoContainer()Creates a new container with aAdaptingBehaviorand no parent container.DefaultPicoContainer(ComponentFactory componentFactory)Creates a new container with a custom ComponentFactory and no parent container.DefaultPicoContainer(ComponentFactory componentFactory, LifecycleStrategy lifecycleStrategy, PicoContainer parent)Creates a new container with a custom ComponentFactory, LifecycleStrategy for instance registration, and a parent container.DefaultPicoContainer(ComponentFactory componentFactory, LifecycleStrategy lifecycleStrategy, PicoContainer parent, ComponentMonitor componentMonitor)DefaultPicoContainer(ComponentFactory componentFactory, PicoContainer parent)Creates a new container with a custom ComponentFactory and a parent container.DefaultPicoContainer(ComponentMonitor monitor)Creates a new container with the AdaptingInjection using a custom ComponentMonitorDefaultPicoContainer(ComponentMonitor monitor, LifecycleStrategy lifecycleStrategy, PicoContainer parent)Creates a new container with the AdaptingInjection using a custom ComponentMonitor and lifecycle strategyDefaultPicoContainer(ComponentMonitor monitor, PicoContainer parent)Creates a new container with the AdaptingInjection using a custom ComponentMonitorDefaultPicoContainer(LifecycleStrategy lifecycleStrategy, PicoContainer parent)Creates a new container with the AdaptingInjection using a custom lifecycle strategyDefaultPicoContainer(PicoContainer parent)Creates a new container with a (caching)AdaptingInjectionand a parent container.
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaccept(PicoVisitor visitor)Accepts a visitor that should visit the child containers, component adapters and component instances.MutablePicoContaineraddAdapter(ComponentAdapter<?> componentAdapter)Register a component via a ComponentAdapter.MutablePicoContaineraddAdapter(ComponentAdapter<?> componentAdapter, java.util.Properties properties)protected MutablePicoContaineraddAdapterInternal(ComponentAdapter<?> componentAdapter)MutablePicoContaineraddChildContainer(PicoContainer child)Add a child container.MutablePicoContaineraddComponent(java.lang.Object implOrInstance)Register an arbitrary object.MutablePicoContaineraddComponent(java.lang.Object componentKey, java.lang.Object componentImplementationOrInstance, Parameter... parameters)Register a component and creates specific instructions on which constructor to use, along with which components and/or constants to provide as constructor arguments.MutablePicoContaineraddConfig(java.lang.String name, java.lang.Object val)Register a config item.MutablePicoContaineras(java.util.Properties... properties)You can set for the following operation only the characteristic of registration of a component on the fly.MutablePicoContainerchange(java.util.Properties... properties)You can change the characteristic of registration of all subsequent components in this container.voidchangeMonitor(ComponentMonitor monitor)Changes monitor in the ComponentFactory, the component adapters and the child containers, if these support a ComponentMonitorStrategy.ComponentMonitorcurrentMonitor()Returns the first current monitor found in the ComponentFactory, the component adapters and the child containers, if these support a ComponentMonitorStrategy.protected java.lang.ObjectdecorateComponent(java.lang.Object component, ComponentAdapter<?> componentAdapter)This is invoked when getComponent(..) is called.voiddispose()Dispose the components of this PicoContainer and all its logical child containers.<T> TgetComponent(java.lang.Class<T> componentType)Retrieve a component keyed by the component type.<T> TgetComponent(java.lang.Class<T> componentType, java.lang.Class<? extends java.lang.annotation.Annotation> binding)Retrieve a component keyed by the component type and binding type.java.lang.ObjectgetComponent(java.lang.Object componentKeyOrType)Retrieve a component instance registered with a specific key or type.java.lang.ObjectgetComponent(java.lang.Object componentKeyOrType, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)java.lang.ObjectgetComponent(java.lang.Object componentKeyOrType, java.lang.reflect.Type into)<T> ComponentAdapter<T>getComponentAdapter(java.lang.Class<T> componentType, java.lang.Class<? extends java.lang.annotation.Annotation> binding)Find a component adapter associated with the specified type and binding type.<T> ComponentAdapter<T>getComponentAdapter(java.lang.Class<T> componentType, NameBinding componentNameBinding)Find a component adapter associated with the specified type and binding name.ComponentAdapter<?>getComponentAdapter(java.lang.Object componentKey)Find a component adapter associated with the specified key.java.util.Collection<ComponentAdapter<?>>getComponentAdapters()Retrieve all the component adapters inside this container.<T> java.util.List<ComponentAdapter<T>>getComponentAdapters(java.lang.Class<T> componentType)Retrieve all component adapters inside this container that are associated with the specified type.<T> java.util.List<ComponentAdapter<T>>getComponentAdapters(java.lang.Class<T> componentType, java.lang.Class<? extends java.lang.annotation.Annotation> binding)Retrieve all component adapters inside this container that are associated with the specified type and binding type.protected java.util.Map<java.lang.Object,ComponentAdapter<?>>getComponentKeyToAdapterCache()java.util.List<java.lang.Object>getComponents()Retrieve all the registered component instances in the container, (not including those in the parent container).<T> java.util.List<T>getComponents(java.lang.Class<T> componentType)Returns a List of components of a certain componentType.ConvertersgetConverters()If this container has a set of converters, then return it.LifecycleStategetLifecycleState()Allow querying of the current lifecycle state of a MutablePicoContainer.protected java.util.Set<ComponentAdapter<?>>getModifiableComponentAdapterList()java.lang.StringgetName()Retrieve the name set (if any).protected java.util.List<ComponentAdapter<?>>getOrderedComponentAdapters()PicoContainergetParent()Retrieve the parent container of this container.protected voidinstantiateComponentAsIsStartable(ComponentAdapter<?> adapter)MutablePicoContainermakeChildContainer()Make a child container, using both the same implementation of MutablePicoContainer as the parent and identical behaviors as well.protected voidpotentiallyStartAdapter(ComponentAdapter<?> adapter)booleanremoveChildContainer(PicoContainer child)Remove a child container from this container.<T> ComponentAdapter<T>removeComponent(java.lang.Object componentKey)Unregister a component by key.<T> ComponentAdapter<T>removeComponentByInstance(T componentInstance)Unregister a component by instance.voidsetLifecycleState(LifecycleState lifecycleState)To assist ThreadLocal usage, LifecycleState can be set.voidsetName(java.lang.String name)Name the container instance, to assist debugging or other indexing.voidstart()Start the components of this PicoContainer and all its logical child containers.voidstop()Stop the components of this PicoContainer and all its logical child containers.java.lang.StringtoString()
-
-
-
Field Detail
-
componentFactory
protected final ComponentFactory componentFactory
Component factory instance.
-
lifecycleStrategy
protected final LifecycleStrategy lifecycleStrategy
Lifecycle strategy instance.
-
componentMonitor
protected ComponentMonitor componentMonitor
Component monitor instance. Receives event callbacks.
-
orderedComponentAdapters
protected final java.util.List<ComponentAdapter<?>> orderedComponentAdapters
-
-
Constructor Detail
-
DefaultPicoContainer
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 createsCachedinstances, such as for exampleCaching. Caching can delegate to other ComponentAdapterFactories.- Parameters:
componentFactory- the factory to use for creation of ComponentAdapters.parent- the parent container (used for component dependency lookups).
-
DefaultPicoContainer
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 createsCachedinstances, such as for exampleCaching. 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).
-
DefaultPicoContainer
public DefaultPicoContainer(ComponentFactory componentFactory, LifecycleStrategy lifecycleStrategy, PicoContainer parent, ComponentMonitor componentMonitor)
-
DefaultPicoContainer
public DefaultPicoContainer(ComponentMonitor monitor, PicoContainer parent)
Creates a new container with the AdaptingInjection using a custom ComponentMonitor- Parameters:
monitor- the ComponentMonitor to useparent- the parent container (used for component dependency lookups).
-
DefaultPicoContainer
public DefaultPicoContainer(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 uselifecycleStrategy- the lifecycle strategy to use.parent- the parent container (used for component dependency lookups).
-
DefaultPicoContainer
public DefaultPicoContainer(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).
-
DefaultPicoContainer
public DefaultPicoContainer(ComponentFactory componentFactory)
Creates a new container with a custom ComponentFactory and no parent container.- Parameters:
componentFactory- the ComponentFactory to use.
-
DefaultPicoContainer
public DefaultPicoContainer(ComponentMonitor monitor)
Creates a new container with the AdaptingInjection using a custom ComponentMonitor- Parameters:
monitor- the ComponentMonitor to use
-
DefaultPicoContainer
public DefaultPicoContainer(PicoContainer parent)
Creates a new container with a (caching)AdaptingInjectionand a parent container.- Parameters:
parent- the parent container (used for component dependency lookups).
-
DefaultPicoContainer
public DefaultPicoContainer()
Creates a new container with aAdaptingBehaviorand no parent container.
-
-
Method Detail
-
getComponentAdapters
public java.util.Collection<ComponentAdapter<?>> getComponentAdapters()
Retrieve all the component adapters inside this container. The component adapters from the parent container are not returned.- Specified by:
getComponentAdaptersin interfacePicoContainer- Returns:
- a collection containing all the
ComponentAdapters inside this container. The collection will not be modifiable. - See Also:
a variant of this method which returns the component adapters inside this container that are associated with the specified type.
-
getComponentAdapter
public final ComponentAdapter<?> getComponentAdapter(java.lang.Object componentKey)
Find a component adapter associated with the specified key. If a component adapter cannot be found in this container, the parent container (if one exists) will be searched.- Specified by:
getComponentAdapterin interfacePicoContainer- Parameters:
componentKey- the key that the component was registered with.- Returns:
- the component adapter associated with this key, or
nullif no component has been registered for the specified key.
-
getComponentAdapter
public <T> ComponentAdapter<T> getComponentAdapter(java.lang.Class<T> componentType, NameBinding componentNameBinding)
Find a component adapter associated with the specified type and binding name. If a component adapter cannot be found in this container, the parent container (if one exists) will be searched.- Specified by:
getComponentAdapterin interfacePicoContainer- Parameters:
componentType- the type of the component.componentNameBinding- the name binding to use- Returns:
- the component adapter associated with this class, or
nullif no component has been registered for the specified key.
-
getComponentAdapter
public <T> ComponentAdapter<T> getComponentAdapter(java.lang.Class<T> componentType, java.lang.Class<? extends java.lang.annotation.Annotation> binding)
Find a component adapter associated with the specified type and binding type. If a component adapter cannot be found in this container, the parent container (if one exists) will be searched.- Specified by:
getComponentAdapterin interfacePicoContainer- Parameters:
componentType- the type of the component.binding- the typed binding to use- Returns:
- the component adapter associated with this class, or
nullif no component has been registered for the specified key.
-
getComponentAdapters
public <T> java.util.List<ComponentAdapter<T>> getComponentAdapters(java.lang.Class<T> componentType)
Retrieve all component adapters inside this container that are associated with the specified type. The addComponent adapters from the parent container are not returned.- Specified by:
getComponentAdaptersin interfacePicoContainer- Parameters:
componentType- the type of the components.- Returns:
- a collection containing all the
ComponentAdapters inside this container that are associated with the specified type. Changes to this collection will not be reflected in the container itself.
-
getComponentAdapters
public <T> java.util.List<ComponentAdapter<T>> getComponentAdapters(java.lang.Class<T> componentType, java.lang.Class<? extends java.lang.annotation.Annotation> binding)
Retrieve all component adapters inside this container that are associated with the specified type and binding type. The addComponent adapters from the parent container are not returned.- Specified by:
getComponentAdaptersin interfacePicoContainer- Parameters:
componentType- the type of the components.binding- the typed binding to use- Returns:
- a collection containing all the
ComponentAdapters inside this container that are associated with the specified type. Changes to this collection will not be reflected in the container itself.
-
addAdapterInternal
protected MutablePicoContainer addAdapterInternal(ComponentAdapter<?> componentAdapter)
-
addAdapter
public MutablePicoContainer addAdapter(ComponentAdapter<?> componentAdapter)
Register a component via a ComponentAdapter. Use this if you need fine grained control over what ComponentAdapter to use for a specific component. The adapter will be wrapped in whatever behaviors that the the container has been set up with. If you want to bypass that behavior for the adapter you are adding, you should use Characteristics.NONE like so pico.as(Characteristics.NONE).addAdapter(...) This method can be used to override the ComponentAdapter created by theComponentFactorypassed to the constructor of this container.- Specified by:
addAdapterin interfaceMutablePicoContainer- Parameters:
componentAdapter- the adapter- Returns:
- the same instance of MutablePicoContainer
-
addAdapter
public MutablePicoContainer addAdapter(ComponentAdapter<?> componentAdapter, java.util.Properties properties)
-
removeComponent
public <T> ComponentAdapter<T> removeComponent(java.lang.Object componentKey)
Unregister a component by key.- Specified by:
removeComponentin interfaceMutablePicoContainer- Parameters:
componentKey- key of the component to unregister.- Returns:
- the ComponentAdapter that was associated with this component.
-
addComponent
public MutablePicoContainer addComponent(java.lang.Object implOrInstance)
Register an arbitrary object. The class of the object will be used as a key. Calling this method is equivalent to callingaddComponent(componentImplementation, componentImplementation). The returned ComponentAdapter will be anInstanceAdapter.- Specified by:
addComponentin interfaceMutablePicoContainer- Parameters:
implOrInstance- Component implementation or instance- Returns:
- the same instance of MutablePicoContainer
-
addConfig
public MutablePicoContainer addConfig(java.lang.String name, java.lang.Object val)
Description copied from interface:MutablePicoContainerRegister a config item.- Specified by:
addConfigin interfaceMutablePicoContainer- Parameters:
name- the name of the config itemval- the value of the config item- Returns:
- the same instance of MutablePicoContainer
-
addComponent
public MutablePicoContainer addComponent(java.lang.Object componentKey, java.lang.Object componentImplementationOrInstance, Parameter... parameters)
Register a component and creates specific instructions on which constructor to use, along with which components and/or constants to provide as constructor arguments. These "directives" are provided through an array of Parameter objects. Parameter[0] correspondes to the first constructor argument, Parameter[N] corresponds to the N+1th constructor argument.Tips for Parameter usage
- Partial Autowiring: If you have two constructor args to match and you only wish to specify one of the constructors and
let PicoContainer wire the other one, you can use as parameters:
new ComponentParameter(), new ComponentParameter("someService")The default constructor for the component parameter indicates auto-wiring should take place for that parameter. - Force No-Arg constructor usage: If you wish to force a component to be constructed with
the no-arg constructor, use a zero length Parameter array. Ex:
new Parameter[0]-
The returned ComponentAdapter will be instantiated by the
ComponentFactorypassed to the container's constructor.
- Specified by:
addComponentin interfaceMutablePicoContainer- Parameters:
componentKey- a key that identifies the component. Must be unique within the container. The type of the key object has no semantic significance unless explicitly specified in the documentation of the implementing container.componentImplementationOrInstance- the component's implementation class. This must be a concrete class (ie, a class that can be instantiated). Or an intance of the compoent.parameters- the parameters that gives the container hints about what arguments to pass to the constructor when it is instantiated. Container implementations may ignore one or more of these hints.- Returns:
- the same instance of MutablePicoContainer
- See Also:
Parameter,ConstantParameter,ComponentParameter
- Partial Autowiring: If you have two constructor args to match and you only wish to specify one of the constructors and
let PicoContainer wire the other one, you can use as parameters:
-
getComponents
public java.util.List<java.lang.Object> getComponents() throws PicoExceptionDescription copied from interface:PicoContainerRetrieve all the registered component instances in the container, (not including those in the parent container). The components are returned in their order of instantiation, which depends on the dependency order between them.- Specified by:
getComponentsin interfacePicoContainer- Returns:
- all the components.
- Throws:
PicoException- if the instantiation of the component fails
-
getComponents
public <T> java.util.List<T> getComponents(java.lang.Class<T> componentType)
Description copied from interface:PicoContainerReturns a List of components of a certain componentType. The list is ordered by instantiation order, starting with the components instantiated first at the beginning.- Specified by:
getComponentsin interfacePicoContainer- Parameters:
componentType- the searched type.- Returns:
- a List of components.
-
getComponent
public java.lang.Object getComponent(java.lang.Object componentKeyOrType)
Description copied from interface:PicoContainerRetrieve a component instance registered with a specific key or type. If a component cannot be found in this container, the parent container (if one exists) will be searched.- Specified by:
getComponentin interfacePicoContainer- Parameters:
componentKeyOrType- the key or Type that the component was registered with.- Returns:
- an instantiated component, or
nullif no component has been registered for the specified key.
-
getComponent
public java.lang.Object getComponent(java.lang.Object componentKeyOrType, java.lang.reflect.Type into)- Specified by:
getComponentin interfacePicoContainer
-
getComponent
public java.lang.Object getComponent(java.lang.Object componentKeyOrType, java.lang.Class<? extends java.lang.annotation.Annotation> annotation)
-
decorateComponent
protected java.lang.Object decorateComponent(java.lang.Object component, ComponentAdapter<?> componentAdapter)This is invoked when getComponent(..) is called. It allows extendees to decorate a component before it is returned to the caller.- Parameters:
component- the component that will be returned for getComponent(..)componentAdapter- the component adapter that made that component- Returns:
- the component (the same as that passed in by default)
-
getComponent
public <T> T getComponent(java.lang.Class<T> componentType)
Description copied from interface:PicoContainerRetrieve a component keyed by the component type.- Specified by:
getComponentin interfacePicoContainer- Parameters:
componentType- the type of the component- Returns:
- the typed resulting object instance or null if the object does not exist.
-
getComponent
public <T> T getComponent(java.lang.Class<T> componentType, java.lang.Class<? extends java.lang.annotation.Annotation> binding)Description copied from interface:PicoContainerRetrieve a component keyed by the component type and binding type.- Specified by:
getComponentin interfacePicoContainer- Parameters:
componentType- the type of the componentbinding- the binding type of the component- Returns:
- the typed resulting object instance or null if the object does not exist.
-
getParent
public PicoContainer getParent()
Retrieve the parent container of this container.- Specified by:
getParentin interfacePicoContainer- Returns:
- a
PicoContainerinstance, ornullif this container does not have a parent.
-
removeComponentByInstance
public <T> ComponentAdapter<T> removeComponentByInstance(T componentInstance)
Unregister a component by instance.- Specified by:
removeComponentByInstancein interfaceMutablePicoContainer- Parameters:
componentInstance- the component instance to unregister.- Returns:
- the same instance of MutablePicoContainer
-
start
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. The child container for which start is attempted is tracked so that upon stop, only those need to be stopped. The lifecycle operation is delegated to the component adapter, if it is an instance oflifecycle manager. The actuallifecycle strategysupported depends on the concrete implementation of the adapter.- Specified by:
startin interfaceStartable- See Also:
Behavior,LifecycleStrategy,makeChildContainer(),addChildContainer(PicoContainer),removeChildContainer(PicoContainer)
-
stop
public void stop()
Stop the components of this PicoContainer and all its logical child containers. The stopping of the child containers is only attempted for those that have been started, possibly not successfully. The lifecycle operation is delegated to the component adapter, if it is an instance oflifecycle manager. The actuallifecycle strategysupported depends on the concrete implementation of the adapter.- Specified by:
stopin interfaceStartable- See Also:
Behavior,LifecycleStrategy,makeChildContainer(),addChildContainer(PicoContainer),removeChildContainer(PicoContainer)
-
dispose
public void dispose()
Dispose the components of this PicoContainer and all its logical child containers. The lifecycle operation is delegated to the component adapter, if it is an instance oflifecycle manager. The actuallifecycle strategysupported depends on the concrete implementation of the adapter.- Specified by:
disposein interfaceDisposable- See Also:
Behavior,LifecycleStrategy,makeChildContainer(),addChildContainer(PicoContainer),removeChildContainer(PicoContainer)
-
setLifecycleState
public void setLifecycleState(LifecycleState lifecycleState)
Description copied from interface:MutablePicoContainerTo assist ThreadLocal usage, LifecycleState can be set. No need to use this for normal usages.- Specified by:
setLifecycleStatein interfaceMutablePicoContainer- Parameters:
lifecycleState- the lifecyle state to use.
-
makeChildContainer
public MutablePicoContainer makeChildContainer()
Description copied from interface:MutablePicoContainerMake 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:
makeChildContainerin interfaceMutablePicoContainer- Returns:
- the new child container.
-
addChildContainer
public MutablePicoContainer addChildContainer(PicoContainer child)
Description copied from interface:MutablePicoContainerAdd a child container. This action will list the the 'child' as exactly that in the parents scope. It will not change the child's view of a parent. That is determined by the constructor arguments of the child itself. Lifecycle events will be cascaded from parent to child as a consequence of calling this method.- Specified by:
addChildContainerin interfaceMutablePicoContainer- Parameters:
child- the child container- Returns:
- the same instance of MutablePicoContainer
-
removeChildContainer
public boolean removeChildContainer(PicoContainer child)
Description copied from interface:MutablePicoContainerRemove a child container from this container. It will not change the child's view of a parent. Lifecycle event will no longer be cascaded from the parent to the child.- Specified by:
removeChildContainerin interfaceMutablePicoContainer- Parameters:
child- the child container- Returns:
trueif the child container has been removed.
-
change
public MutablePicoContainer change(java.util.Properties... properties)
Description copied from interface:MutablePicoContainerYou can change the characteristic of registration of all subsequent components in this container.- Specified by:
changein interfaceMutablePicoContainer- Returns:
- the same Pico instance with changed properties
-
as
public MutablePicoContainer as(java.util.Properties... properties)
Description copied from interface:MutablePicoContainerYou can set for the following operation only the characteristic of registration of a component on the fly.- Specified by:
asin interfaceMutablePicoContainer- Returns:
- the same Pico instance with temporary properties
-
accept
public void accept(PicoVisitor visitor)
Description copied from interface:PicoContainerAccepts a visitor that should visit the child containers, component adapters and component instances.- Specified by:
acceptin interfacePicoContainer- Parameters:
visitor- the visitor
-
changeMonitor
public void changeMonitor(ComponentMonitor monitor)
Changes monitor in the ComponentFactory, the component adapters and the child containers, if these support a ComponentMonitorStrategy. Changes the component monitor used- Specified by:
changeMonitorin interfaceComponentMonitorStrategy- Parameters:
monitor- the new ComponentMonitor to use
-
currentMonitor
public ComponentMonitor currentMonitor()
Returns the first current monitor found in the ComponentFactory, the component adapters and the child containers, if these support a ComponentMonitorStrategy. Returns the monitor currently used- Specified by:
currentMonitorin interfaceComponentMonitorStrategy- Returns:
- The ComponentMonitor currently used
- Throws:
PicoCompositionException- if no component monitor is found in container or its children
-
potentiallyStartAdapter
protected void potentiallyStartAdapter(ComponentAdapter<?> adapter)
-
instantiateComponentAsIsStartable
protected void instantiateComponentAsIsStartable(ComponentAdapter<?> adapter)
-
getOrderedComponentAdapters
protected java.util.List<ComponentAdapter<?>> getOrderedComponentAdapters()
- Returns:
- the orderedComponentAdapters
-
getComponentKeyToAdapterCache
protected java.util.Map<java.lang.Object,ComponentAdapter<?>> getComponentKeyToAdapterCache()
- Returns:
- the componentKeyToAdapterCache
-
getModifiableComponentAdapterList
protected java.util.Set<ComponentAdapter<?>> getModifiableComponentAdapterList()
- Returns:
- the componentAdapters
-
setName
public void setName(java.lang.String name)
Description copied from interface:MutablePicoContainerName the container instance, to assist debugging or other indexing.- Specified by:
setNamein interfaceMutablePicoContainer- Parameters:
name- the name to call it.
-
toString
public java.lang.String toString()
- Overrides:
toStringin classjava.lang.Object
-
getConverters
public Converters getConverters()
If this container has a set of converters, then return it. If it does not, and the parent (or their parent ..) does, use that If they do not, return a NullObject implementation (ConversNothing)- Specified by:
getConvertersin interfaceConverting- Returns:
- the converters
-
getLifecycleState
public LifecycleState getLifecycleState()
Allow querying of the current lifecycle state of a MutablePicoContainer.- Specified by:
getLifecycleStatein interfaceMutablePicoContainer- Returns:
- the current Lifecycle State.
- See Also:
MutablePicoContainer.getLifecycleState()
-
getName
public java.lang.String getName()
Retrieve the name set (if any).- Specified by:
getNamein interfaceMutablePicoContainer- Returns:
- Retrieve the arbitrary name of the container set by calling
setName. - See Also:
MutablePicoContainer.getName()
-
-