From d64f8c1a05f9b5a3cd6451a20261c5e6f7b4108d Mon Sep 17 00:00:00 2001 From: Stephane Nicoll Date: Thu, 10 Feb 2022 15:01:58 +0100 Subject: [PATCH] Make BeanDefinitionValueResolver public Closes gh-28029 --- .../support/BeanDefinitionValueResolver.java | 26 ++++++++++++++++--- 1 file changed, 23 insertions(+), 3 deletions(-) diff --git a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValueResolver.java b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValueResolver.java index 0468bc4aadd..be3a62e2945 100644 --- a/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValueResolver.java +++ b/spring-beans/src/main/java/org/springframework/beans/factory/support/BeanDefinitionValueResolver.java @@ -1,5 +1,5 @@ /* - * Copyright 2002-2021 the original author or authors. + * Copyright 2002-2022 the original author or authors. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. @@ -25,6 +25,7 @@ import java.util.Properties; import java.util.Set; import org.springframework.beans.BeanWrapper; +import org.springframework.beans.BeanWrapperImpl; import org.springframework.beans.BeansException; import org.springframework.beans.TypeConverter; import org.springframework.beans.factory.BeanCreationException; @@ -59,7 +60,7 @@ import org.springframework.util.StringUtils; * @since 1.2 * @see AbstractAutowireCapableBeanFactory */ -class BeanDefinitionValueResolver { +public class BeanDefinitionValueResolver { private final AbstractAutowireCapableBeanFactory beanFactory; @@ -71,7 +72,8 @@ class BeanDefinitionValueResolver { /** - * Create a BeanDefinitionValueResolver for the given BeanFactory and BeanDefinition. + * Create a BeanDefinitionValueResolver for the given BeanFactory and BeanDefinition, + * using the given {@link TypeConverter}. * @param beanFactory the BeanFactory to resolve against * @param beanName the name of the bean that we work on * @param beanDefinition the BeanDefinition of the bean that we work on @@ -86,6 +88,24 @@ class BeanDefinitionValueResolver { this.typeConverter = typeConverter; } + /** + * Create a BeanDefinitionValueResolver for the given BeanFactory and BeanDefinition + * using a default {@link TypeConverter}. + * @param beanFactory the BeanFactory to resolve against + * @param beanName the name of the bean that we work on + * @param beanDefinition the BeanDefinition of the bean that we work on + */ + public BeanDefinitionValueResolver(AbstractAutowireCapableBeanFactory beanFactory, String beanName, + BeanDefinition beanDefinition) { + + this.beanFactory = beanFactory; + this.beanName = beanName; + this.beanDefinition = beanDefinition; + BeanWrapper beanWrapper = new BeanWrapperImpl(); + beanFactory.initBeanWrapper(beanWrapper); + this.typeConverter = beanWrapper; + } + /** * Given a PropertyValue, return a value, resolving any references to other