spring-framework
spring-framework copied to clipboard
Make the property resolver configurable
Background
Prior to Spring 5.2, when we need to customize the PropertiesLoader, we can subclass PropertyPlaceholderConfigurer
, and override the resolvePlaceholder
method.
Now with PropertySourcesPlaceholderConfigurer
deprecated PropertyPlaceholderConfigurer
, the resolvePlaceholder
method has been moved out of the PlaceHolderConfigurer
and into a separate PropertyResolver
.
Somehow the PropertyResolver
is hardcoded [*]: https://github.com/spring-projects/spring-framework/blob/01bea34569cd3dd00e8691a08ab1a2fc53d6c13e/spring-context/src/main/java/org/springframework/context/support/PropertySourcesPlaceholderConfigurer.java#L157
Due to the hardcode, the only way left for developers to override the resolvePlaceholder
now becomes to duplicate the whole postProcessBeanFactory
method and then provide custom PropertyResolver
.
Changes
Instead of hardcoding a PropertyResolver
as existing and make it very difficult to customize, this PR will point to a factory method to provide the PropertyResolver
as needed.
I believe there is no side effect on this. It only adds the flexibility for customization which has been lost.
Note [*]
Even though PropertyPlaceholderConfigurer
was also using a hardcoded class, https://github.com/spring-projects/spring-framework/blob/01bea34569cd3dd00e8691a08ab1a2fc53d6c13e/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java#L210
It's a private inner class, which even doesn't allow override. However, after several redirects, it eventually points to the resolvePlaceholder
of the current class implementation
https://github.com/spring-projects/spring-framework/blob/01bea34569cd3dd00e8691a08ab1a2fc53d6c13e/spring-beans/src/main/java/org/springframework/beans/factory/config/PropertyPlaceholderConfigurer.java#L250
@1wpro2 Please sign the Contributor License Agreement!
Click here to manually synchronize the status of this Pull Request.
See the FAQ for frequently asked questions.
@1wpro2 Thank you for signing the Contributor License Agreement!
@1zg12 Please sign the Contributor License Agreement!
Click here to manually synchronize the status of this Pull Request.
See the FAQ for frequently asked questions.
@1zg12 Thank you for signing the Contributor License Agreement!
hi @rstoyanchev , can you review this ?
Bump up this, as we are still having issue to overwrite this setting in the newer version of spring. Thanks.