Package org.picocontainer.parameters
Class BasicComponentParameter
- java.lang.Object
-
- org.picocontainer.parameters.AbstractParameter
-
- org.picocontainer.parameters.BasicComponentParameter
-
- All Implemented Interfaces:
java.io.Serializable
,Parameter
- Direct Known Subclasses:
ComponentParameter
public class BasicComponentParameter extends AbstractParameter implements Parameter, java.io.Serializable
A BasicComponentParameter 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. This Parameter will never resolve against a collecting type, that is not directly registered in the PicoContainer itself.- Author:
- Jon Tirsén, Aslak Hellesøy, Jörg Schaible, Thomas Heller
- See Also:
- Serialized Form
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from interface org.picocontainer.Parameter
Parameter.DelegateResolver, Parameter.NotResolved, Parameter.Resolver, Parameter.ValueResolver
-
-
Field Summary
Fields Modifier and Type Field Description static BasicComponentParameter
BASIC_DEFAULT
BASIC_DEFAULT
is an instance of BasicComponentParameter using the default constructor.
-
Constructor Summary
Constructors Constructor Description BasicComponentParameter()
Expect any parameter of the appropriate type.BasicComponentParameter(java.lang.Object componentKey)
Expect a parameter matching a component of a specific key.
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description void
accept(PicoVisitor visitor)
Visit the currentParameter
.static ComponentAdapter<?>
findInjectorOrInstanceAdapter(ComponentAdapter<?> f)
static <T> java.lang.String[]
makeFoundAmbiguousStrings(java.util.Collection<ComponentAdapter<T>> found)
Parameter.Resolver
resolve(PicoContainer container, ComponentAdapter<?> forAdapter, ComponentAdapter<?> injecteeAdapter, java.lang.reflect.Type expectedType, NameBinding expectedNameBinding, boolean useNames, java.lang.annotation.Annotation binding)
Check whether the given Parameter can be satisfied by the container.protected <T> ComponentAdapter<T>
resolveAdapter(PicoContainer container, ComponentAdapter adapter, java.lang.Class<T> expectedType, NameBinding expectedNameBinding, boolean useNames, java.lang.annotation.Annotation binding)
void
verify(PicoContainer container, ComponentAdapter<?> forAdapter, java.lang.reflect.Type expectedType, NameBinding expectedNameBinding, boolean useNames, java.lang.annotation.Annotation binding)
Verify that the Parameter can satisfy the expected type using the container-
Methods inherited from class org.picocontainer.parameters.AbstractParameter
isResolvable, resolveInstance
-
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Methods inherited from interface org.picocontainer.Parameter
isResolvable, resolveInstance
-
-
-
-
Field Detail
-
BASIC_DEFAULT
public static final BasicComponentParameter BASIC_DEFAULT
BASIC_DEFAULT
is an instance of BasicComponentParameter using the default constructor.
-
-
Constructor Detail
-
BasicComponentParameter
public BasicComponentParameter(java.lang.Object componentKey)
Expect a parameter matching a component of a specific key.- Parameters:
componentKey
- the key of the desired addComponent
-
BasicComponentParameter
public BasicComponentParameter()
Expect any parameter of the appropriate type.
-
-
Method Detail
-
resolve
public Parameter.Resolver resolve(PicoContainer container, ComponentAdapter<?> forAdapter, ComponentAdapter<?> injecteeAdapter, java.lang.reflect.Type expectedType, NameBinding expectedNameBinding, boolean useNames, java.lang.annotation.Annotation binding)
Check whether the given Parameter can be satisfied by the container.- Specified by:
resolve
in interfaceParameter
- Parameters:
container
- the container from which dependencies are resolved.forAdapter
- theComponentAdapter
that is asking for the instanceinjecteeAdapter
- the adapter to be injected into (null for N/A)expectedType
- the required typeexpectedNameBinding
- Expected parameter nameuseNames
- should use parameter names for disambiguation- Returns:
true
if the Parameter can be verified.- Throws:
PicoCompositionException
- See Also:
Parameter#isResolvable(PicoContainer, ComponentAdapter, Class, NameBinding ,boolean, Annotation)
-
verify
public void verify(PicoContainer container, ComponentAdapter<?> forAdapter, java.lang.reflect.Type expectedType, NameBinding expectedNameBinding, boolean useNames, java.lang.annotation.Annotation binding)
Description copied from interface:Parameter
Verify that the Parameter can satisfy the expected type using the container- Specified by:
verify
in interfaceParameter
- Parameters:
container
- the container from which dependencies are resolved.forAdapter
- theComponentAdapter
that is asking for the verificationexpectedType
- the required typeexpectedNameBinding
- Expected parameter name
-
accept
public void accept(PicoVisitor visitor)
Visit the currentParameter
.- Specified by:
accept
in interfaceParameter
- Parameters:
visitor
- the visitor.- See Also:
Parameter.accept(org.picocontainer.PicoVisitor)
-
resolveAdapter
protected <T> ComponentAdapter<T> resolveAdapter(PicoContainer container, ComponentAdapter adapter, java.lang.Class<T> expectedType, NameBinding expectedNameBinding, boolean useNames, java.lang.annotation.Annotation binding)
-
makeFoundAmbiguousStrings
public static <T> java.lang.String[] makeFoundAmbiguousStrings(java.util.Collection<ComponentAdapter<T>> found)
-
findInjectorOrInstanceAdapter
public static ComponentAdapter<?> findInjectorOrInstanceAdapter(ComponentAdapter<?> f)
-
-