Spring 2.0 Property Reloading
Here’s an updated version of the net.wuenschenswert.spring property reloading package that works with Spring 2.0.x. The last version I posted was developed for Spring 1.2.8, and as it turns out, spring 2.0 has an incompatible change to the PropertyPlaceholderConfigurer super class. So now this code runs with spring 2.0 only. sigh.
31. Juli 2007 um 12:08
[...] I was going to try and come up with a solution for this, but fortunately it seems that <a href=”http://www.wuenschenswert.net/wunschdenken/archives/138″>someone already has</a>. I haven’t tested it yet, but it looks like it will do the job rather nicely. [...]
22. April 2009 um 12:07
This is fantastic stuff, I’m amazed that Spring haven’t incorporated something like this into the framework, it seems like a no-brainer to me as this is something I’ve wanted for ages, and by reading their forums I am not alone. The “default values for properties” that you implemented is excellent too. Have you tried submitting this to them?
I am using this on Spring 2.5.4 and it works a treat, thanks so much!
20. Oktober 2009 um 22:20
This is exactly what I needed. We have an application in production and needed to go through a massive change control process to fix one typo because we need to bounce the box. Now we will never need to!
Works really well with no code changes as you say. Nice work. I have given you full credit in the code.
Have you had any word from the Spring folks about getting this in the Spring distribution? It would be very valuable for the community
Thanks again,
Dave
01. Februar 2010 um 14:25
Great job,
Works perfectly for simple use cases, but you quickly hit the limits.
In fact we’re trying to use reloadable properties in lists and maps (doesn’t work) Doesn’t work also in nested bean definitions. And maybe other cases spring namespaces for instance (haven’t tested that).
Have you thought about those cases? Do you have some work done for it?
Thanks,
Amokrane
16. März 2010 um 18:22
Thanks for this code, which does just what we need.
In Spring 3 this no longer works as it stands because the createInstance hook has been removed from PropertiesFactoryBean - instead mergeProperties is called directly. You can get it working again by updating ReloadablePropertiesFactoryBean - declare a boolean initialised flag and change the createInstance method to:
protected Properties mergeProperties() throws IOException {
if (!initialised) {
initialised = true;
// would like to uninherit from AbstractFactoryBean (but it’s final!)
if (!isSingleton())
throw new RuntimeException(”ReloadablePropertiesFactoryBean only works as singleton”);
reloadableProperties = new ReloadablePropertiesImpl();
if (preListeners != null)
reloadableProperties.setListeners(preListeners);
reload(true);
return reloadableProperties;
} else {
return super.mergeProperties();
}
I am just testing this at the moment, so will let you know if I hit problems