Jonathan Kupcho opened SPR-15172 and commented

I was tasked with allowing properties to be programmatically injected rather than from existing properties. Diving into the code, I noticed there was a PropertySource object which seems to have fit the bill perfectly, but wiring up the object properly became a challenge. I wanted the ability to reference existing properties from property files while programmatically wiring other properties. This lead to late binding issues, the ApplicationContext was being wired before the property had a chance to populate, etc.

The use case:

some.property=${prop.source.property}

The prop.source.property would determined by the PropertySource class written by the developer. This wouldn't be based on a file, or command line argument, it would be calculated by the developer.

The problem areas implementing this was within the following class: PropertySourcesPlaceholderConfigurer

There is no (easy) way, as far as I can tell, to wire in custom PropertySource objects without subclassing this class, and overriding a bunch of code manually. Namely, the postProcessBeanFactory method.

Thanks!


No further details from SPR-15172

Comment From: spring-projects-issues

Jonathan Kupcho commented

formatting

Comment From: snicoll

Isn't it what PropertySourcesPlaceholderConfigurer#setPropertySources is all about. This makes sure that only the property sources that you've specified are taken into account. If you need to merge things from a ConfigurableEnvironment you can do so by getting its MutablePropertySources via getPropertySources and add/remove the necessary sources.

If I misunderstood the request, please provide more details and we can reopen.