I was thinking if the following scenario could be achieved in Spring
BeanFactory:
- use property placeholders inside the definitions ( i mean ${prop.value})
- apply programmatically a PropertyPlaceholderConfigurer to obtain the real values and retrieve the beans
- apply another PropertyPlaceholderConfigurer and obtain another set of beans
Actually this behavior is not available. After applying the first
PropertyPlaceholderConfigurer the values ${prop.value} are lost foreever, so applying another
PropertyPlaceholderConfigurer will do nothing in fact.
The solution I see for solving this are:
- either clone in a way the BeanFactory and apply PropertyPlaceholderConfigurer on the clone (till this moment I couldn't figure out a way to implement this)
- or create a custom BeanFactory (probably by extending DefaultListableBeanFactory) that will be able to keep the original values after applying a property placeholder
Does anybody see any other solution for this?
1 comments:
Hey Pope,
You should be able to write some form of custom post processor that manages this information for you - maybe use something OTHER than the built in post processors. I'm not 100% sure I understand the intended result, but it sounds like you want to go through 2 entire processing cycles (e.g. two bean definition instantiation cycles), which may be problematic with one bean factory; another option is to wrap the beans in target sources or something of that nature... I'll think about this more.
Post a Comment