|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.picocontainer.defaults.DefaultPicoContainer
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.
Constructor Summary | |
DefaultPicoContainer()
|
|
DefaultPicoContainer(ComponentAdapterFactory componentAdapterFactory)
|
|
DefaultPicoContainer(ComponentAdapterFactory componentAdapterFactory,
PicoContainer parent)
|
|
DefaultPicoContainer(PicoContainer parent)
|
Method Summary | |
void |
addOrderedComponentAdapter(ComponentAdapter componentAdapter)
Callback method from the implementation to keep track of the instantiation order. |
void |
dispose()
|
ComponentAdapter |
getComponentAdapter(Object componentKey)
Finds a ComponentAdapter matching the key, looking in parent if not found in self (unless parent is null). |
ComponentAdapter |
getComponentAdapterOfType(Class componentType)
Finds a ComponentAdapter matching the type, looking in parent if not found in self (unless parent is null). |
Collection |
getComponentAdapters()
Return all adapters (not including the adapters from the parent). |
Object |
getComponentInstance(Object componentKey)
Gets a component instance registered with a specific key. |
Object |
getComponentInstanceOfType(Class componentType)
Finds a component instance matching the type, looking in parent if not found in self (unless parent is null). |
List |
getComponentInstances()
Gets all the registered component instances in the container, (not including those in the parent container). |
Collection |
getComponentKeys()
Get all the component keys. |
PicoContainer |
getParent()
Get the parent container of this container. |
boolean |
hasComponent(Object componentKey)
Checks for the presence of a particular component. |
boolean |
isDisposed()
|
boolean |
isStarted()
|
boolean |
isStopped()
|
void |
registerComponent(ComponentAdapter componentAdapter)
Registers a component via a ComponentAdapter. Use this if you need fine grained control over what ComponentAdapter to use for a specific component. This method can be used to override the ComponentAdapter created by the ComponentAdapterFactory
passed to the constructor of this container. |
ComponentAdapter |
registerComponentImplementation(Class componentImplementation)
Registers a component using the componentImplementation as key. The returned ComponentAdapter will be instantiated by the ComponentAdapterFactory
passed to the container's constructor. |
ComponentAdapter |
registerComponentImplementation(Object componentKey,
Class componentImplementation)
Registers a component. The returned ComponentAdapter will be instantiated by the ComponentAdapterFactory
passed to the container's constructor. |
ComponentAdapter |
registerComponentImplementation(Object componentKey,
Class componentImplementation,
Parameter[] parameters)
Registers a component. The returned ComponentAdapter will be instantiated by the ComponentAdapterFactory
passed to the container's constructor. |
ComponentAdapter |
registerComponentInstance(Object component)
Registers an arbitrary object, using itself as a key. The returned ComponentAdapter will be an InstanceComponentAdapter . |
ComponentAdapter |
registerComponentInstance(Object componentKey,
Object componentInstance)
Registers an arbitrary object as a compoent in the container. This is handy when other components in the same container have dependencies on this kind of object, but where letting the container manage and instantiate it is impossible. The returned ComponentAdapter will be an InstanceComponentAdapter . |
void |
setParent(PicoContainer parent)
Sets the Parent container. |
void |
start()
|
void |
stop()
|
ComponentAdapter |
unregisterComponent(Object componentKey)
Unregisters a component. |
void |
verify()
Verifies that the dependencies for all the registered components can be satisfied None of the components are instantiated during the verification process. |
Methods inherited from class java.lang.Object |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
public DefaultPicoContainer(ComponentAdapterFactory componentAdapterFactory, PicoContainer parent)
public DefaultPicoContainer(PicoContainer parent)
public DefaultPicoContainer(ComponentAdapterFactory componentAdapterFactory)
public DefaultPicoContainer()
Method Detail |
public final Collection getComponentKeys()
PicoContainer
getComponentKeys
in interface PicoContainer
public Collection getComponentAdapters()
PicoContainer
getComponentAdapters
in interface PicoContainer
ComponentAdapter
.public final ComponentAdapter getComponentAdapter(Object componentKey) throws AmbiguousComponentResolutionException
PicoContainer
getComponentAdapter
in interface PicoContainer
componentKey
- key of the component.
AmbiguousComponentResolutionException
public ComponentAdapter getComponentAdapterOfType(Class componentType)
PicoContainer
getComponentAdapterOfType
in interface PicoContainer
componentType
- type of the component.
public void registerComponent(ComponentAdapter componentAdapter) throws DuplicateComponentKeyRegistrationException
ComponentAdapterFactory
passed to the constructor of this container.
registerComponent
in interface MutablePicoContainer
componentAdapter
- the adapter
DuplicateComponentKeyRegistrationException
public ComponentAdapter unregisterComponent(Object componentKey)
MutablePicoContainer
unregisterComponent
in interface MutablePicoContainer
componentKey
- key of the component to unregister.
public ComponentAdapter registerComponentInstance(Object component) throws PicoRegistrationException
InstanceComponentAdapter
.
registerComponentInstance
in interface MutablePicoContainer
component
-
PicoRegistrationException
- if registration fails.public ComponentAdapter registerComponentInstance(Object componentKey, Object componentInstance) throws PicoRegistrationException
InstanceComponentAdapter
.
registerComponentInstance
in interface MutablePicoContainer
componentKey
- a key that identifies the compoent. Must be unique within the conainer.componentInstance
- an arbitrary object.
PicoRegistrationException
- if registration fails.public ComponentAdapter registerComponentImplementation(Class componentImplementation) throws PicoRegistrationException
ComponentAdapterFactory
passed to the container's constructor.
registerComponentImplementation
in interface MutablePicoContainer
componentImplementation
- the concrete component class.
PicoRegistrationException
- if registration fails.public ComponentAdapter registerComponentImplementation(Object componentKey, Class componentImplementation) throws PicoRegistrationException
ComponentAdapterFactory
passed to the container's constructor.
registerComponentImplementation
in interface MutablePicoContainer
componentKey
- a key that identifies the compoent. Must be unique within the conainer.componentImplementation
- the concrete component class.
PicoRegistrationException
- if registration fails.public ComponentAdapter registerComponentImplementation(Object componentKey, Class componentImplementation, Parameter[] parameters) throws PicoRegistrationException
ComponentAdapterFactory
passed to the container's constructor.
registerComponentImplementation
in interface MutablePicoContainer
componentKey
- a key that identifies the compoent. Must be unique within the conainer.componentImplementation
- the concrete component class.parameters
- an array of parameters that gives the container hints about what arguments
to pass to the constructor when it is instantiated.
PicoRegistrationException
- if registration fails.public void addOrderedComponentAdapter(ComponentAdapter componentAdapter)
PicoContainer
addOrderedComponentAdapter
in interface PicoContainer
public List getComponentInstances() throws PicoException
PicoContainer
getComponentInstances
in interface PicoContainer
PicoException
- if one of the components could not be instantiated or dependencies
could not be properly resolved.public Object getComponentInstance(Object componentKey) throws PicoException
PicoContainer
getComponentInstance
in interface PicoContainer
componentKey
- key the component was registered with.
PicoException
- if the component could not be instantiated or dependencies
could not be properly resolved.public Object getComponentInstanceOfType(Class componentType)
PicoContainer
getComponentInstanceOfType
in interface PicoContainer
componentType
- type of the component.
public boolean hasComponent(Object componentKey)
PicoContainer
hasComponent
in interface PicoContainer
componentKey
- key of the component to look for.
public PicoContainer getParent()
PicoContainer
getParent
in interface PicoContainer
PicoContainer
.public void setParent(PicoContainer parent)
MutablePicoContainer
setParent
in interface MutablePicoContainer
parent
- parent container.public void verify() throws PicoVerificationException
PicoContainer
verify
in interface PicoContainer
PicoVerificationException
- if there are unsatisifiable dependencies.public void start()
start
in interface Startable
public void stop()
stop
in interface Stoppable
public void dispose()
dispose
in interface Disposable
public boolean isStarted()
public boolean isStopped()
public boolean isDisposed()
|
|||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |