使用属性值填充给定 BeanWrapper 中的 bean 实例。

概要流程图

  1. @SuppressWarnings("deprecation") // for postProcessPropertyValues
  2. protected void populateBean(String beanName, RootBeanDefinition mbd, @Nullable BeanWrapper bw) {
  3. // 包装类为空
  4. if (bw == null) {
  5. // 如果有属性的话,但是没处理就抛出异常了
  6. if (mbd.hasPropertyValues()) {
  7. throw new BeanCreationException(
  8. mbd.getResourceDescription(), beanName, "Cannot apply property values to null instance");
  9. } else {
  10. // Skip property population phase for null instance.
  11. return;
  12. }
  13. }
  14. // 让后扩展处理器加入
  15. // Give any InstantiationAwareBeanPostProcessors the opportunity to modify the
  16. // state of the bean before properties are set. This can be used, for example,
  17. // to support styles of field injection.
  18. if (!mbd.isSynthetic() && hasInstantiationAwareBeanPostProcessors()) {
  19. for (BeanPostProcessor bp : getBeanPostProcessors()) {
  20. if (bp instanceof InstantiationAwareBeanPostProcessor) {
  21. InstantiationAwareBeanPostProcessor ibp = (InstantiationAwareBeanPostProcessor) bp;
  22. if (!ibp.postProcessAfterInstantiation(bw.getWrappedInstance(), beanName)) {
  23. return;
  24. }
  25. }
  26. }
  27. }
  28. // 获取属性
  29. PropertyValues pvs = (mbd.hasPropertyValues() ? mbd.getPropertyValues() : null);
  30. // 获取属性的注入类型
  31. int resolvedAutowireMode = mbd.getResolvedAutowireMode();
  32. if (resolvedAutowireMode == AUTOWIRE_BY_NAME || resolvedAutowireMode == AUTOWIRE_BY_TYPE) {
  33. // 通过名称或者类型注入
  34. MutablePropertyValues newPvs = new MutablePropertyValues(pvs);
  35. // Add property values based on autowire by name if applicable.
  36. if (resolvedAutowireMode == AUTOWIRE_BY_NAME) {
  37. autowireByName(beanName, mbd, bw, newPvs);
  38. }
  39. // Add property values based on autowire by type if applicable.
  40. if (resolvedAutowireMode == AUTOWIRE_BY_TYPE) {
  41. autowireByType(beanName, mbd, bw, newPvs);
  42. }
  43. pvs = newPvs;
  44. }
  45. boolean hasInstAwareBpps = hasInstantiationAwareBeanPostProcessors();
  46. boolean needsDepCheck = (mbd.getDependencyCheck() != AbstractBeanDefinition.DEPENDENCY_CHECK_NONE);
  47. PropertyDescriptor[] filteredPds = null;
  48. if (hasInstAwareBpps) {
  49. if (pvs == null) {
  50. pvs = mbd.getPropertyValues();
  51. }
  52. for (BeanPostProcessor bp : getBeanPostProcessors()) {
  53. if (bp instanceof InstantiationAwareBeanPostProcessor) {
  54. InstantiationAwareBeanPostProcessor ibp = (InstantiationAwareBeanPostProcessor) bp;
  55. PropertyValues pvsToUse = ibp.postProcessProperties(pvs, bw.getWrappedInstance(), beanName);
  56. if (pvsToUse == null) {
  57. if (filteredPds == null) {
  58. filteredPds = filterPropertyDescriptorsForDependencyCheck(bw, mbd.allowCaching);
  59. }
  60. pvsToUse = ibp.postProcessPropertyValues(pvs, filteredPds, bw.getWrappedInstance(), beanName);
  61. if (pvsToUse == null) {
  62. return;
  63. }
  64. }
  65. pvs = pvsToUse;
  66. }
  67. }
  68. }
  69. if (needsDepCheck) {
  70. if (filteredPds == null) {
  71. filteredPds = filterPropertyDescriptorsForDependencyCheck(bw, mbd.allowCaching);
  72. }
  73. checkDependencies(beanName, mbd, filteredPds, pvs);
  74. }
  75. if (pvs != null) {
  76. applyPropertyValues(beanName, mbd, bw, pvs);
  77. }
  78. }

流程1 - 参数校验

  1. // 包装类为空
  2. if (bw == null) {
  3. // 如果有属性的话,但是没处理就抛出异常了
  4. if (mbd.hasPropertyValues()) {
  5. throw new BeanCreationException(
  6. mbd.getResourceDescription(), beanName, "Cannot apply property values to null instance");
  7. } else {
  8. // Skip property population phase for null instance.
  9. return;
  10. }
  11. }

流程2 - 后扩展加入

通过 InstantiationAwareBeanPostProcessor 扩展点,这里是实例化后,填充属性前用户可以调整bean的机会。它可以决定是否执行后面的填充逻辑。

  1. // 让后扩展处理器加入
  2. // Give any InstantiationAwareBeanPostProcessors the opportunity to modify the
  3. // state of the bean before properties are set. This can be used, for example,
  4. // to support styles of field injection.
  5. if (!mbd.isSynthetic() && hasInstantiationAwareBeanPostProcessors()) {
  6. for (BeanPostProcessor bp : getBeanPostProcessors()) {
  7. if (bp instanceof InstantiationAwareBeanPostProcessor) {
  8. InstantiationAwareBeanPostProcessor ibp = (InstantiationAwareBeanPostProcessor) bp;
  9. if (!ibp.postProcessAfterInstantiation(bw.getWrappedInstance(), beanName)) {
  10. return;
  11. }
  12. }
  13. }
  14. }

代码演示
准备bean

  1. public class Dog {
  2. private String name;
  3. private Integer age;
  4. public Dog() {
  5. System.out.println("Dog init!!");
  6. }
  7. public Dog(String name, Integer age) {
  8. System.out.println("Dog init!!");
  9. this.name = name;
  10. this.age = age;
  11. }
  12. public void say(){
  13. System.out.println("wwwwwwwww");
  14. }
  15. public String getName() {
  16. return name;
  17. }
  18. public void setName(String name) {
  19. this.name = name;
  20. }
  21. public Integer getAge() {
  22. return age;
  23. }
  24. public void setAge(Integer age) {
  25. this.age = age;
  26. }
  27. }

增加自定义扩展,这里我们修改bean的属性name。

  1. public class OrgInstantiationAwareBeanPostProcessor implements InstantiationAwareBeanPostProcessor {
  2. @Override
  3. public boolean postProcessAfterInstantiation(Object bean, String beanName) throws BeansException {
  4. if (bean.getClass() == Dog.class) {
  5. Dog dog = (Dog) bean;
  6. dog.setName("哈哈哈哈哈");
  7. }
  8. return false;
  9. }
  10. }

bean 加入 IOC

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans
  3. xmlns="http://www.springframework.org/schema/beans"
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5. xsi:schemaLocation="http://www.springframework.org/schema/beans
  6. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
  7. <bean id="dog" class="cn.lichenghao.entity.Dog">
  8. <property name="name" value="d1"/>
  9. <property name="age" value="12"/>
  10. </bean>
  11. <bean id="orgInstantiationAwareBeanPostProcessor"
  12. class="cn.lichenghao.processor.OrgInstantiationAwareBeanPostProcessor"/>
  13. </beans>

测试
可以看出,我们定义的 bean 被我们的自定义扩展修改 name 值后结束。

  1. @DisplayName("自定义InstantiationAwareBeanPostProcessor")
  2. @Test
  3. public void OrgInstantiationAwareBeanPostProcessor() {
  4. ClassPathXmlApplicationContext classPathXmlApplicationContext
  5. = new ClassPathXmlApplicationContext("processor/InstantiationAwareBeanPostProcessor.xml");
  6. Dog dog = classPathXmlApplicationContext.getBean(Dog.class);
  7. System.out.println(dog.getName());
  8. }
  9. // 结果
  10. Dog init!!
  11. 哈哈哈哈哈

流程3 - 解析属性

AutowireCapableBeanFactory 接口中定义了各种注入类型如下所示:

resolvedAutowireMode 依赖注入方式 描述
0 AUTOWIRE_NO 没有显式配置上装配的方式(默认)
1 AUTOWIRE_BY_NAME 按 beanName 进行装配
2 AUTOWIRE_BY_TYPE 按 type 进行装配
3 AUTOWIRE_CONSTRUCTOR 在构造函数中进行装配
4 AUTOWIRE_AUTODETECT @Deprecated
  1. // 获取属性
  2. PropertyValues pvs = (mbd.hasPropertyValues() ? mbd.getPropertyValues() : null);
  3. // 获取属性的注入类型,默认情况下为0
  4. int resolvedAutowireMode = mbd.getResolvedAutowireMode();
  5. if (resolvedAutowireMode == AUTOWIRE_BY_NAME || resolvedAutowireMode == AUTOWIRE_BY_TYPE) {
  6. // 通过名称或者类型注入
  7. MutablePropertyValues newPvs = new MutablePropertyValues(pvs);
  8. // Add property values based on autowire by name if applicable.
  9. // 通过名称注入
  10. if (resolvedAutowireMode == AUTOWIRE_BY_NAME) {
  11. autowireByName(beanName, mbd, bw, newPvs);
  12. }
  13. // Add property values based on autowire by type if applicable.
  14. // 通过类型注入
  15. if (resolvedAutowireMode == AUTOWIRE_BY_TYPE) {
  16. autowireByType(beanName, mbd, bw, newPvs);
  17. }
  18. pvs = newPvs;
  19. }

当在配置文件中指定了注入类型才会进入这个分支。
比如: 或者 使用 @Autowired 注解。

根据名称获取属性 autowireByName

  1. protected void autowireByName(
  2. String beanName, AbstractBeanDefinition mbd, BeanWrapper bw, MutablePropertyValues pvs) {
  3. // 过滤得到需要根据名称注入的属性
  4. String[] propertyNames = unsatisfiedNonSimpleProperties(mbd, bw);
  5. for (String propertyName : propertyNames) {
  6. // 判断依赖的属性是否有指定的bean
  7. if (containsBean(propertyName)) {
  8. // 得到依赖的bean
  9. Object bean = getBean(propertyName);
  10. // 加入pvs
  11. pvs.add(propertyName, bean);
  12. // 加入缓存
  13. registerDependentBean(propertyName, beanName);
  14. if (logger.isTraceEnabled()) {
  15. logger.trace("Added autowiring by name from bean name '" + beanName +
  16. "' via property '" + propertyName + "' to bean named '" + propertyName + "'");
  17. }
  18. } else {
  19. if (logger.isTraceEnabled()) {
  20. logger.trace("Not autowiring property '" + propertyName + "' of bean '" + beanName +
  21. "' by name: no matching bean found");
  22. }
  23. }
  24. }
  25. }

过程:

  1. 首先通过方法 unsatisfiedNonSimpleProperties 过滤得到属性;
  2. 遍历这些属性,判断是否为注册的 bean,进而得到该 bean,加入到 MutablePropertyValues,并加入到缓存中(便于销毁)。

    unsatisfiedNonSimpleProperties

    过滤得到需要填充的属性,那么得到哪些属性?

  3. 属性有 set 方法;

  4. 属性不是被排除的;
  5. 不是当前对象的属性;
  6. 属性类型不是简单的类型比如:String,Number 子类 或者 简单类型的数组。

所以得到的是引用类型的属性。

  1. protected String[] unsatisfiedNonSimpleProperties(AbstractBeanDefinition mbd, BeanWrapper bw) {
  2. Set<String> result = new TreeSet<>();
  3. PropertyValues pvs = mbd.getPropertyValues();
  4. // PropertyDescriptor:java.beans提供,获取当前Bean的类里面具体的属性和其getter, setter方法
  5. PropertyDescriptor[] pds = bw.getPropertyDescriptors();
  6. for (PropertyDescriptor pd : pds) {
  7. // pd.getWriteMethod() != null :属性有set方法
  8. // !isExcludedFromDependencyCheck(pd) :属性不是从依赖项检查中排除的
  9. // !pvs.contains(pd.getName()) :pvs中不包含
  10. // !BeanUtils.isSimpleProperty(pd.getPropertyType()) :不是简单的类型比如:String,Number子类等等
  11. if (pd.getWriteMethod() != null
  12. && !isExcludedFromDependencyCheck(pd)
  13. && !pvs.contains(pd.getName())
  14. && !BeanUtils.isSimpleProperty(pd.getPropertyType())) {
  15. result.add(pd.getName());
  16. }
  17. }
  18. return StringUtils.toStringArray(result);
  19. }

registerDependentBean

将属性依赖的 bean 加入缓存中。为了以后统一销毁用。
这涉及到两个缓存:dependentBeans,dependenciesForBeanMap。
假设:有bean:a、b、c、d 都包含属性 bean:dog (a,b,c,d,dog 是 bean 的 name)
dependentBeans:dog-{a,b,c,d}
dependenciesForBeanMap: a-{dog}, b-{dog},c-{dog}, d-{dog},
源码如下:

  1. public void registerDependentBean(String beanName, String dependentBeanName) {
  2. /**
  3. * 缓存。比如Bean: a,b,c,d 都有属性Bean: dog
  4. *
  5. * dependentBeanMap : dog-[a,b,c,d]
  6. * dependenciesForBeanMap:a-[dog,cat],b-[dog]
  7. */
  8. String canonicalName = canonicalName(beanName);
  9. synchronized (this.dependentBeanMap) {
  10. Set<String> dependentBeans =
  11. this.dependentBeanMap.computeIfAbsent(canonicalName, k -> new LinkedHashSet<>(8));
  12. if (!dependentBeans.add(dependentBeanName)) {
  13. return;
  14. }
  15. }
  16. synchronized (this.dependenciesForBeanMap) {
  17. Set<String> dependenciesForBean =
  18. this.dependenciesForBeanMap
  19. .computeIfAbsent(dependentBeanName, k -> new LinkedHashSet<>(8));
  20. dependenciesForBean.add(canonicalName);
  21. }
  22. }

打码测试

准备bean

  1. public class Dog {
  2. private String name;
  3. private Integer age;
  4. public Dog() {
  5. System.out.println("Dog init!!");
  6. }
  7. public Dog(String name, Integer age) {
  8. System.out.println("Dog init!!");
  9. this.name = name;
  10. this.age = age;
  11. }
  12. public void say() {
  13. System.out.println("wwwwwwwww");
  14. }
  15. public String getName() {
  16. return name;
  17. }
  18. public void setName(String name) {
  19. this.name = name;
  20. }
  21. public Integer getAge() {
  22. return age;
  23. }
  24. public void setAge(Integer age) {
  25. this.age = age;
  26. }
  27. }

测试bean依赖上面的bean

  1. public class AutowireByNameService {
  2. private Dog dog;
  3. public void setDog(Dog dog) {
  4. this.dog = dog;
  5. }
  6. public void doSomething() {
  7. dog.say();
  8. }
  9. }

加入容器

  1. <?xml version="1.0" encoding="UTF-8"?>
  2. <beans
  3. xmlns="http://www.springframework.org/schema/beans"
  4. xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  5. xsi:schemaLocation="http://www.springframework.org/schema/beans
  6. http://www.springframework.org/schema/beans/spring-beans-3.0.xsd">
  7. <bean id="dog" class="cn.lichenghao.populateBean.entity.Dog">
  8. <property name="name" value="Tom"/>
  9. <property name="age" value="12"/>
  10. </bean>
  11. <bean id="autowireByNameService"
  12. class="cn.lichenghao.populateBean.service.AutowireByNameService" autowire="byName"/>
  13. </beans>

测试

  1. @DisplayName("测试根据属性名称注入")
  2. @Test
  3. public void autowireByNameServiceTest() {
  4. ClassPathXmlApplicationContext classPathXmlApplicationContext
  5. = new ClassPathXmlApplicationContext("populateBean/s1.xml");
  6. AutowireByNameService bean = classPathXmlApplicationContext.getBean(AutowireByNameService.class);
  7. bean.doSomething();
  8. }

默认情况下,依赖bean的名称首字母小写去匹配。如果把 xml 中的配置的 id 修改为其他值,那么就会找不到了。
会报错哦!

根据类型获取属性 autowireByType

  1. protected void autowireByType(
  2. String beanName, AbstractBeanDefinition mbd, BeanWrapper bw, MutablePropertyValues pvs) {
  3. TypeConverter converter = getCustomTypeConverter();
  4. if (converter == null) {
  5. converter = bw;
  6. }
  7. Set<String> autowiredBeanNames = new LinkedHashSet<>(4);
  8. String[] propertyNames = unsatisfiedNonSimpleProperties(mbd, bw);
  9. for (String propertyName : propertyNames) {
  10. try {
  11. PropertyDescriptor pd = bw.getPropertyDescriptor(propertyName);
  12. // Don't try autowiring by type for type Object: never makes sense,
  13. // even if it technically is a unsatisfied, non-simple property.
  14. if (Object.class != pd.getPropertyType()) {
  15. MethodParameter methodParam = BeanUtils.getWriteMethodParameter(pd);
  16. // Do not allow eager init for type matching in case of a prioritized post-processor.
  17. boolean eager = !(bw.getWrappedInstance() instanceof PriorityOrdered);
  18. DependencyDescriptor desc = new AutowireByTypeDependencyDescriptor(methodParam, eager);
  19. Object autowiredArgument
  20. = resolveDependency(desc, beanName, autowiredBeanNames, converter);
  21. if (autowiredArgument != null) {
  22. pvs.add(propertyName, autowiredArgument);
  23. }
  24. for (String autowiredBeanName : autowiredBeanNames) {
  25. registerDependentBean(autowiredBeanName, beanName);
  26. if (logger.isTraceEnabled()) {
  27. logger.trace("Autowiring by type from bean name '"
  28. + beanName + "' via property '"
  29. + propertyName + "' to bean named '" + autowiredBeanName + "'");
  30. }
  31. }
  32. autowiredBeanNames.clear();
  33. }
  34. } catch (BeansException ex) {
  35. throw new UnsatisfiedDependencyException(mbd.getResourceDescription()
  36. , beanName, propertyName, ex);
  37. }
  38. }
  39. }

同样首先过滤得到需要填充的属性;

流程4 - 解析注解相关处理器

后处理器,主要用来处理一些注解注入,如:
AutowiredAnnotationBeanPostProcessor 用于处理 @Autowired 和 @Value 注解;
CommonAnnotationBeanPostProcessor 用于处理 @Resource 注解。

  1. // 是否有后处理器
  2. boolean hasInstAwareBpps = hasInstantiationAwareBeanPostProcessors();
  3. // 依赖检查
  4. boolean needsDepCheck = (mbd.getDependencyCheck() != AbstractBeanDefinition.DEPENDENCY_CHECK_NONE);
  5. PropertyDescriptor[] filteredPds = null;
  6. if (hasInstAwareBpps) {
  7. if (pvs == null) {
  8. pvs = mbd.getPropertyValues();
  9. }
  10. for (BeanPostProcessor bp : getBeanPostProcessors()) {
  11. if (bp instanceof InstantiationAwareBeanPostProcessor) {
  12. InstantiationAwareBeanPostProcessor ibp = (InstantiationAwareBeanPostProcessor) bp;
  13. PropertyValues pvsToUse = ibp.postProcessProperties(pvs, bw.getWrappedInstance(), beanName);
  14. if (pvsToUse == null) {
  15. if (filteredPds == null) {
  16. filteredPds = filterPropertyDescriptorsForDependencyCheck(bw, mbd.allowCaching);
  17. }
  18. pvsToUse = ibp.postProcessPropertyValues(pvs, filteredPds, bw.getWrappedInstance()
  19. , beanName);
  20. if (pvsToUse == null) {
  21. return;
  22. }
  23. }
  24. pvs = pvsToUse;
  25. }
  26. }
  27. }
  28. if (needsDepCheck) {
  29. if (filteredPds == null) {
  30. filteredPds = filterPropertyDescriptorsForDependencyCheck(bw, mbd.allowCaching);
  31. }
  32. checkDependencies(beanName, mbd, filteredPds, pvs);
  33. }

流程5 - applyPropertyValues

将上面自动装配的属性值设置到对象中。
首先是参数校验和安全机制处理

  1. // 参数校验
  2. if (pvs.isEmpty()) {
  3. return;
  4. }
  5. // 安全机制特权处理
  6. if (System.getSecurityManager() != null && bw instanceof BeanWrapperImpl) {
  7. ((BeanWrapperImpl) bw).setSecurityContext(getAccessControlContext());
  8. }

继续:判断属性是否已经准备好可以设置到对象中,如果已经准备好,那么就直接设置就完毕了;没有的话拿到原始的属性键值对继续处理。

  1. MutablePropertyValues mpvs = null;
  2. List<PropertyValue> original;
  3. // 判断是否为MutablePropertyValues的实例
  4. if (pvs instanceof MutablePropertyValues) {
  5. mpvs = (MutablePropertyValues) pvs;
  6. // 默认情况下isConverted是false
  7. if (mpvs.isConverted()) {
  8. // Shortcut: use the pre-converted values as-is.
  9. try {
  10. // 如果已经转换好了,那么直接设置属性值即可
  11. bw.setPropertyValues(mpvs);
  12. return;
  13. } catch (BeansException ex) {
  14. throw new BeanCreationException(
  15. mbd.getResourceDescription(), beanName, "Error setting property values", ex);
  16. }
  17. }
  18. original = mpvs.getPropertyValueList();
  19. } else {
  20. // 获取属性键值对集合
  21. original = Arrays.asList(pvs.getPropertyValues());
  22. }

继续:获取值解析器,用于解析属性相关信息

  1. // 获取类型转换器
  2. TypeConverter converter = getCustomTypeConverter();
  3. if (converter == null) {
  4. converter = bw;
  5. }
  6. // 值解析器
  7. BeanDefinitionValueResolver valueResolver
  8. = new BeanDefinitionValueResolver(this, beanName, mbd, converter);

继续:遍历每一个属性,创建属性的深拷贝

  1. for (PropertyValue pv : original) {
  2. if (pv.isConverted()) {
  3. deepCopy.add(pv);
  4. } else {
  5. // 属性名称
  6. String propertyName = pv.getName();
  7. // 属性的原始值,可能是一个:RuntimeBeanNameReference<otherBean> 引用类型
  8. Object originalValue = pv.getValue();
  9. // 如果属性对象是AutowiredPropertyMarker的实例,那么获取其原始值
  10. if (originalValue == AutowiredPropertyMarker.INSTANCE) {
  11. Method writeMethod = bw.getPropertyDescriptor(propertyName).getWriteMethod();
  12. if (writeMethod == null) {
  13. throw new IllegalArgumentException("Autowire marker
  14. for property without write method: " + pv);
  15. }
  16. originalValue = new DependencyDescriptor(new MethodParameter(writeMethod, 0), true);
  17. }
  18. // 利用值解析器获取值,并将其设置为已经转换好的属性值
  19. Object resolvedValue = valueResolver.resolveValueIfNecessary(pv, originalValue);
  20. Object convertedValue = resolvedValue;
  21. // 判断属性是否是可以转换的
  22. // 判断 bw.isWritableProperty(propertyName)
  23. // --是否有set方法
  24. // 判断 PropertyAccessorUtils.isNestedOrIndexedProperty(propertyName)
  25. // --检查给定的属性是否为索引属性或嵌套属性
  26. boolean convertible = bw.isWritableProperty(propertyName) &&
  27. !PropertyAccessorUtils.isNestedOrIndexedProperty(propertyName);
  28. // 符合条件设置 convertedValue
  29. if (convertible) {
  30. convertedValue = convertForProperty(resolvedValue, propertyName, bw, converter);
  31. }
  32. // Possibly store converted value in merged bean definition,
  33. // in order to avoid re-conversion for every created bean instance.
  34. // 如果解析后的值和原始值是一样的
  35. if (resolvedValue == originalValue) {
  36. if (convertible) {
  37. pv.setConvertedValue(convertedValue);
  38. }
  39. deepCopy.add(pv);
  40. // 必须是字符串类型
  41. // 不是动态的字符串
  42. // 不是集合也不是数组
  43. } else if (convertible && originalValue instanceof TypedStringValue &&
  44. !((TypedStringValue) originalValue).isDynamic() &&
  45. !(convertedValue instanceof Collection || ObjectUtils.isArray(convertedValue))) {
  46. pv.setConvertedValue(convertedValue);
  47. deepCopy.add(pv);
  48. // 其他情况
  49. } else {
  50. resolveNecessary = true;
  51. deepCopy.add(new PropertyValue(pv, convertedValue));
  52. }
  53. }
  54. }

最后,将属性设置到对象上

  1. try {
  2. bw.setPropertyValues(new MutablePropertyValues(deepCopy));
  3. } catch (BeansException ex) {
  4. throw new BeanCreationException(
  5. mbd.getResourceDescription(), beanName, "Error setting property values", ex);
  6. }