AutowireCapableBeanFactory源码

import java.util.Set;

import org.springframework.beans.BeansException;
import org.springframework.beans.TypeConverter;
import org.springframework.beans.factory.BeanFactory;
import org.springframework.beans.factory.NoSuchBeanDefinitionException;
import org.springframework.beans.factory.NoUniqueBeanDefinitionException;
import org.springframework.lang.Nullable;

/**
 * Extension of the {@link org.springframework.beans.factory.BeanFactory}
 * interface to be implemented by bean factories that are capable of
 * autowiring, provided that they want to expose this functionality for
 * existing bean instances.
 *
 * <p>This subinterface of BeanFactory is not meant to be used in normal
 * application code: stick to {@link org.springframework.beans.factory.BeanFactory}
 * or {@link org.springframework.beans.factory.ListableBeanFactory} for
 * typical use cases.
 *
 * <p>Integration code for other frameworks can leverage this interface to
 * wire and populate existing bean instances that Spring does not control
 * the lifecycle of. This is particularly useful for WebWork Actions and
 * Tapestry Page objects, for example.
 *
 * <p>Note that this interface is not implemented by
 * {@link org.springframework.context.ApplicationContext} facades,
 * as it is hardly ever used by application code. That said, it is available
 * from an application context too, accessible through ApplicationContext's
 * {@link org.springframework.context.ApplicationContext#getAutowireCapableBeanFactory()}
 * method.
 *
 * <p>You may also implement the {@link org.springframework.beans.factory.BeanFactoryAware}
 * interface, which exposes the internal BeanFactory even when running in an
 * ApplicationContext, to get access to an AutowireCapableBeanFactory:
 * simply cast the passed-in BeanFactory to AutowireCapableBeanFactory.
 *
 * @author Juergen Hoeller
 * @since 04.12.2003
 * @see org.springframework.beans.factory.BeanFactoryAware
 * @see org.springframework.beans.factory.config.ConfigurableListableBeanFactory
 * @see org.springframework.context.ApplicationContext#getAutowireCapableBeanFactory()
 */

//通过上面注释信息可以得知这个接口类是创建Bean的Bean工程的拓展类,全中文名为自动装配Bean工程
//其作用为注册进Bean工厂的数据自动装配,该接口类中提供了各种自动装配Bean实例的常量等..可以根据
//不同方式来装配Bean

public interface AutowireCapableBeanFactory extends BeanFactory {

    /**
     * Constant that indicates no externally defined autowiring. Note that
     * BeanFactoryAware etc and annotation-driven injection will still be applied.
     * @see #createBean
     * @see #autowire
     * @see #autowireBeanProperties
     */
 /**
     * 常量,用于标识外部自动装配功能是否可用。但是此标识不影响正常的(基于注解的等)自动装配功能的使用
     */
    int AUTOWIRE_NO = 0;

    /**
     * Constant that indicates autowiring bean properties by name
     * (applying to all bean property setters).
     * @see #createBean
     * @see #autowire
     * @see #autowireBeanProperties
     */
        //根据名称自动装配Bean
    int AUTOWIRE_BY_NAME = 1;

    /**
     * Constant that indicates autowiring bean properties by type
     * (applying to all bean property setters).
     * @see #createBean
     * @see #autowire
     * @see #autowireBeanProperties
     */
        //根据类型装配Bean
    int AUTOWIRE_BY_TYPE = 2;

    /**
     * Constant that indicates autowiring the greediest constructor that
     * can be satisfied (involves resolving the appropriate constructor).
     * @see #createBean
     * @see #autowire
     */
      //可用于构造器的Bean装配
    int AUTOWIRE_CONSTRUCTOR = 3;

    /**
     * Constant that indicates determining an appropriate autowire strategy
     * through introspection of the bean class.
     * @see #createBean
     * @see #autowire
     * @deprecated as of Spring 3.0: If you are using mixed autowiring strategies,
     * prefer annotation-based autowiring for clearer demarcation of autowiring needs.
     */
        //标识按照贪婪策略匹配出的最符合的构造方法来自动装配的常量
    @Deprecated
    int AUTOWIRE_AUTODETECT = 4;

    /**
     * Suffix for the "original instance" convention when initializing an existing
     * bean instance: to be appended to the fully-qualified bean class name,
     * e.g. "com.mypackage.MyClass.ORIGINAL", in order to enforce the given instance
     * to be returned, i.e. no proxies etc.
     * @since 5.1
     * @see #initializeBean(Object, String)
     * @see #applyBeanPostProcessorsBeforeInitialization(Object, String)
     * @see #applyBeanPostProcessorsAfterInitialization(Object, String)
     */
        //根据约定的后缀来装配Bean
    String ORIGINAL_INSTANCE_SUFFIX = ".ORIGINAL";


    //-------------------------------------------------------------------------
    // Typical methods for creating and populating external bean instances
    //-------------------------------------------------------------------------

    /**
     * Fully create a new bean instance of the given class.
     * <p>Performs full initialization of the bean, including all applicable
     * {@link BeanPostProcessor BeanPostProcessors}.
     * <p>Note: This is intended for creating a fresh instance, populating annotated
     * fields and methods as well as applying all standard bean initialization callbacks.
     * It does <i>not</i> imply traditional by-name or by-type autowiring of properties;
     * use {@link #createBean(Class, int, boolean)} for those purposes.
     * @param beanClass the class of the bean to create
     * @return the new bean instance
     * @throws BeansException if instantiation or wiring failed
     */
        //具备注解方式创建Bean
        //表明这是用于创建Bean实例,但是不具备自动装配,如果创建失败则抛出BeansException异常
    <T> T createBean(Class<T> beanClass) throws BeansException;

    /**
     * Populate the given bean instance through applying after-instantiation callbacks
     * and bean property post-processing (e.g. for annotation-driven injection).
     * <p>Note: This is essentially intended for (re-)populating annotated fields and
     * methods, either for new instances or for deserialized instances. It does
     * <i>not</i> imply traditional by-name or by-type autowiring of properties;
     * use {@link #autowireBeanProperties} for those purposes.
     * @param existingBean the existing bean instance
     * @throws BeansException if wiring failed
     */
        //表明主要是用于处理Bean中带有注解的域和方法,来创建Bean实例,也不具备自动装配
    void autowireBean(Object existingBean) throws BeansException;

    /**
     * Configure the given raw bean: autowiring bean properties, applying
     * bean property values, applying factory callbacks such as {@code setBeanName}
     * and {@code setBeanFactory}, and also applying all bean post processors
     * (including ones which might wrap the given raw bean).
     * <p>This is effectively a superset of what {@link #initializeBean} provides,
     * fully applying the configuration specified by the corresponding bean definition.
     * <b>Note: This method requires a bean definition for the given name!</b>
     * @param existingBean the existing bean instance
     * @param beanName the name of the bean, to be passed to it if necessary
     * (a bean definition of that name has to be available)
     * @return the bean instance to use, either the original or a wrapped one
     * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
     * if there is no bean definition with the given name
     * @throws BeansException if the initialization failed
     * @see #initializeBean
     */
/**

*配置给定的原始bean:autowiringbean属性,应用
*bean属性值,应用工厂回调,如{@code setBeanName}
*和{@code setBeanFactory},并应用所有bean后处理器
*完全应用相应bean定义指定的配置。
*该方法需要给定名称的bean定义
*@param existingBean现有的bean实例
*@param beanName bean的名称,如果需要,可以传递给它
*(必须提供该名称的bean定义)
*@返回要使用的bean实例,可以是原始的,也可以是包装的
*@throws org.springframework.beans.factory.NoSuchBeanDefinitionException异常
*如果没有具有给定名称的bean定义
*如果初始化失败,抛出异常throws BeansException
*/
    Object configureBean(Object existingBean, String beanName) throws BeansException;


    //-------------------------------------------------------------------------
    // Specialized methods for fine-grained control over the bean lifecycle
      //对bean生命周期进行细粒度控制的专门方法
    //-------------------------------------------------------------------------

    /**
     * Fully create a new bean instance of the given class with the specified
     * autowire strategy. All constants defined in this interface are supported here.
     * <p>Performs full initialization of the bean, including all applicable
     * {@link BeanPostProcessor BeanPostProcessors}. This is effectively a superset
     * of what {@link #autowire} provides, adding {@link #initializeBean} behavior.
     * @param beanClass the class of the bean to create
     * @param autowireMode by name or type, using the constants in this interface
     * @param dependencyCheck whether to perform a dependency check for objects
     * (not applicable to autowiring a constructor, thus ignored there)
     * @return the new bean instance
     * @throws BeansException if instantiation or wiring failed
     * @see #AUTOWIRE_NO
     * @see #AUTOWIRE_BY_NAME
     * @see #AUTOWIRE_BY_TYPE
     * @see #AUTOWIRE_CONSTRUCTOR
     */
/**
*使用指定的自动连线策略。此处支持此接口中定义的所有常量。
*执行bean的完全初始化,包括所有适用的
*在{@autowire}提供的功能中,添加了初始化Bean行为。
*@param beanClass要创建的bean的类
*@param autowireMode按名称或类型,使用此接口中的常量
*@param dependency检查是否对对象执行依赖性检查
*(不适用于自动连接构造函数)
*@return新bean实例
*如果实例化或连接失败,将抛出BeansException异常
*@AUTOWIRE  注解按名称装配Bean
*/
    Object createBean(Class<?> beanClass, int autowireMode, boolean dependencyCheck) throws BeansException;

    /**
     * Instantiate a new bean instance of the given class with the specified autowire
     * strategy. All constants defined in this interface are supported here.
     * Can also be invoked with {@code AUTOWIRE_NO} in order to just apply
     * before-instantiation callbacks (e.g. for annotation-driven injection).
     * <p>Does <i>not</i> apply standard {@link BeanPostProcessor BeanPostProcessors}
     * callbacks or perform any further initialization of the bean. This interface
     * offers distinct, fine-grained operations for those purposes, for example
     * {@link #initializeBean}. However, {@link InstantiationAwareBeanPostProcessor}
     * callbacks are applied, if applicable to the construction of the instance.
     * @param beanClass the class of the bean to instantiate
     * @param autowireMode by name or type, using the constants in this interface
     * @param dependencyCheck whether to perform a dependency check for object
     * references in the bean instance (not applicable to autowiring a constructor,
     * thus ignored there)
     * @return the new bean instance
     * @throws BeansException if instantiation or wiring failed
     * @see #AUTOWIRE_NO
     * @see #AUTOWIRE_BY_NAME
     * @see #AUTOWIRE_BY_TYPE
     * @see #AUTOWIRE_CONSTRUCTOR
     * @see #AUTOWIRE_AUTODETECT
     * @see #initializeBean
     * @see #applyBeanPostProcessorsBeforeInitialization
     * @see #applyBeanPostProcessorsAfterInitialization
     */
/**
*用指定的autowire实例化给定类的新bean实例,此处支持此接口中定义的所有常量。
*也可以用{@AUTOWIRE调用,以便应用,在实例化回调之前(例如,对于注释驱动的注入)。
*不能应用Bean后处理器
*回调或执行bean的任何进一步初始化。此接口
*例如,为这些目的提供不同的细粒度操作
*初始化Bean但是,初始化Bean后处理器回调将应用于实例的构造(如果适用)。
*@param beanClass要实例化的bean的类
*@param autowireMode按名称或类型,使用此接口中的常量
*@param dependencyCheck是否对对象执行依赖性检查
*bean实例中的引用(不适用于自动连接构造函数,因此被忽略了)
*@return新bean实例
*如果实例化或连接失败,@抛出BeansException
*@见#initializeBean
*@applybeanpostprocessors在初始化之前
*@applybeanpostprocessors初始化后
*/
    Object autowire(Class<?> beanClass, int autowireMode, boolean dependencyCheck) throws BeansException;

    /**
     * Autowire the bean properties of the given bean instance by name or type.
     * Can also be invoked with {@code AUTOWIRE_NO} in order to just apply
     * after-instantiation callbacks (e.g. for annotation-driven injection).
     * <p>Does <i>not</i> apply standard {@link BeanPostProcessor BeanPostProcessors}
     * callbacks or perform any further initialization of the bean. This interface
     * offers distinct, fine-grained operations for those purposes, for example
     * {@link #initializeBean}. However, {@link InstantiationAwareBeanPostProcessor}
     * callbacks are applied, if applicable to the configuration of the instance.
     * @param existingBean the existing bean instance
     * @param autowireMode by name or type, using the constants in this interface
     * @param dependencyCheck whether to perform a dependency check for object
     * references in the bean instance
     * @throws BeansException if wiring failed
     * @see #AUTOWIRE_BY_NAME
     * @see #AUTOWIRE_BY_TYPE
     * @see #AUTOWIRE_NO
     */
/**
*按名称或类型自动关联给定bean实例的bean属性。
*也可以用{@AUTOWIRE调用,以便应用实例化后回调(例如注释驱动的注入)。
*不能应用在Bean后处理器
*回调或执行bean的任何进一步初始化。此接口 例如,为这些目的提供不同的细粒度操作
*初始化Bean但是,Bean后处理器回调将应用于实例的配置(如果适用)。
*@param existingBean现有的bean实例
*@param autowireMode按名称或类型,使用此接口中的常量
*@param dependencyCheck是否对对象执行依赖性检查
*如果装配失败,@抛出BeansException
*/
    void autowireBeanProperties(Object existingBean, int autowireMode, boolean dependencyCheck)
            throws BeansException;

    /**
     * Apply the property values of the bean definition with the given name to
     * the given bean instance. The bean definition can either define a fully
     * self-contained bean, reusing its property values, or just property values
     * meant to be used for existing bean instances.
     * <p>This method does <i>not</i> autowire bean properties; it just applies
     * explicitly defined property values. Use the {@link #autowireBeanProperties}
     * method to autowire an existing bean instance.
     * <b>Note: This method requires a bean definition for the given name!</b>
     * <p>Does <i>not</i> apply standard {@link BeanPostProcessor BeanPostProcessors}
     * callbacks or perform any further initialization of the bean. This interface
     * offers distinct, fine-grained operations for those purposes, for example
     * {@link #initializeBean}. However, {@link InstantiationAwareBeanPostProcessor}
     * callbacks are applied, if applicable to the configuration of the instance.
     * @param existingBean the existing bean instance
     * @param beanName the name of the bean definition in the bean factory
     * (a bean definition of that name has to be available)
     * @throws org.springframework.beans.factory.NoSuchBeanDefinitionException
     * if there is no bean definition with the given name
     * @throws BeansException if applying the property values failed
     * @see #autowireBeanProperties
     */
/**
*将具有给定名称的bean定义的属性值应用于
*给定的bean实例。bean定义可以定义
*自包含bean,重用它的属性值,或者只是属性值
*用于现有bean实例。
*此方法不具有autowire bean属性它只是适用的显式定义的属性值。使用autowireBeanProperties方法自动关联现有bean实例。
*此方法需要给定名称的bean定义
*不能应用BeanPostProcessor(Bean后处理器)
*回调或执行bean的任何进一步初始化。此接口
*例如,为这些目的提供不同的细粒度操作
*initializeBean但是,InstantiationAwareBeanPostProcessor回调将应用于实例的配置(如果适用)。
*@param existingBean现有的bean实例
*@param beanName bean工厂中bean定义的名称
*(必须提供该名称的bean定义)
*@throws org.springframework.beans.factory.NoSuchBeanDefinitionException异常
*如果没有具有给定名称的bean定义
*如果应用属性值失败,@throws BeansException
*/
    void applyBeanPropertyValues(Object existingBean, String beanName) throws BeansException;

    /**
     * Initialize the given raw bean, applying factory callbacks
     * such as {@code setBeanName} and {@code setBeanFactory},
     * also applying all bean post processors (including ones which
     * might wrap the given raw bean).
     * <p>Note that no bean definition of the given name has to exist
     * in the bean factory. The passed-in bean name will simply be used
     * for callbacks but not checked against the registered bean definitions.
     * @param existingBean the existing bean instance
     * @param beanName the name of the bean, to be passed to it if necessary
     * (only passed to {@link BeanPostProcessor BeanPostProcessors};
     * can follow the {@link #ORIGINAL_INSTANCE_SUFFIX} convention in order to
     * enforce the given instance to be returned, i.e. no proxies etc)
     * @return the bean instance to use, either the original or a wrapped one
     * @throws BeansException if the initialization failed
     * @see #ORIGINAL_INSTANCE_SUFFIX
     */
/**
*初始化给定的原始bean,应用工厂回调
*例如{setBeanName}和{setBeanFactory},
*还应用了所有bean后处理器(包括可以包装给定的Bean)。
*给定名称的bean定义不必存在Bean工厂。只需使用传入的bean名称
*用于回调,但未根据已注册的bean定义进行检查。
*@param existingBean现有的bean实例
*@param beanName bean的名称,如果需要,可以传递给它
*(仅传递给beanpstoprocessor beanpstoprocessors
*可以遵循ORIGINAL_INSTANCE_SUFFIX后缀约定匹配
*强制返回给定实例,即没有代理等)
*@返回要使用的bean实例,可以是原始的,也可以是包装的
*如果初始化失败,@throws BeansException
*/
    Object initializeBean(Object existingBean, String beanName) throws BeansException;

    /**
     * Apply {@link BeanPostProcessor BeanPostProcessors} to the given existing bean
     * instance, invoking their {@code postProcessBeforeInitialization} methods.
     * The returned bean instance may be a wrapper around the original.
     * @param existingBean the existing bean instance
     * @param beanName the name of the bean, to be passed to it if necessary
     * (only passed to {@link BeanPostProcessor BeanPostProcessors};
     * can follow the {@link #ORIGINAL_INSTANCE_SUFFIX} convention in order to
     * enforce the given instance to be returned, i.e. no proxies etc)
     * @return the bean instance to use, either the original or a wrapped one
     * @throws BeansException if any post-processing failed
     * @see BeanPostProcessor#postProcessBeforeInitialization
     * @see #ORIGINAL_INSTANCE_SUFFIX
     */
/**

*将{ BeanPostProcessor BeanPostProcessors}应用于给定的现有bean
*实例,调用它们的{postProcessBeforeInitialization}方法。
*返回的bean实例可能是原始bean的包装器。
*@param existingBean现有的bean实例
*@param beanName bean的名称,如果需要,可以传递给它
*(仅传递给{beanpstoprocessor beanpstoprocessors};
*可以遵循{@link#ORIGINAL_INSTANCE_SUFFIX}约定
*强制返回给定实例,即没有代理等)
*如果任何后处理失败,@throws BeansException
*BeanPostProcessor#初始化前的后处理
*/
    Object applyBeanPostProcessorsBeforeInitialization(Object existingBean, String beanName)
            throws BeansException;

    /**
     * Apply {@link BeanPostProcessor BeanPostProcessors} to the given existing bean
     * instance, invoking their {@code postProcessAfterInitialization} methods.
     * The returned bean instance may be a wrapper around the original.
     * @param existingBean the existing bean instance
     * @param beanName the name of the bean, to be passed to it if necessary
     * (only passed to {@link BeanPostProcessor BeanPostProcessors};
     * can follow the {@link #ORIGINAL_INSTANCE_SUFFIX} convention in order to
     * enforce the given instance to be returned, i.e. no proxies etc)
     * @return the bean instance to use, either the original or a wrapped one
     * @throws BeansException if any post-processing failed
     * @see BeanPostProcessor#postProcessAfterInitialization
     * @see #ORIGINAL_INSTANCE_SUFFIX
     */
/**
*将{@link BeanPostProcessor BeanPostProcessors}应用于给定的现有bean
*实例,调用它们的{@CodePostProcessAfterInitialization}方法。
*返回的bean实例可能是原始bean的包装器。
*@param existingBean现有的bean实例
*@param beanName bean的名称,如果需要,可以传递给它
*(仅传递给{@link beanpstoprocessor beanpstoprocessors};
*可以遵循{@link#ORIGINAL_INSTANCE_SUFFIX}约定
*强制返回给定实例,即没有代理等)
*@返回要使用的bean实例,可以是原始的,也可以是包装的
*如果任何后处理失败,@throws BeansException
*BeanPostProcessor#初始化后的后处理器
*/
    Object applyBeanPostProcessorsAfterInitialization(Object existingBean, String beanName)
            throws BeansException;

    /**
     * Destroy the given bean instance (typically coming from {@link #createBean}),
     * applying the {@link org.springframework.beans.factory.DisposableBean} contract as well as
     * registered {@link DestructionAwareBeanPostProcessor DestructionAwareBeanPostProcessors}.
     * <p>Any exception that arises during destruction should be caught
     * and logged instead of propagated to the caller of this method.
     * @param existingBean the bean instance to destroy
     */
/**
*销毁给定的bean实例(通常来自{@link#createBean}),
*应用{@link org.springframework.beans.factory.DisposableBean}合同以及
*已注册{@link DestructionAwareBeanPostProcessor DestructionAwareBeanPostProcessors}。
*<p>销毁过程中出现的任何异常都应被捕获
*并记录,而不是传播到此方法的调用方。
*@param existingBean要销毁的bean实例
*/
    void destroyBean(Object existingBean);


    //-------------------------------------------------------------------------
    // Delegate methods for resolving injection points
    //-------------------------------------------------------------------------

    /**
     * Resolve the bean instance that uniquely matches the given object type, if any,
     * including its bean name.
     * <p>This is effectively a variant of {@link #getBean(Class)} which preserves the
     * bean name of the matching instance.
     * @param requiredType type the bean must match; can be an interface or superclass
     * @return the bean name plus bean instance
     * @throws NoSuchBeanDefinitionException if no matching bean was found
     * @throws NoUniqueBeanDefinitionException if more than one matching bean was found
     * @throws BeansException if the bean could not be created
     * @since 4.3.3
     * @see #getBean(Class)
     */
/**
*解析唯一匹配给定对象类型的bean实例(如果有的话),
*包括它的豆名。
*<p>这实际上是{@link#getBean(Class)}的一个变体,它保留了
*匹配实例的bean名称。
*@param requiredType bean必须匹配的类型;可以是接口或超类
*@return bean name加bean实例
*如果找不到匹配的bean,@抛出NoSuchBeanDefinitionException
*如果找到多个匹配bean,@throws NoUniqueBeanDefinitionException
*如果无法创建bean,@throws BeansException
*@自4.3.3
*@see#getBean(类)
*/
    <T> NamedBeanHolder<T> resolveNamedBean(Class<T> requiredType) throws BeansException;

    /**
     * Resolve a bean instance for the given bean name, providing a dependency descriptor
     * for exposure to target factory methods.
     * <p>This is effectively a variant of {@link #getBean(String, Class)} which supports
     * factory methods with an {@link org.springframework.beans.factory.InjectionPoint}
     * argument.
     * @param name the name of the bean to look up
     * @param descriptor the dependency descriptor for the requesting injection point
     * @return the corresponding bean instance
     * @throws NoSuchBeanDefinitionException if there is no bean with the specified name
     * @throws BeansException if the bean could not be created
     * @since 5.1.5
     * @see #getBean(String, Class)
     */
/**
*为给定的bean名称解析bean实例,提供依赖描述符
*用于接触目标工厂方法。
*<p>这实际上是{@link#getBean(String,Class)}的一个变体,它支持
*带有{@link org.springframework.beans.factory.InjectionPoint}的工厂方法
*争论。
*@param name要查找的bean的名称
*@param descriptor请求注入点的依赖关系描述符
*@返回对应的bean实例
*如果没有具有指定名称的bean,@抛出NoSuchBeanDefinitionException
*如果无法创建bean,@throws BeansException
*@自5.1.5
*@see#getBean(字符串,类)
*/
    Object resolveBeanByName(String name, DependencyDescriptor descriptor) throws BeansException;

    /**
     * Resolve the specified dependency against the beans defined in this factory.
     * @param descriptor the descriptor for the dependency (field/method/constructor)
     * @param requestingBeanName the name of the bean which declares the given dependency
     * @return the resolved object, or {@code null} if none found
     * @throws NoSuchBeanDefinitionException if no matching bean was found
     * @throws NoUniqueBeanDefinitionException if more than one matching bean was found
     * @throws BeansException if dependency resolution failed for any other reason
     * @since 2.5
     * @see #resolveDependency(DependencyDescriptor, String, Set, TypeConverter)
     */
/**
*根据此工厂中定义的bean解析指定的依赖关系。
*@param descriptor依赖项的描述符(字段/方法/构造函数)
*@param requestingBeanName声明给定依赖项的bean的名称
*@返回已解析的对象,如果找不到,则返回{@code null}
*如果找不到匹配的bean,@抛出NoSuchBeanDefinitionException
*如果找到多个匹配bean,@throws NoUniqueBeanDefinitionException
*如果依赖项解析因任何其他原因失败,@throws BeansException
*@自2.5
*@see#resolveDependency(DependencyDescriptor、String、Set、TypeConverter)
*/
    @Nullable
    Object resolveDependency(DependencyDescriptor descriptor, @Nullable String requestingBeanName) throws BeansException;

    /**
     * Resolve the specified dependency against the beans defined in this factory.
     * @param descriptor the descriptor for the dependency (field/method/constructor)
     * @param requestingBeanName the name of the bean which declares the given dependency
     * @param autowiredBeanNames a Set that all names of autowired beans (used for
     * resolving the given dependency) are supposed to be added to
     * @param typeConverter the TypeConverter to use for populating arrays and collections
     * @return the resolved object, or {@code null} if none found
     * @throws NoSuchBeanDefinitionException if no matching bean was found
     * @throws NoUniqueBeanDefinitionException if more than one matching bean was found
     * @throws BeansException if dependency resolution failed for any other reason
     * @since 2.5
     * @see DependencyDescriptor
     */
/**
*根据此工厂中定义的bean解析指定的依赖关系。
*@param descriptor依赖项的描述符(字段/方法/构造函数)
*@param requestingBeanName声明给定依赖项的bean的名称
*@param autowiredBeanNames一个集合,所有autowired bean的名称(用于
*解析给定的依赖关系)应该添加到
*@param typeConverter用于填充数组和集合的typeConverter
*@返回已解析的对象,如果找不到,则返回{@code null}
*如果找不到匹配的bean,@抛出NoSuchBeanDefinitionException
*如果找到多个匹配bean,@throws NoUniqueBeanDefinitionException
*如果依赖项解析因任何其他原因失败,@throws BeansException
*@自2.5
*@参见DependencyDescriptor
*/
    @Nullable
    Object resolveDependency(DependencyDescriptor descriptor, @Nullable String requestingBeanName,
            @Nullable Set<String> autowiredBeanNames, @Nullable TypeConverter typeConverter) throws BeansException;

}
最后编辑于
©著作权归作者所有,转载或内容合作请联系作者
  • 序言:七十年代末,一起剥皮案震惊了整个滨河市,随后出现的几起案子,更是在滨河造成了极大的恐慌,老刑警刘岩,带你破解...
    沈念sama阅读 216,240评论 6 498
  • 序言:滨河连续发生了三起死亡事件,死亡现场离奇诡异,居然都是意外死亡,警方通过查阅死者的电脑和手机,发现死者居然都...
    沈念sama阅读 92,328评论 3 392
  • 文/潘晓璐 我一进店门,熙熙楼的掌柜王于贵愁眉苦脸地迎上来,“玉大人,你说我怎么就摊上这事。” “怎么了?”我有些...
    开封第一讲书人阅读 162,182评论 0 353
  • 文/不坏的土叔 我叫张陵,是天一观的道长。 经常有香客问我,道长,这世上最难降的妖魔是什么? 我笑而不...
    开封第一讲书人阅读 58,121评论 1 292
  • 正文 为了忘掉前任,我火速办了婚礼,结果婚礼上,老公的妹妹穿的比我还像新娘。我一直安慰自己,他们只是感情好,可当我...
    茶点故事阅读 67,135评论 6 388
  • 文/花漫 我一把揭开白布。 她就那样静静地躺着,像睡着了一般。 火红的嫁衣衬着肌肤如雪。 梳的纹丝不乱的头发上,一...
    开封第一讲书人阅读 51,093评论 1 295
  • 那天,我揣着相机与录音,去河边找鬼。 笑死,一个胖子当着我的面吹牛,可吹牛的内容都是我干的。 我是一名探鬼主播,决...
    沈念sama阅读 40,013评论 3 417
  • 文/苍兰香墨 我猛地睁开眼,长吁一口气:“原来是场噩梦啊……” “哼!你这毒妇竟也来了?” 一声冷哼从身侧响起,我...
    开封第一讲书人阅读 38,854评论 0 273
  • 序言:老挝万荣一对情侣失踪,失踪者是张志新(化名)和其女友刘颖,没想到半个月后,有当地人在树林里发现了一具尸体,经...
    沈念sama阅读 45,295评论 1 310
  • 正文 独居荒郊野岭守林人离奇死亡,尸身上长有42处带血的脓包…… 初始之章·张勋 以下内容为张勋视角 年9月15日...
    茶点故事阅读 37,513评论 2 332
  • 正文 我和宋清朗相恋三年,在试婚纱的时候发现自己被绿了。 大学时的朋友给我发了我未婚夫和他白月光在一起吃饭的照片。...
    茶点故事阅读 39,678评论 1 348
  • 序言:一个原本活蹦乱跳的男人离奇死亡,死状恐怖,灵堂内的尸体忽然破棺而出,到底是诈尸还是另有隐情,我是刑警宁泽,带...
    沈念sama阅读 35,398评论 5 343
  • 正文 年R本政府宣布,位于F岛的核电站,受9级特大地震影响,放射性物质发生泄漏。R本人自食恶果不足惜,却给世界环境...
    茶点故事阅读 40,989评论 3 325
  • 文/蒙蒙 一、第九天 我趴在偏房一处隐蔽的房顶上张望。 院中可真热闹,春花似锦、人声如沸。这庄子的主人今日做“春日...
    开封第一讲书人阅读 31,636评论 0 22
  • 文/苍兰香墨 我抬头看了看天上的太阳。三九已至,却和暖如春,着一层夹袄步出监牢的瞬间,已是汗流浃背。 一阵脚步声响...
    开封第一讲书人阅读 32,801评论 1 268
  • 我被黑心中介骗来泰国打工, 没想到刚下飞机就差点儿被人妖公主榨干…… 1. 我叫王不留,地道东北人。 一个月前我还...
    沈念sama阅读 47,657评论 2 368
  • 正文 我出身青楼,却偏偏与公主长得像,于是被迫代替她去往敌国和亲。 传闻我的和亲对象是个残疾皇子,可洞房花烛夜当晚...
    茶点故事阅读 44,558评论 2 352