Save This Page
Home » spring-framework-2.5.6-with-dependencies » org.springframework » beans » factory » support » [javadoc | source]
org.springframework.beans.factory.support
class: ConstructorResolver [javadoc | source]
java.lang.Object
   org.springframework.beans.factory.support.ConstructorResolver
Helper class for resolving constructors and factory methods. Performs constructor resolution through argument matching.

Operates on an AbstractBeanFactory and an InstantiationStrategy . Used by AbstractAutowireCapableBeanFactory .

Constructor:
 public ConstructorResolver(AbstractBeanFactory beanFactory,
    AutowireCapableBeanFactory autowireFactory,
    InstantiationStrategy instantiationStrategy,
    TypeConverter typeConverter) 
    Create a new ConstructorResolver for the given factory and instantiation strategy.
    Parameters:
    beanFactory - the BeanFactory to work with
    autowireFactory - the BeanFactory as AutowireCapableBeanFactory
    instantiationStrategy - the instantiate strategy for creating bean instances
    typeConverter - the TypeConverter to use (or null for using the default)
Method from org.springframework.beans.factory.support.ConstructorResolver Summary:
autowireConstructor,   instantiateUsingFactoryMethod,   resolveAutowiredArgument
Methods from java.lang.Object:
equals,   getClass,   hashCode,   notify,   notifyAll,   toString,   wait,   wait,   wait
Method from org.springframework.beans.factory.support.ConstructorResolver Detail:
 protected BeanWrapper autowireConstructor(String beanName,
    RootBeanDefinition mbd,
    Constructor[] chosenCtors,
    Object[] explicitArgs) 
    "autowire constructor" (with constructor arguments by type) behavior. Also applied if explicit constructor argument values are specified, matching all remaining arguments with beans from the bean factory.

    This corresponds to constructor injection: In this mode, a Spring bean factory is able to host components that expect constructor-based dependency resolution.

 public BeanWrapper instantiateUsingFactoryMethod(String beanName,
    RootBeanDefinition mbd,
    Object[] explicitArgs) 
    Instantiate the bean using a named factory method. The method may be static, if the bean definition parameter specifies a class, rather than a "factory-bean", or an instance variable on a factory object itself configured using Dependency Injection.

    Implementation requires iterating over the static or instance methods with the name specified in the RootBeanDefinition (the method may be overloaded) and trying to match with the parameters. We don't have the types attached to constructor args, so trial and error is the only way to go here. The explicitArgs array may contain argument values passed in programmatically via the corresponding getBean method.

 protected Object resolveAutowiredArgument(MethodParameter param,
    String beanName,
    Set autowiredBeanNames,
    TypeConverter typeConverter) 
    Template method for resolving the specified argument which is supposed to be autowired.