org.picocontainer
Interface MutablePicoContainer

All Superinterfaces:
Disposable, PicoContainer, Startable
All Known Implementing Classes:
DefaultPicoContainer

public interface MutablePicoContainer
extends PicoContainer

This is the core interface for registration of components.

Version:
$Revision: 1.26 $
Author:
Paul Hammant, Aslak Hellesøy, Jon Tirsén

Method Summary
 void registerComponent(ComponentAdapter componentAdapter)
          Registers a component via a ComponentAdapter.
 ComponentAdapter registerComponentImplementation(java.lang.Class componentImplementation)
          Registers a component using the componentImplementation as key.
 ComponentAdapter registerComponentImplementation(java.lang.Object componentKey, java.lang.Class componentImplementation)
          Registers a component.
 ComponentAdapter registerComponentImplementation(java.lang.Object componentKey, java.lang.Class componentImplementation, Parameter[] parameters)
          Registers a component.
 ComponentAdapter registerComponentInstance(java.lang.Object componentInstance)
          Registers an arbitrary object, using its class as a key.
 ComponentAdapter registerComponentInstance(java.lang.Object componentKey, java.lang.Object componentInstance)
          Registers an arbitrary object as a compoent in the container.
 void setParent(PicoContainer parent)
          Deprecated. This will probably go away. implementations should take the parent in the constructor (constructor injection!)
 ComponentAdapter unregisterComponent(java.lang.Object componentKey)
          Unregisters a component by key.
 ComponentAdapter unregisterComponentByInstance(java.lang.Object componentInstance)
          Unregisters a component by instance.
 
Methods inherited from interface org.picocontainer.PicoContainer
addOrderedComponentAdapter, getComponentAdapter, getComponentAdapterOfType, getComponentAdapters, getComponentInstance, getComponentInstanceOfType, getComponentInstances, getParent, verify
 
Methods inherited from interface org.picocontainer.Startable
start, stop
 
Methods inherited from interface org.picocontainer.Disposable
dispose
 

Method Detail

registerComponentImplementation

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

Parameters:
componentKey - a key that identifies the compoent. Must be unique within the conainer. The type of the key object has no semantic significance unless explicitly specified in the implementing container.
componentImplementation - the concrete component class.
Returns:
the associated ComponentAdapter.
Throws:
PicoRegistrationException - if registration fails.

registerComponentImplementation

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

Parameters:
componentKey - a key that identifies the compoent. Must be unique within the conainer. The type of the key object has no semantic significance unless explicitly specified in the implementing container.
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 associated ComponentAdapter.
Throws:
PicoRegistrationException - if registration fails.

registerComponentImplementation

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

Parameters:
componentImplementation - the concrete component class.
Returns:
the associated ComponentAdapter.
Throws:
PicoRegistrationException - if registration fails.

registerComponentInstance

public ComponentAdapter registerComponentInstance(java.lang.Object componentInstance)
                                           throws PicoRegistrationException
Registers an arbitrary object, using its class as a key.

Parameters:
componentInstance -
Returns:
the associated ComponentAdapter.
Throws:
PicoRegistrationException - if registration fails.

registerComponentInstance

public ComponentAdapter registerComponentInstance(java.lang.Object componentKey,
                                                  java.lang.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. Beware that too much use of this method is an antipattern.

Parameters:
componentKey - a key that identifies the compoent. 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.
Returns:
the associated ComponentAdapter.
Throws:
PicoRegistrationException - if registration fails.

registerComponent

public void registerComponent(ComponentAdapter componentAdapter)
                       throws PicoRegistrationException
Registers a component via a ComponentAdapter. Use this if you need fine grained control over what ComponentAdapter to use for a specific component.

Parameters:
componentAdapter - the adapter
Throws:
PicoRegistrationException - if registration fails.

unregisterComponent

public ComponentAdapter unregisterComponent(java.lang.Object componentKey)
Unregisters a component by key.

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

unregisterComponentByInstance

public ComponentAdapter unregisterComponentByInstance(java.lang.Object componentInstance)
Unregisters a component by instance.

Parameters:
componentInstance - the component instance to unregister.
Returns:
the associated ComponentAdapter.

setParent

public void setParent(PicoContainer parent)
Deprecated. This will probably go away. implementations should take the parent in the constructor (constructor injection!)

Sets the Parent container.

Parameters:
parent - parent container.


Copyright © 2003-2004 Codehaus. All Rights Reserved.