org.picocontainer
Interface PicoContainer

All Superinterfaces:
Disposable, Lifecycle, Startable, Stoppable
All Known Subinterfaces:
MutablePicoContainer
All Known Implementing Classes:
DefaultPicoContainer

public interface PicoContainer
extends Lifecycle

This is the core interface for PicoContainer. It only has accessor methods. In order to register components in a PicoContainer, use a MutablePicoContainer, such as DefaultPicoContainer.

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

Method Summary
 void addOrderedComponentAdapter(ComponentAdapter componentAdapter)
          Callback method from the implementation to keep track of the instantiation order.
 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()
          Deprecated. We don't need to expose this. The collection can be constructed outside with data from getComponentAdapters().
 PicoContainer getParent()
          Get the parent container of this container.
 boolean hasComponent(Object componentKey)
          Deprecated. We don't need this. Can be determined with getComponentInstance(Object) != null.
 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 interface org.picocontainer.lifecycle.Startable
start
 
Methods inherited from interface org.picocontainer.lifecycle.Stoppable
stop
 
Methods inherited from interface org.picocontainer.lifecycle.Disposable
dispose
 

Method Detail

hasComponent

public boolean hasComponent(Object componentKey)
Deprecated. We don't need this. Can be determined with getComponentInstance(Object) != null.

Checks for the presence of a particular component.

Parameters:
componentKey - key of the component to look for.
Returns:
true if there is a component for this key.

getComponentKeys

public Collection getComponentKeys()
Deprecated. We don't need to expose this. The collection can be constructed outside with data from getComponentAdapters().

Get all the component keys.

Returns:
all the component keys.

getComponentInstance

public Object getComponentInstance(Object componentKey)
                            throws PicoException
Gets a component instance registered with a specific key.

Parameters:
componentKey - key the component was registered with.
Returns:
an instantiated component.
Throws:
PicoException - if the component could not be instantiated or dependencies could not be properly resolved.

getComponentInstanceOfType

public Object getComponentInstanceOfType(Class componentType)
Finds a component instance matching the type, looking in parent if not found in self (unless parent is null).

Parameters:
componentType - type of the component.
Returns:
the adapter matching the class.

getComponentInstances

public List getComponentInstances()
                           throws PicoException
Gets all the registered component instances in the container, (not including those in the parent container). The components are returned in their order of instantiation, which depends on the dependency order between them.

Returns:
all the components.
Throws:
PicoException - if one of the components could not be instantiated or dependencies could not be properly resolved.

getParent

public PicoContainer getParent()
Get the parent container of this container.

Returns:
a Collection of PicoContainer.

verify

public void verify()
            throws PicoVerificationException
Verifies that the dependencies for all the registered components can be satisfied None of the components are instantiated during the verification process.

Throws:
PicoVerificationException - if there are unsatisifiable dependencies.

getComponentAdapter

public ComponentAdapter getComponentAdapter(Object componentKey)
                                     throws PicoIntrospectionException
Finds a ComponentAdapter matching the key, looking in parent if not found in self (unless parent is null).

Parameters:
componentKey - key of the component.
Returns:
the adapter matching the key.
Throws:
PicoIntrospectionException

getComponentAdapterOfType

public ComponentAdapter getComponentAdapterOfType(Class componentType)
Finds a ComponentAdapter matching the type, looking in parent if not found in self (unless parent is null).

Parameters:
componentType - type of the component.
Returns:
the adapter matching the class.

getComponentAdapters

public Collection getComponentAdapters()
Return all adapters (not including the adapters from the parent).

Returns:
Collection of ComponentAdapter.

addOrderedComponentAdapter

public void addOrderedComponentAdapter(ComponentAdapter componentAdapter)
Callback method from the implementation to keep track of the instantiation order. This method is not intended to be called explicitly by clients of the API!



Copyright © 2003-2004 Codehaus. All Rights Reserved.