org.picocontainer
Interface MutablePicoContainer

All Superinterfaces:
PicoContainer
All Known Implementing Classes:
DefaultLifecyclePicoContainer, DefaultPicoContainer

public interface MutablePicoContainer
extends PicoContainer

This is the core interface for registration of components.

Author:
Paul Hammant, Aslak Hellesøy, Jon Tirsén

Method Summary
 void addChild(MutablePicoContainer child)
          Adds a Child container.
 void addOrderedComponentAdapter(ComponentAdapter componentAdapter)
          Adds a component instance to the container.
 void addParent(MutablePicoContainer parent)
          Adds a Parent container.
 Object registerComponentImplementation(Class componentImplementation)
          Registers a component using the componentImplementation as key.
 Object registerComponentImplementation(Object componentKey, Class componentImplementation)
          Registers a component.
 Object registerComponentImplementation(Object componentKey, Class componentImplementation, Parameter[] parameters)
          Registers a component.
 Object registerComponentInstance(Object componentInstance)
          Registers an arbitrary object, using itself as a key.
 Object registerComponentInstance(Object componentKey, Object componentInstance)
          Registers an arbitrary object as a compoent in the container.
 Object unregisterComponent(Object componentKey)
          Unregisters a component.
 
Methods inherited from interface org.picocontainer.PicoContainer
findComponentAdapter, getChildContainers, getComponentInstance, getComponentInstances, getComponentKeys, getComponentMulticaster, getComponentMulticaster, getParentContainers, hasComponent
 

Method Detail

registerComponentImplementation

public Object registerComponentImplementation(Object componentKey,
                                              Class componentImplementation)
                                       throws PicoRegistrationException
Registers a component.

Parameters:
componentKey - a key that identifies the compoent. Must be unique within the conainer.
componentImplementation - the concrete component class.
Throws:
PicoRegistrationException - if registration fails.

registerComponentImplementation

public Object registerComponentImplementation(Object componentKey,
                                              Class componentImplementation,
                                              Parameter[] parameters)
                                       throws PicoRegistrationException
Registers a component.

Parameters:
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.
Returns:
the key used for registration.
Throws:
PicoRegistrationException - if registration fails.

registerComponentImplementation

public Object registerComponentImplementation(Class componentImplementation)
                                       throws PicoRegistrationException
Registers a component using the componentImplementation as key.

Parameters:
componentImplementation - the concrete component class.
Returns:
the key used for registration.
Throws:
PicoRegistrationException - if registration fails.

registerComponentInstance

public Object registerComponentInstance(Object componentInstance)
                                 throws PicoRegistrationException
Registers an arbitrary object, using itself as a key.

Parameters:
componentInstance -
Returns:
the key used for registration.
Throws:
PicoRegistrationException

registerComponentInstance

public Object registerComponentInstance(Object componentKey,
                                        Object componentInstance)
                                 throws PicoRegistrationException
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.

Parameters:
componentKey - a key that identifies the compoent. Must be unique within the conainer.
componentInstance - an arbitrary object.
Returns:
the key used for registration.
Throws:
PicoRegistrationException - if registration fails.

unregisterComponent

public Object unregisterComponent(Object componentKey)
Unregisters a component.

Parameters:
componentKey - key of the component to unregister.
Returns:
the unregistered component.

addOrderedComponentAdapter

public void addOrderedComponentAdapter(ComponentAdapter componentAdapter)
Adds a component instance to the container. Do not call this method explicitly. It is used by the internals. Use registerComponentInstance(java.lang.Object) instead if you wish to register externally instantiated objects.

Parameters:
componentAdapter - key of the component.

addChild

public void addChild(MutablePicoContainer child)
Adds a Child container. Will also add this instance as a parent to child, so calling addParent(org.picocontainer.MutablePicoContainer) is not necessary.

Parameters:
child - child container.

addParent

public void addParent(MutablePicoContainer parent)
Adds a Parent container. Will also add this instance as a child to parent, so calling addChild(org.picocontainer.MutablePicoContainer) is not necessary.

Parameters:
parent - parent container.


Copyright © 2003 Codehaus. All Rights Reserved.