Class BasicComponentParameter

java.lang.Object
org.picocontainer.parameters.AbstractParameter
org.picocontainer.parameters.BasicComponentParameter
All Implemented Interfaces:
Serializable, Parameter
Direct Known Subclasses:
ComponentParameter

public class BasicComponentParameter extends AbstractParameter implements Parameter, 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:
  • Field Details

    • BASIC_DEFAULT

      public static final BasicComponentParameter BASIC_DEFAULT
      BASIC_DEFAULT is an instance of BasicComponentParameter using the default constructor.
  • Constructor Details

    • BasicComponentParameter

      public BasicComponentParameter(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 Details

    • resolve

      public Parameter.Resolver resolve(PicoContainer container, ComponentAdapter<?> forAdapter, ComponentAdapter<?> injecteeAdapter, Type expectedType, NameBinding expectedNameBinding, boolean useNames, Annotation binding)
      Check whether the given Parameter can be satisfied by the container.
      Specified by:
      resolve in interface Parameter
      Parameters:
      container - the container from which dependencies are resolved.
      forAdapter - the ComponentAdapter that is asking for the instance
      injecteeAdapter - the adapter to be injected into (null for N/A)
      expectedType - the required type
      expectedNameBinding - Expected parameter name
      useNames - should use parameter names for disambiguation
      binding - @return true if the component parameter can be resolved.
      Returns:
      true if the Parameter can be verified.
      See Also:
      • invalid reference
        Parameter#isResolvable(PicoContainer, ComponentAdapter, Class, NameBinding,boolean, Annotation)
    • verify

      public void verify(PicoContainer container, ComponentAdapter<?> forAdapter, Type expectedType, NameBinding expectedNameBinding, boolean useNames, Annotation binding)
      Description copied from interface: Parameter
      Verify that the Parameter can satisfy the expected type using the container
      Specified by:
      verify in interface Parameter
      Parameters:
      container - the container from which dependencies are resolved.
      forAdapter - the ComponentAdapter that is asking for the verification
      expectedType - the required type
      expectedNameBinding - Expected parameter name
      useNames -
      binding -
    • accept

      public void accept(PicoVisitor visitor)
      Visit the current Parameter.
      Specified by:
      accept in interface Parameter
      Parameters:
      visitor - the visitor.
      See Also:
    • resolveAdapter

      protected <T> ComponentAdapter<T> resolveAdapter(PicoContainer container, ComponentAdapter adapter, Class<T> expectedType, NameBinding expectedNameBinding, boolean useNames, Annotation binding)
    • makeFoundAmbiguousStrings

      public static <T> String[] makeFoundAmbiguousStrings(Collection<ComponentAdapter<T>> found)
    • findInjectorOrInstanceAdapter

      public static ComponentAdapter<?> findInjectorOrInstanceAdapter(ComponentAdapter<?> f)