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, Class<? extends Annotation> injectionAnnotation, boolean useNames)
          Convenience method to create annotated field injector
static ComponentAdapter annotatedMethod(Object key, Class<?> impl, Parameter[] parameters, ComponentMonitor monitor, Class<? extends Annotation> injectionAnnotation, boolean useNames)
          convenience method to create annotated method injector
static ComponentAdapter composite(Object componentKey, Class<?> componentImplementation, Parameter[] parameters, ComponentMonitor monitor, 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, boolean useNames)
          Creates a ConstructorInjector
static ComponentAdapter constructor(Object componentKey, Class componentImplementation, Parameter[] parameters, ComponentMonitor monitor, boolean useNames, boolean rememberChosenCtor)
          Creates a ConstructorInjector
static ComponentAdapter method(Object componentKey, Class componentImplementation, Parameter[] parameters, ComponentMonitor monitor, String methodName, boolean useNames)
          convenience method to create method injector
static ComponentAdapter multi(Object componentKey, Class componentImplementation, Parameter[] parameters, ComponentMonitor componentMonitor, String setterPrefix, boolean useNames)
          convenience method to create multi component adapter
static ComponentAdapter namedField(Object key, Class<?> impl, Parameter[] parameters, ComponentMonitor componentMonitor, String fieldNames)
          convenience method to create named field injector
static ComponentAdapter setter(Object componentKey, Class componentImplementation, Parameter[] parameters, ComponentMonitor monitor, String prefix, boolean useNames)
          convenience method to create setter injector
static ComponentAdapter typedField(Object key, Class<?> impl, Parameter[] parameters, ComponentMonitor componentMonitor, 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,
                                           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
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,
                                           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
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,
                                              Class<? extends Annotation> injectionAnnotation,
                                              boolean useNames)
Convenience method to create annotated field injector

Parameters:
key -
impl -
parameters -
componentMonitor -
injectionAnnotation -
useNames -
Returns:
annotated field injector instance.

annotatedMethod

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

Parameters:
key -
impl -
parameters -
monitor -
injectionAnnotation -
useNames -
Returns:
method injector instance.

composite

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

Parameters:
componentKey -
componentImplementation -
parameters -
monitor -
useNames -
injectors -
Returns:
composite injector instance.

method

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

Parameters:
componentKey -
componentImplementation -
parameters -
monitor -
methodName -
useNames -
Returns:
method injector instance.
Throws:
AbstractInjector.NotConcreteRegistrationException

multi

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

Parameters:
componentKey -
componentImplementation -
parameters -
componentMonitor -
setterPrefix -
useNames -
Returns:
MultiInjector component adapter instance.

namedField

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

Parameters:
key -
impl -
parameters -
componentMonitor -
fieldNames -
Returns:
named field component injector instance.

setter

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

Parameters:
componentKey -
componentImplementation -
parameters -
monitor -
prefix -
useNames -
Returns:
setter injector instance.
Throws:
AbstractInjector.NotConcreteRegistrationException

typedField

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

Parameters:
key -
impl -
parameters -
componentMonitor -
classNames -
Returns:
typed field injector instance.


Copyright © 2003-2010 Codehaus. All Rights Reserved.