org.picocontainer.defaults
Class ConstantParameter

java.lang.Object
  extended by org.picocontainer.defaults.ConstantParameter
All Implemented Interfaces:
java.io.Serializable, Parameter

public class ConstantParameter
extends java.lang.Object
implements Parameter, java.io.Serializable

A ConstantParameter should be used to pass in "constant" arguments to constructors. This includes Strings,Integers or any other object that is not registered in the container.

Version:
$Revision: 3132 $
Author:
Jon Tirsén, Aslak Hellesøy, Jörg Schaible, Thomas Heller
See Also:
Serialized Form

Field Summary
private  java.lang.Object value
           
 
Constructor Summary
ConstantParameter(java.lang.Object value)
           
 
Method Summary
 void accept(PicoVisitor visitor)
          Visit the current Parameter.
private  boolean checkPrimitive(java.lang.Class expectedType)
           
 boolean isResolvable(PicoContainer container, ComponentAdapter adapter, java.lang.Class expectedType)
          Check if the Parameter can statisfy the expected type using the container.
 java.lang.Object resolveInstance(PicoContainer container, ComponentAdapter adapter, java.lang.Class expectedType)
          Retrieve the object from the Parameter that statisfies the expected type.
 void verify(PicoContainer container, ComponentAdapter adapter, java.lang.Class expectedType)
          Verify that the Parameter can statisfied the expected type using the container
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Field Detail

value

private final java.lang.Object value
Constructor Detail

ConstantParameter

public ConstantParameter(java.lang.Object value)
Method Detail

resolveInstance

public java.lang.Object resolveInstance(PicoContainer container,
                                        ComponentAdapter adapter,
                                        java.lang.Class expectedType)
Description copied from interface: Parameter
Retrieve the object from the Parameter that statisfies the expected type.

Specified by:
resolveInstance in interface Parameter
Parameters:
container - the container from which dependencies are resolved.
adapter - the ComponentAdapter that is asking for the instance
expectedType - the type that the returned instance needs to match.
Returns:
the instance or null if no suitable instance can be found.

isResolvable

public boolean isResolvable(PicoContainer container,
                            ComponentAdapter adapter,
                            java.lang.Class expectedType)
Description copied from interface: Parameter
Check if the Parameter can statisfy the expected type using the container.

Specified by:
isResolvable in interface Parameter
Parameters:
container - the container from which dependencies are resolved.
adapter - the ComponentAdapter that is asking for the instance
expectedType - the required type
Returns:
true if the component parameter can be resolved.

verify

public void verify(PicoContainer container,
                   ComponentAdapter adapter,
                   java.lang.Class expectedType)
            throws PicoException
Verify that the Parameter can statisfied the expected type using the container

Specified by:
verify in interface Parameter
Parameters:
container - the container from which dependencies are resolved.
adapter - the ComponentAdapter that is asking for the verification
expectedType - the required type
Throws:
PicoIntrospectionException - if parameter and its dependencies cannot be resolved
PicoException
See Also:
Parameter.verify(org.picocontainer.PicoContainer, org.picocontainer.ComponentAdapter, java.lang.Class)

accept

public void accept(PicoVisitor visitor)
Visit the current Parameter.

Specified by:
accept in interface Parameter
Parameters:
visitor - the visitor.
See Also:
Parameter.accept(org.picocontainer.PicoVisitor)

checkPrimitive

private boolean checkPrimitive(java.lang.Class expectedType)