public abstract class AbstractDelegatingMutablePicoContainer extends java.lang.Object implements MutablePicoContainer, java.io.Serializable
| Modifier and Type | Field and Description |
|---|---|
private MutablePicoContainer |
delegate |
| Constructor and Description |
|---|
AbstractDelegatingMutablePicoContainer(MutablePicoContainer delegate) |
| Modifier and Type | Method and Description |
|---|---|
void |
accept(PicoVisitor visitor)
Accepts a visitor that should visit the child containers, component adapters and component instances.
|
boolean |
addChildContainer(PicoContainer child)
Add a child container.
|
void |
dispose()
Dispose this component.
|
boolean |
equals(java.lang.Object obj) |
ComponentAdapter |
getComponentAdapter(java.lang.Object componentKey)
Find a component adapter associated with the specified key.
|
ComponentAdapter |
getComponentAdapterOfType(java.lang.Class componentType)
Find a component adapter associated with the specified type.
|
java.util.Collection |
getComponentAdapters()
Retrieve all the component adapters inside this container.
|
java.util.List |
getComponentAdaptersOfType(java.lang.Class componentType)
Retrieve all component adapters inside this container that are associated with the specified type.
|
java.lang.Object |
getComponentInstance(java.lang.Object componentKey)
Retrieve a component instance registered with a specific key.
|
java.lang.Object |
getComponentInstanceOfType(java.lang.Class componentType)
Find a component instance matching the specified type.
|
java.util.List |
getComponentInstances()
Retrieve all the registered component instances in the container, (not including those in the parent container).
|
java.util.List |
getComponentInstancesOfType(java.lang.Class type)
Returns a List of components of a certain componentType.
|
protected MutablePicoContainer |
getDelegate() |
PicoContainer |
getParent()
Retrieve the parent container of this container.
|
ComponentAdapter |
registerComponent(ComponentAdapter componentAdapter)
Register a component via a ComponentAdapter.
|
ComponentAdapter |
registerComponentImplementation(java.lang.Class componentImplementation)
Register a component using the componentImplementation as key.
|
ComponentAdapter |
registerComponentImplementation(java.lang.Object componentKey,
java.lang.Class componentImplementation)
Register a component.
|
ComponentAdapter |
registerComponentImplementation(java.lang.Object componentKey,
java.lang.Class componentImplementation,
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.
|
ComponentAdapter |
registerComponentInstance(java.lang.Object componentInstance)
Register an arbitrary object.
|
ComponentAdapter |
registerComponentInstance(java.lang.Object componentKey,
java.lang.Object componentInstance)
Register an arbitrary object as a component in the container.
|
boolean |
removeChildContainer(PicoContainer child)
Remove a child container from this container.
|
void |
start()
Start this component.
|
void |
stop()
Stop this component.
|
ComponentAdapter |
unregisterComponent(java.lang.Object componentKey)
Unregister a component by key.
|
ComponentAdapter |
unregisterComponentByInstance(java.lang.Object componentInstance)
Unregister a component by instance.
|
void |
verify()
Deprecated.
since 1.1 - Use new VerifyingVisitor().traverse(this)
|
clone, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitmakeChildContainerprivate MutablePicoContainer delegate
public AbstractDelegatingMutablePicoContainer(MutablePicoContainer delegate)
protected MutablePicoContainer getDelegate()
public ComponentAdapter registerComponentImplementation(java.lang.Object componentKey, java.lang.Class componentImplementation) throws PicoRegistrationException
MutablePicoContainerregisterComponentImplementation in interface MutablePicoContainercomponentKey - 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.componentImplementation - the component's implementation class. This must be a concrete class (ie, a
class that can be instantiated).getXXX() methods of the
PicoContainer interface can be used to retrieve a reference to the component later on.PicoRegistrationException - if registration of the component fails.a variant of this method that allows more control
over the parameters passed into the componentImplementation constructor when constructing an instance.public ComponentAdapter registerComponentImplementation(java.lang.Object componentKey, java.lang.Class componentImplementation, Parameter[] parameters) throws PicoRegistrationException
MutablePicoContainernew Parameter[]{new ComponentParameter(), new ComponentParameter("someService"}
The default constructor for the component parameter indicates auto-wiring should take place for
that parameter.
new Parameter[] {}
registerComponentImplementation in interface MutablePicoContainercomponentKey - 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.componentImplementation - the component's implementation class. This must be a concrete class (ie, a
class that can be instantiated).parameters - an array of 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.getXXX() methods of the
PicoContainer interface can be used to retrieve a reference to the component later on.PicoRegistrationException - if registration of the component fails.Parameter,
ConstantParameter,
ComponentParameterpublic ComponentAdapter registerComponentImplementation(java.lang.Class componentImplementation) throws PicoRegistrationException
MutablePicoContainerregisterComponentImplementation(componentImplementation, componentImplementation).registerComponentImplementation in interface MutablePicoContainercomponentImplementation - the concrete component class.getXXX() methods of the
PicoContainer interface can be used to retrieve a reference to the component later on.PicoRegistrationException - if registration fails.public ComponentAdapter registerComponentInstance(java.lang.Object componentInstance) throws PicoRegistrationException
MutablePicoContainerregisterComponentImplementation(componentImplementation, componentImplementation).registerComponentInstance in interface MutablePicoContainergetXXX() methods of the
PicoContainer interface can be used to retrieve a reference to the component later on.PicoRegistrationException - if registration fails.public ComponentAdapter registerComponentInstance(java.lang.Object componentKey, java.lang.Object componentInstance) throws PicoRegistrationException
MutablePicoContainerregisterComponentInstance in interface MutablePicoContainercomponentKey - a key that identifies the component. Must be unique within the conainer. The type of the
key object has no semantic significance unless explicitly specified in the implementing
container.componentInstance - an arbitrary object.getXXX() methods of the
PicoContainer interface can be used to retrieve a reference to the component later on.PicoRegistrationException - if registration fails.public ComponentAdapter registerComponent(ComponentAdapter componentAdapter) throws PicoRegistrationException
MutablePicoContainerregisterComponent in interface MutablePicoContainercomponentAdapter - the adapterPicoRegistrationException - if registration fails.public ComponentAdapter unregisterComponent(java.lang.Object componentKey)
MutablePicoContainerunregisterComponent in interface MutablePicoContainercomponentKey - key of the component to unregister.public ComponentAdapter unregisterComponentByInstance(java.lang.Object componentInstance)
MutablePicoContainerunregisterComponentByInstance in interface MutablePicoContainercomponentInstance - the component instance to unregister.public java.lang.Object getComponentInstance(java.lang.Object componentKey)
PicoContainergetComponentInstance in interface PicoContainercomponentKey - the key that the component was registered with.null if no component has been registered for the specified
key.public java.lang.Object getComponentInstanceOfType(java.lang.Class componentType)
PicoContainergetComponentInstanceOfType in interface PicoContainercomponentType - the type of the componentnull if no component has been registered
with a matching typepublic java.util.List getComponentInstances()
PicoContainergetComponentInstances in interface PicoContainerpublic PicoContainer getParent()
PicoContainergetParent in interface PicoContainerPicoContainer instance, or null if this container does not have a parent.public ComponentAdapter getComponentAdapter(java.lang.Object componentKey)
PicoContainergetComponentAdapter in interface PicoContainercomponentKey - the key that the component was registered with.null if no component has been
registered for the specified key.public ComponentAdapter getComponentAdapterOfType(java.lang.Class componentType)
PicoContainergetComponentAdapterOfType in interface PicoContainercomponentType - the type of the component.null if no component has been
registered for the specified key.public java.util.Collection getComponentAdapters()
PicoContainergetComponentAdapters in interface PicoContainerComponentAdapters inside this container. The collection will not
be modifiable.a variant of this method which returns the component adapters inside this
container that are associated with the specified type.public java.util.List getComponentAdaptersOfType(java.lang.Class componentType)
PicoContainergetComponentAdaptersOfType in interface PicoContainercomponentType - the type of the components.ComponentAdapters inside this container that are associated with
the specified type. Changes to this collection will not be reflected in the container itself.public void verify()
throws PicoVerificationException
PicoContainerverify in interface PicoContainerPicoVerificationException - if there are unsatisifiable dependencies.public void start()
Startablepublic void stop()
StartableDisposable if you need a single call at the definite end of the lifecycle.public void dispose()
Disposabledispose in interface Disposablepublic boolean addChildContainer(PicoContainer child)
MutablePicoContaineraddChildContainer in interface MutablePicoContainerchild - the child containertrue if the child container was not already in.public boolean removeChildContainer(PicoContainer child)
MutablePicoContainerremoveChildContainer in interface MutablePicoContainerchild - the child containertrue if the child container has been removed.public void accept(PicoVisitor visitor)
PicoContaineraccept in interface PicoContainervisitor - the visitorpublic java.util.List getComponentInstancesOfType(java.lang.Class type)
throws PicoException
PicoContainergetComponentInstancesOfType in interface PicoContainertype - the searched type.PicoException - if the instantiation of a component failspublic boolean equals(java.lang.Object obj)
equals in class java.lang.Object