Class ConstructorInjection

java.lang.Object
org.picocontainer.injectors.AbstractInjectionFactory
org.picocontainer.injectors.ConstructorInjection
All Implemented Interfaces:
Serializable, ComponentFactory, InjectionFactory
Direct Known Subclasses:
ForgetfulConstructorInjection

public class ConstructorInjection extends AbstractInjectionFactory
A InjectionFactory for constructor injection. The factory creates ConstructorInjector. If there is more than one constructor for the component, the one with the most satisfiable parameters will be used. By default, the choice of constructor for the component in question will be remembered between usages.
Author:
Paul Hammant, Jon Tirsén
See Also:
  • Constructor Details

    • ConstructorInjection

      public ConstructorInjection(boolean rememberChosenConstructor)
      Parameters:
      rememberChosenConstructor - whether 'which constructor?' should be remembered from use to use for the associated injector.
    • ConstructorInjection

      public ConstructorInjection()
      Will remember which constructor to use between usages on the associated Injector.
  • Method Details

    • createComponentAdapter

      public <T> ComponentAdapter<T> createComponentAdapter(ComponentMonitor monitor, LifecycleStrategy lifecycleStrategy, Properties properties, Object componentKey, Class<T> componentImplementation, Parameter... parameters) throws PicoCompositionException
      Description copied from interface: ComponentFactory
      Create a new component adapter based on the specified arguments.
      Parameters:
      monitor - the component monitor
      lifecycleStrategy - te lifecycle strategy
      properties - the component properties
      componentKey - the key to be associated with this adapter. This value should be returned from a call to ComponentAdapter.getComponentKey() on the created adapter.
      componentImplementation - the implementation class to be associated with this adapter. This value should be returned from a call to ComponentAdapter.getComponentImplementation() on the created adapter. Should not be null.
      parameters - additional parameters to use by the component adapter in constructing component instances. These may be used, for example, to make decisions about the arguments passed into the component constructor. These should be considered hints; they may be ignored by some implementations. May be null, and may be of zero length.
      Returns:
      a new component adapter based on the specified arguments. Should not return null.
      Throws:
      PicoCompositionException - if the creation of the component adapter results in a PicoCompositionException.