在上篇文章中我们了解到了如何设置Bean之间的依赖关系,以及如何将一个Bean设置到它所依赖的另一个bean的属性中,但是我们还忘了一步,就是对BeanDefinition进行解析,在Spring中是通过BeanDefinitionResolver来对BeanDefinition进行解析的。
在populateBean()会创建一个BeanDefinitionValueResolver对象,然后调用BeanDefinitionValueResolver#resolveValueNecessary方法来对BeanDefinition进行解析,根本上其实是对一个propertyValue进行解析。
/**
* Given a PropertyValue, return a value, resolving any references to other
* beans in the factory if necessary.
给定一个PropertyValue,返回一个值,如果有必要,解析对工厂中其他bean的任何引用
The value could be:
这个value可以是
* <li>A BeanDefinition, which leads to the creation of a corresponding
* new bean instance. Singleton flags and names of such "inner beans"
* are always ignored: Inner beans are anonymous prototypes.
BeanDefinition,它导致创建相应的新bean实例。 Singleton标志和这种“内部bean”的名称总是被忽略:内部bean是匿名原型。
* <li>A RuntimeBeanReference, which must be resolved.
一个RuntimeBeanReference,必须解析
* <li>A ManagedList. This is a special collection that may contain
* RuntimeBeanReferences or Collections that will need to be resolved.
一个managedList,这是一个特殊的集合,可能包含需要解析的RuntimeBeanReference或者Collections
* <li>A ManagedSet. May also contain RuntimeBeanReferences or
* Collections that will need to be resolved.
一个ManagedSet。也可能包含RunTimeBeanReference或需要解决的集合
一个ManagedSet,
* <li>A ManagedMap. In this case the value may be a RuntimeBeanReference
* or Collection that will need to be resolved.
一个Managed