|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectorg.picocontainer.defaults.BasicComponentParameter
org.picocontainer.defaults.ComponentParameter
public class ComponentParameter
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. Collecting parameter types are
supported for Array
,Collection
and
Map
.
Field Summary | |
---|---|
static ComponentParameter |
ARRAY
Use ARRAY as Parameter for an Array that must have elements. |
static ComponentParameter |
ARRAY_ALLOW_EMPTY
Use ARRAY_ALLOW_EMPTY as Parameter for an Array that may have no
elements. |
private Parameter |
collectionParameter
|
static ComponentParameter |
DEFAULT
DEFAULT is an instance of ComponentParameter using the default constructor. |
Fields inherited from class org.picocontainer.defaults.BasicComponentParameter |
---|
BASIC_DEFAULT |
Constructor Summary | |
---|---|
|
ComponentParameter()
Expect any scalar paramter of the appropriate type or an Array . |
|
ComponentParameter(boolean emptyCollection)
Expect any scalar paramter of the appropriate type or an Array . |
|
ComponentParameter(java.lang.Class componentValueType,
boolean emptyCollection)
Expect any scalar paramter of the appropriate type or the collecting type Array ,Collection or Map . |
|
ComponentParameter(java.lang.Class componentKeyType,
java.lang.Class componentValueType,
boolean emptyCollection)
Expect any scalar paramter of the appropriate type or the collecting type Array ,Collection or Map . |
|
ComponentParameter(java.lang.Object componentKey)
Expect a parameter matching a component of a specific key. |
private |
ComponentParameter(java.lang.Object componentKey,
Parameter collectionParameter)
|
Method Summary | |
---|---|
void |
accept(PicoVisitor visitor)
Accept the visitor for the current Parameter . |
boolean |
isResolvable(PicoContainer container,
ComponentAdapter adapter,
java.lang.Class expectedType)
Check wether the given Parameter can be statisfied by 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 |
---|
public static final ComponentParameter DEFAULT
DEFAULT
is an instance of ComponentParameter using the default constructor.
public static final ComponentParameter ARRAY
ARRAY
as Parameter
for an Array that must have elements.
public static final ComponentParameter ARRAY_ALLOW_EMPTY
ARRAY_ALLOW_EMPTY
as Parameter
for an Array that may have no
elements.
private final Parameter collectionParameter
Constructor Detail |
---|
public ComponentParameter(java.lang.Object componentKey)
componentKey
- the key of the desired componentpublic ComponentParameter()
Array
.
public ComponentParameter(boolean emptyCollection)
Array
.
Resolve the parameter even if no compoennt is of the array's component type.
emptyCollection
- true
allows an Array to be emptypublic ComponentParameter(java.lang.Class componentValueType, boolean emptyCollection)
Array
,Collection
or Map
.
The components in the collection will be of the specified type.
componentValueType
- the component's type (ignored for an Array)emptyCollection
- true
allows the collection to be emptypublic ComponentParameter(java.lang.Class componentKeyType, java.lang.Class componentValueType, boolean emptyCollection)
Array
,Collection
or Map
.
The components in the collection will be of the specified type and their adapter's key
must have a particular type.
componentKeyType
- the component adapter's key typecomponentValueType
- the component's type (ignored for an Array)emptyCollection
- true
allows the collection to be emptyprivate ComponentParameter(java.lang.Object componentKey, Parameter collectionParameter)
Method Detail |
---|
public java.lang.Object resolveInstance(PicoContainer container, ComponentAdapter adapter, java.lang.Class expectedType)
Parameter
resolveInstance
in interface Parameter
resolveInstance
in class BasicComponentParameter
container
- the container from which dependencies are resolved.adapter
- the ComponentAdapter
that is asking for the instanceexpectedType
- the type that the returned instance needs to match.
null
if no suitable instance can be found.public boolean isResolvable(PicoContainer container, ComponentAdapter adapter, java.lang.Class expectedType)
BasicComponentParameter
isResolvable
in interface Parameter
isResolvable
in class BasicComponentParameter
container
- the container from which dependencies are resolved.adapter
- the ComponentAdapter
that is asking for the instanceexpectedType
- the required type
true
if the Parameter can be verified.Parameter.isResolvable(org.picocontainer.PicoContainer,
org.picocontainer.ComponentAdapter, java.lang.Class)
public void verify(PicoContainer container, ComponentAdapter adapter, java.lang.Class expectedType)
Parameter
verify
in interface Parameter
verify
in class BasicComponentParameter
container
- the container from which dependencies are resolved.adapter
- the ComponentAdapter
that is asking for the verificationexpectedType
- the required typepublic void accept(PicoVisitor visitor)
Parameter
. If internally a
CollectionComponentParameter
is used, it is visited also.
accept
in interface Parameter
accept
in class BasicComponentParameter
visitor
- the visitor.BasicComponentParameter.accept(org.picocontainer.PicoVisitor)
|
||||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | |||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |