org.picocontainer.defaults
Class ConstructorInjectionComponentAdapter

java.lang.Object
  extended byorg.picocontainer.defaults.AbstractComponentAdapter
      extended byorg.picocontainer.defaults.InstantiatingComponentAdapter
          extended byorg.picocontainer.defaults.ConstructorInjectionComponentAdapter
All Implemented Interfaces:
ComponentAdapter, Serializable

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: 1.29 $
Author:
Paul Hammant, Aslak Hellesøy, Jon Tirsén, Zohar Melamed, Jörg Schaible
See Also:
Serialized Form

Field Summary
 
Fields inherited from class org.picocontainer.defaults.InstantiatingComponentAdapter
allowNonPublicClasses, parameters, verifyingGuard
 
Constructor Summary
ConstructorInjectionComponentAdapter(Object componentKey, Class componentImplementation)
          Use default parameters.
ConstructorInjectionComponentAdapter(Object componentKey, Class componentImplementation, Parameter[] parameters)
           
ConstructorInjectionComponentAdapter(Object componentKey, Class componentImplementation, Parameter[] parameters, boolean allowNonPublicClasses)
          Explicitly specifies parameters.
 
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, newInstance, verify
 
Methods inherited from class org.picocontainer.defaults.AbstractComponentAdapter
checkTypeCompatibility, getComponentImplementation, getComponentKey, toString
 
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)
                                     throws AssignabilityRegistrationException,
                                            NotConcreteRegistrationException
Explicitly specifies parameters. If parameters are null, default parameters will be used.


ConstructorInjectionComponentAdapter

public ConstructorInjectionComponentAdapter(Object componentKey,
                                            Class componentImplementation,
                                            Parameter[] parameters)

ConstructorInjectionComponentAdapter

public ConstructorInjectionComponentAdapter(Object componentKey,
                                            Class componentImplementation)
                                     throws AssignabilityRegistrationException,
                                            NotConcreteRegistrationException
Use default parameters.

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:
AmbiguousComponentResolutionException
UnsatisfiableDependenciesException
NotConcreteRegistrationException
PicoIntrospectionException
AssignabilityRegistrationException

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:
PicoIntrospectionException - if the component has dependencies which could not be resolved, or instantiation of the component lead to an ambigous situation within the container.
PicoInitializationException - if the component could not be instantiated.
AssignabilityRegistrationException
NotConcreteRegistrationException

getConstructorArguments

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


Copyright © 2003-2004 Codehaus. All Rights Reserved.