Daily Archives: October 28, 2004

Persistable bean values in Spring BeanFactory

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?



Filed under Uncategorized