org.picocontainer
Interface ComponentAdapter

All Known Implementing Classes:
AbstractComponentAdapter, DecoratingComponentAdapter

public interface ComponentAdapter

A component adapter is responsible for providing a specific component instance. An instance of an implementation of this interface is used inside a PicoContainer for every registered component or instance. Each ComponentAdapter instance has to have a key which is unique within that container. The key itself is either a class type (normally an interface) or an identifier.

Since:
1.0
Version:
$Revision: 1.16 $
Author:
Jon Tirsén, Paul Hammant, Aslak Hellesøy
See Also:
an extension of the PicoContainer interface which allows you to modify the contents of the container.

Method Summary
 Class getComponentImplementation()
          Retrieve the class of the component.
 Object getComponentInstance()
          Retrieve the component instance.
 Object getComponentKey()
          Retrieve the key associated with the component.
 PicoContainer getContainer()
          Retrieve the container in which the component is registered.
 void setContainer(PicoContainer picoContainer)
          Set the container in which this adapter is registered.
 void verify()
          Verify that all dependencies for this adapter can be satisifed.
 

Method Detail

getComponentKey

public Object getComponentKey()
Retrieve the key associated with the component.

Returns:
the component's key. Should either be a class type (normally an interface) or an identifier that is unique (within the scope of the current PicoContainer).

getComponentImplementation

public Class getComponentImplementation()
Retrieve the class of the component.

Returns:
the component's implementation class. Should normally be a concrete class (ie, a class that can be instantiated).

getComponentInstance

public Object getComponentInstance()
                            throws PicoInitializationException,
                                   PicoIntrospectionException
Retrieve the component instance. This method will usually create a new instance each time it is called, but that is not required. For example, CachingComponentAdapter will always return the same instance.

Returns:
the component instance.
Throws:
PicoInitializationException - if the component could not be instantiated.
PicoIntrospectionException - if the component has dependencies which could not be resolved, or instantiation of the component lead to an ambigous situation within the container.

getContainer

public PicoContainer getContainer()
Retrieve the container in which the component is registered.

Returns:
the container in which the component is registered.

setContainer

public void setContainer(PicoContainer picoContainer)
Set the container in which this adapter is registered. This method will be called once by the container when the adapter is registered in that container. It should usually not be called directly.

Parameters:
picoContainer - the container in which this adapter is registered.

verify

public void verify()
            throws PicoVerificationException
Verify that all dependencies for this adapter can be satisifed. Normally, the adapter should verify this by checking that the associated PicoContainer contains all the needed dependnecies.

Throws:
PicoVerificationException - if one or more dependencies cannot be resolved.


Copyright © 2003-2004 Codehaus. All Rights Reserved.