org.picocontainer.defaults
Class ConstructorInjectionComponentAdapter

java.lang.Object
  extended by org.picocontainer.defaults.MonitoringComponentAdapter
      extended by org.picocontainer.defaults.AbstractComponentAdapter
          extended by org.picocontainer.defaults.InstantiatingComponentAdapter
              extended by org.picocontainer.defaults.ConstructorInjectionComponentAdapter
All Implemented Interfaces:
Serializable, ComponentAdapter, ComponentMonitorStrategy, LifecycleStrategy

public class ConstructorInjectionComponentAdapter
extends InstantiatingComponentAdapter

Instantiates components using Constructor Injection. Note that this class doesn't cache instances. If you want caching, use a CachingComponentAdapter around this one.

Version:
$Revision: 2971 $
Author:
Paul Hammant, Aslak Hellesøy, Jon Tirsén, Zohar Melamed, Jörg Schaible, Mauro Talevi
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.picocontainer.defaults.InstantiatingComponentAdapter
allowNonPublicClasses, lifecycleStrategy, parameters, verifyingGuard
 
Constructor Summary
ConstructorInjectionComponentAdapter(Object componentKey, Class componentImplementation)
          Creates a ConstructorInjectionComponentAdapter with key and implementation
ConstructorInjectionComponentAdapter(Object componentKey, Class componentImplementation, Parameter[] parameters)
          Creates a ConstructorInjectionComponentAdapter with key, implementation and parameters
ConstructorInjectionComponentAdapter(Object componentKey, Class componentImplementation, Parameter[] parameters, boolean allowNonPublicClasses)
          Creates a ConstructorInjectionComponentAdapter
ConstructorInjectionComponentAdapter(Object componentKey, Class componentImplementation, Parameter[] parameters, boolean allowNonPublicClasses, ComponentMonitor monitor)
          Creates a ConstructorInjectionComponentAdapter
ConstructorInjectionComponentAdapter(Object componentKey, Class componentImplementation, Parameter[] parameters, boolean allowNonPublicClasses, ComponentMonitor monitor, LifecycleStrategy lifecycleStrategy)
          Creates a ConstructorInjectionComponentAdapter
 
Method Summary
 Object getComponentInstance(PicoContainer container)
          Retrieve the component instance.
protected  Object[] getConstructorArguments(PicoContainer container, Constructor ctor)
           
protected  Constructor getGreediestSatisfiableConstructor(PicoContainer container)
          Find and return the greediest satisfiable constructor.
 
Methods inherited from class org.picocontainer.defaults.InstantiatingComponentAdapter
accept, createDefaultParameters, dispose, hasLifecycle, newInstance, start, stop, verify
 
Methods inherited from class org.picocontainer.defaults.AbstractComponentAdapter
checkTypeCompatibility, getComponentImplementation, getComponentKey, toString
 
Methods inherited from class org.picocontainer.defaults.MonitoringComponentAdapter
changeMonitor, currentMonitor
 
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
 

Constructor Detail

ConstructorInjectionComponentAdapter

public ConstructorInjectionComponentAdapter(Object componentKey,
                                            Class componentImplementation,
                                            Parameter[] parameters,
                                            boolean allowNonPublicClasses,
                                            ComponentMonitor monitor,
                                            LifecycleStrategy lifecycleStrategy)
                                     throws AssignabilityRegistrationException,
                                            NotConcreteRegistrationException
Creates a ConstructorInjectionComponentAdapter

Parameters:
componentKey - the search key for this implementation
componentImplementation - the concrete implementation
parameters - the parameters to use for the initialization
allowNonPublicClasses - flag to allow instantiation of non-public classes.
monitor - the component monitor used by this adapter
lifecycleStrategy - the component lifecycle strategy used by this adapter
Throws:
AssignabilityRegistrationException - if the key is a type and the implementation cannot be assigned to.
NotConcreteRegistrationException - if the implementation is not a concrete class.
NullPointerException - if one of the parameters is null

ConstructorInjectionComponentAdapter

public ConstructorInjectionComponentAdapter(Object componentKey,
                                            Class componentImplementation,
                                            Parameter[] parameters,
                                            boolean allowNonPublicClasses,
                                            ComponentMonitor monitor)
                                     throws AssignabilityRegistrationException,
                                            NotConcreteRegistrationException
Creates a ConstructorInjectionComponentAdapter

Parameters:
componentKey - the search key for this implementation
componentImplementation - the concrete implementation
parameters - the parameters to use for the initialization
allowNonPublicClasses - flag to allow instantiation of non-public classes.
monitor - the component monitor used by this adapter
Throws:
AssignabilityRegistrationException - if the key is a type and the implementation cannot be assigned to.
NotConcreteRegistrationException - if the implementation is not a concrete class.
NullPointerException - if one of the parameters is null

ConstructorInjectionComponentAdapter

public ConstructorInjectionComponentAdapter(Object componentKey,
                                            Class componentImplementation,
                                            Parameter[] parameters,
                                            boolean allowNonPublicClasses)
                                     throws AssignabilityRegistrationException,
                                            NotConcreteRegistrationException
Creates a ConstructorInjectionComponentAdapter

Parameters:
componentKey - the search key for this implementation
componentImplementation - the concrete implementation
parameters - the parameters to use for the initialization
allowNonPublicClasses - flag to allow instantiation of non-public classes.
Throws:
AssignabilityRegistrationException - if the key is a type and the implementation cannot be assigned to.
NotConcreteRegistrationException - if the implementation is not a concrete class.
NullPointerException - if one of the parameters is null

ConstructorInjectionComponentAdapter

public ConstructorInjectionComponentAdapter(Object componentKey,
                                            Class componentImplementation,
                                            Parameter[] parameters)
Creates a ConstructorInjectionComponentAdapter with key, implementation and parameters

Parameters:
componentKey - the search key for this implementation
componentImplementation - the concrete implementation
parameters - the parameters to use for the initialization
Throws:
AssignabilityRegistrationException - if the key is a type and the implementation cannot be assigned to.
NotConcreteRegistrationException - if the implementation is not a concrete class.
NullPointerException - if one of the parameters is null

ConstructorInjectionComponentAdapter

public ConstructorInjectionComponentAdapter(Object componentKey,
                                            Class componentImplementation)
                                     throws AssignabilityRegistrationException,
                                            NotConcreteRegistrationException
Creates a ConstructorInjectionComponentAdapter with key and implementation

Parameters:
componentKey - the search key for this implementation
componentImplementation - the concrete implementation
Throws:
AssignabilityRegistrationException - if the key is a type and the implementation cannot be assigned to.
NotConcreteRegistrationException - if the implementation is not a concrete class.
NullPointerException - if one of the parameters is null
Method Detail

getGreediestSatisfiableConstructor

protected Constructor getGreediestSatisfiableConstructor(PicoContainer container)
                                                  throws PicoIntrospectionException,
                                                         UnsatisfiableDependenciesException,
                                                         AmbiguousComponentResolutionException,
                                                         AssignabilityRegistrationException,
                                                         NotConcreteRegistrationException
Description copied from class: InstantiatingComponentAdapter
Find and return the greediest satisfiable constructor.

Specified by:
getGreediestSatisfiableConstructor in class InstantiatingComponentAdapter
Parameters:
container - the PicoContainer to resolve dependencies.
Returns:
the found constructor.
Throws:
PicoIntrospectionException
UnsatisfiableDependenciesException
AmbiguousComponentResolutionException
AssignabilityRegistrationException
NotConcreteRegistrationException

getComponentInstance

public Object getComponentInstance(PicoContainer container)
                            throws PicoInitializationException,
                                   PicoIntrospectionException,
                                   AssignabilityRegistrationException,
                                   NotConcreteRegistrationException
Description copied from interface: ComponentAdapter
Retrieve the component instance. This method will usually create a new instance each time it is called, but that is not required. For example, CachingComponentAdapter will always return the same instance.

Parameters:
container - the PicoContainer, that is used to resolve any possible dependencies of the instance.
Returns:
the component instance.
Throws:
PicoInitializationException - if the component could not be instantiated.
PicoIntrospectionException - if the component has dependencies which could not be resolved, or instantiation of the component lead to an ambigous situation within the container.
AssignabilityRegistrationException
NotConcreteRegistrationException

getConstructorArguments

protected Object[] getConstructorArguments(PicoContainer container,
                                           Constructor ctor)


Copyright © 2003-2007 Codehaus. All Rights Reserved.