public class DefaultPicoContainer extends java.lang.Object implements MutablePicoContainer
| Modifier and Type | Class and Description |
|---|---|
static class |
DefaultPicoContainer.InstanceComponentAdapter |
| Constructor and Description |
|---|
DefaultPicoContainer() |
DefaultPicoContainer(PicoContainer parent) |
| Modifier and Type | Method and Description |
|---|---|
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<ComponentAdapter> |
getComponentAdapters()
Retrieve all the component adapters inside this container.
|
java.util.List<ComponentAdapter> |
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.
|
PicoContainer |
getParent()
Retrieve the parent container of this container.
|
<T> T |
getService(java.lang.Class<T> serviceClass) |
ComponentAdapter |
getServiceAdapter(java.lang.String key) |
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.
|
ComponentAdapter |
registerComponentInstance(java.lang.Object component)
Register an arbitrary object.
|
ComponentAdapter |
registerComponentInstance(java.lang.Object componentKey,
java.lang.Object componentInstance)
Register an arbitrary object as a component in the container.
|
void |
release() |
java.lang.String |
toString() |
ComponentAdapter |
unregisterComponent(java.lang.Object componentKey)
Unregister a component by key.
|
public DefaultPicoContainer(PicoContainer parent)
public DefaultPicoContainer()
public java.util.Collection<ComponentAdapter> 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 final 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 void release()
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.List<ComponentAdapter> 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 ComponentAdapter registerComponent(ComponentAdapter componentAdapter)
MutablePicoContainerregisterComponent in interface MutablePicoContainercomponentAdapter - the adapterpublic ComponentAdapter unregisterComponent(java.lang.Object componentKey)
MutablePicoContainerunregisterComponent in interface MutablePicoContainercomponentKey - key of the component 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 <T> T getService(java.lang.Class<T> serviceClass)
public final ComponentAdapter getServiceAdapter(java.lang.String 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 ComponentAdapter registerComponentInstance(java.lang.Object component)
MutablePicoContainerregisterComponentImplementation(componentImplementation, componentImplementation).registerComponentInstance in interface MutablePicoContainergetXXX() methods of the
PicoContainer interface can be used to retrieve a reference to the component later on.public ComponentAdapter registerComponentInstance(java.lang.Object componentKey, java.lang.Object componentInstance)
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.public ComponentAdapter registerComponentImplementation(java.lang.Class componentImplementation)
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.public ComponentAdapter registerComponentImplementation(java.lang.Object componentKey, java.lang.Class componentImplementation)
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.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)
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).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.public PicoContainer getParent()
PicoContainergetParent in interface PicoContainerPicoContainer instance, or null if this container does not have a parent.public java.lang.String toString()
toString in class java.lang.Object