org.picocontainer.defaults
Class ComponentParameter

java.lang.Object
  extended byorg.picocontainer.defaults.ComponentParameter
All Implemented Interfaces:
Parameter, Serializable

public class ComponentParameter
extends Object
implements Parameter, Serializable

A ComponentParameter should be used to pass in a particular component as argument to a different component's constructor. This is particularly useful in cases where several components of the same type have been registered, but with a different key. Passing a ComponentParameter as a parameter when registering a component will give PicoContainer a hint about what other component to use in the constructor.

Version:
$Revision: 1.18 $
Author:
Jon Tirsén, Aslak Hellesøy
See Also:
Serialized Form

Constructor Summary
ComponentParameter()
          Expect any paramter of the appropriate type.
ComponentParameter(Object componentKey)
          Expect a parameter matching a component of a specific key.
 
Method Summary
 ComponentAdapter resolveAdapter(PicoContainer picoContainer, Class expectedType)
          Retrieve the component adapter that should be used to find the instance to be passed in for this parameter.
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

ComponentParameter

public ComponentParameter(Object componentKey)
Expect a parameter matching a component of a specific key.

Parameters:
componentKey - the key of the desired component

ComponentParameter

public ComponentParameter()
Expect any paramter of the appropriate type.

Method Detail

resolveAdapter

public ComponentAdapter resolveAdapter(PicoContainer picoContainer,
                                       Class expectedType)
                                throws PicoIntrospectionException
Description copied from interface: Parameter
Retrieve the component adapter that should be used to find the instance to be passed in for this parameter.

Specified by:
resolveAdapter in interface Parameter
Parameters:
picoContainer - the container from which dependencies are resolved.
expectedType - the type that the returned adapter needs to provide.
Returns:
the component adapter that should be used to find the instance to be passed in for this parameter. Should return null if not suitable adapter can be found.
Throws:
PicoIntrospectionException


Copyright © 2003-2004 Codehaus. All Rights Reserved.