public interface PicoContainer extends Startable, Disposable
accept(PicoVisitor)
method). In order to register components in a
PicoContainer, use a MutablePicoContainer
, such as DefaultPicoContainer
.Modifier and Type | Method and Description |
---|---|
void |
accept(PicoVisitor visitor)
Accepts a visitor that should visit the child containers, component adapters and component instances.
|
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 componentType)
Returns a List of components of a certain componentType.
|
PicoContainer |
getParent()
Retrieve the parent container of this container.
|
void |
verify()
Deprecated.
since 1.1 - Use "new VerifyingVisitor().traverse(this)"
|
dispose
java.lang.Object getComponentInstance(java.lang.Object componentKey)
componentKey
- the key that the component was registered with.null
if no component has been registered for the specified
key.java.lang.Object getComponentInstanceOfType(java.lang.Class componentType)
componentType
- the type of the componentnull
if no component has been registered
with a matching typePicoException
- if the instantiation of the component failsjava.util.List getComponentInstances()
PicoException
- if the instantiation of the component failsPicoContainer getParent()
PicoContainer
instance, or null
if this container does not have a parent.ComponentAdapter getComponentAdapter(java.lang.Object componentKey)
componentKey
- the key that the component was registered with.null
if no component has been
registered for the specified key.ComponentAdapter getComponentAdapterOfType(java.lang.Class componentType)
componentType
- the type of the component.null
if no component has been
registered for the specified key.java.util.Collection getComponentAdapters()
ComponentAdapter
s 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.
java.util.List getComponentAdaptersOfType(java.lang.Class componentType)
componentType
- the type of the components.ComponentAdapter
s inside this container that are associated with
the specified type. Changes to this collection will not be reflected in the container itself.void verify() throws PicoVerificationException
PicoVerificationException
- if there are unsatisifiable dependencies.java.util.List getComponentInstancesOfType(java.lang.Class componentType)
componentType
- the searched type.PicoException
- if the instantiation of a component failsvoid accept(PicoVisitor visitor)
visitor
- the visitor