org.picocontainer.injectors
Class Injector

java.lang.Object
  extended by org.picocontainer.injectors.Injector

public class Injector
extends Object

convenience class providing static methods to conveniently create injectors ( like org.junit.Assert )

Author:
Konstantin Pribluda

Constructor Summary
Injector()
           
 
Method Summary
static ComponentAdapter annotatedField(Object key, Class<?> impl, Parameter[] parameters, ComponentMonitor componentMonitor, LifecycleStrategy lifecycleStrategy, Class<? extends Annotation> injectionAnnotation, boolean useNames)
          convenience method to create annotated field injector
static ComponentAdapter annotatedMethod(Object key, Class<?> impl, Parameter[] parameters, ComponentMonitor monitor, LifecycleStrategy lifecycleStrategy, Class<? extends Annotation> injectionAnnotation, boolean useNames)
          convenience method to create annotated method injector
static ComponentAdapter composite(Object componentKey, Class<?> componentImplementation, Parameter[] parameters, ComponentMonitor monitor, LifecycleStrategy lifecycleStrategy, boolean useNames, Injector... injectors)
          creates composite injector
static ComponentAdapter constructor(Object componentKey, Class<?> componentImplementation, Parameter... parameters)
          Constructor injector that uses no monitor and no lifecycle adapter.
static ComponentAdapter constructor(Object componentKey, Class componentImplementation, Parameter[] parameters, ComponentMonitor monitor, LifecycleStrategy lifecycleStrategy, boolean useNames)
          Creates a ConstructorInjector
static ComponentAdapter constructor(Object componentKey, Class componentImplementation, Parameter[] parameters, ComponentMonitor monitor, LifecycleStrategy lifecycleStrategy, boolean useNames, boolean rememberChosenCtor)
          Creates a ConstructorInjector
static ComponentAdapter method(Object componentKey, Class componentImplementation, Parameter[] parameters, ComponentMonitor monitor, LifecycleStrategy lifecycleStrategy, String methodName, boolean useNames)
          convenience method to create method injector
static ComponentAdapter multi(Object componentKey, Class componentImplementation, Parameter[] parameters, ComponentMonitor componentMonitor, LifecycleStrategy lifecycleStrategy, String setterPrefix, boolean useNames)
          convenience method to create multi component adapter
static ComponentAdapter namedField(Object key, Class<?> impl, Parameter[] parameters, ComponentMonitor componentMonitor, LifecycleStrategy lifecycleStrategy, String fieldNames)
          convenience method to create named field injector
static ComponentAdapter setter(Object componentKey, Class componentImplementation, Parameter[] parameters, ComponentMonitor monitor, LifecycleStrategy lifecycleStrategy, String setterMethodPrefix, boolean useNames)
          convenience method to create setter injector
static ComponentAdapter typedField(Object key, Class<?> impl, Parameter[] parameters, ComponentMonitor componentMonitor, LifecycleStrategy lifecycleStrategy, String classNames)
          conveniently create typed field injector
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 

Constructor Detail

Injector

public Injector()
Method Detail

constructor

public static ComponentAdapter constructor(Object componentKey,
                                           Class<?> componentImplementation,
                                           Parameter... parameters)
Constructor injector that uses no monitor and no lifecycle adapter. This is a more convenient constructor for use when instantiating a constructor injector directly.

Parameters:
componentKey - the search key for this implementation
componentImplementation - the concrete implementation
parameters - the parameters used for initialization

constructor

public static ComponentAdapter constructor(Object componentKey,
                                           Class componentImplementation,
                                           Parameter[] parameters,
                                           ComponentMonitor monitor,
                                           LifecycleStrategy lifecycleStrategy,
                                           boolean useNames)
                                    throws AbstractInjector.NotConcreteRegistrationException
Creates a ConstructorInjector

Parameters:
componentKey - the search key for this implementation
componentImplementation - the concrete implementation
parameters - the parameters to use for the initialization
monitor - the component monitor used by this addAdapter
lifecycleStrategy - the component lifecycle strategy used by this addAdapter
useNames - use argument names when looking up dependencies
Throws:
AbstractInjector.NotConcreteRegistrationException - if the implementation is not a concrete class.
NullPointerException - if one of the parameters is null

constructor

public static ComponentAdapter constructor(Object componentKey,
                                           Class componentImplementation,
                                           Parameter[] parameters,
                                           ComponentMonitor monitor,
                                           LifecycleStrategy lifecycleStrategy,
                                           boolean useNames,
                                           boolean rememberChosenCtor)
                                    throws AbstractInjector.NotConcreteRegistrationException
Creates a ConstructorInjector

Parameters:
componentKey - the search key for this implementation
componentImplementation - the concrete implementation
parameters - the parameters to use for the initialization
monitor - the component monitor used by this addAdapter
lifecycleStrategy - the component lifecycle strategy used by this addAdapter
useNames - use argument names when looking up dependencies
rememberChosenCtor - remember the chosen constructor (to speed up second/subsequent calls)
Throws:
AbstractInjector.NotConcreteRegistrationException - if the implementation is not a concrete class.
NullPointerException - if one of the parameters is null

annotatedField

public static ComponentAdapter annotatedField(Object key,
                                              Class<?> impl,
                                              Parameter[] parameters,
                                              ComponentMonitor componentMonitor,
                                              LifecycleStrategy lifecycleStrategy,
                                              Class<? extends Annotation> injectionAnnotation,
                                              boolean useNames)
convenience method to create annotated field injector

Parameters:
key -
impl -
parameters -
componentMonitor -
lifecycleStrategy -
injectionAnnotation -
useNames -
Returns:

annotatedMethod

public static ComponentAdapter annotatedMethod(Object key,
                                               Class<?> impl,
                                               Parameter[] parameters,
                                               ComponentMonitor monitor,
                                               LifecycleStrategy lifecycleStrategy,
                                               Class<? extends Annotation> injectionAnnotation,
                                               boolean useNames)
convenience method to create annotated method injector

Parameters:
key -
impl -
parameters -
monitor -
lifecycleStrategy -
injectionAnnotation -
useNames -
Returns:

composite

public static ComponentAdapter composite(Object componentKey,
                                         Class<?> componentImplementation,
                                         Parameter[] parameters,
                                         ComponentMonitor monitor,
                                         LifecycleStrategy lifecycleStrategy,
                                         boolean useNames,
                                         Injector... injectors)
creates composite injector

Parameters:
componentKey -
componentImplementation -
parameters -
monitor -
lifecycleStrategy -
useNames -
injectors -
Returns:

method

public static ComponentAdapter method(Object componentKey,
                                      Class componentImplementation,
                                      Parameter[] parameters,
                                      ComponentMonitor monitor,
                                      LifecycleStrategy lifecycleStrategy,
                                      String methodName,
                                      boolean useNames)
                               throws AbstractInjector.NotConcreteRegistrationException
convenience method to create method injector

Parameters:
componentKey -
componentImplementation -
parameters -
monitor -
lifecycleStrategy -
methodName -
useNames -
Returns:
Throws:
AbstractInjector.NotConcreteRegistrationException

multi

public static ComponentAdapter multi(Object componentKey,
                                     Class componentImplementation,
                                     Parameter[] parameters,
                                     ComponentMonitor componentMonitor,
                                     LifecycleStrategy lifecycleStrategy,
                                     String setterPrefix,
                                     boolean useNames)
convenience method to create multi component adapter

Parameters:
componentKey -
componentImplementation -
parameters -
componentMonitor -
lifecycleStrategy -
setterPrefix -
useNames -
Returns:

namedField

public static ComponentAdapter namedField(Object key,
                                          Class<?> impl,
                                          Parameter[] parameters,
                                          ComponentMonitor componentMonitor,
                                          LifecycleStrategy lifecycleStrategy,
                                          String fieldNames)
convenience method to create named field injector

Parameters:
key -
impl -
parameters -
componentMonitor -
lifecycleStrategy -
fieldNames -
Returns:

setter

public static ComponentAdapter setter(Object componentKey,
                                      Class componentImplementation,
                                      Parameter[] parameters,
                                      ComponentMonitor monitor,
                                      LifecycleStrategy lifecycleStrategy,
                                      String setterMethodPrefix,
                                      boolean useNames)
                               throws AbstractInjector.NotConcreteRegistrationException
convenience method to create setter injector

Parameters:
componentKey -
componentImplementation -
parameters -
monitor -
lifecycleStrategy -
setterMethodPrefix -
useNames -
Returns:
Throws:
AbstractInjector.NotConcreteRegistrationException

typedField

public static ComponentAdapter typedField(Object key,
                                          Class<?> impl,
                                          Parameter[] parameters,
                                          ComponentMonitor componentMonitor,
                                          LifecycleStrategy lifecycleStrategy,
                                          String classNames)
conveniently create typed field injector

Parameters:
key -
impl -
parameters -
componentMonitor -
lifecycleStrategy -
classNames -
Returns:


Copyright © 2003-2009 Codehaus. All Rights Reserved.