views:

1172

answers:

3

I'm using Spring 2.5.6. I have a bean whose properties are being assign from a property file via a PropertyPlaceholderConfigurer. I'm wondering whether its possible to have the property of the bean updated when the property file is modified. There would be for example some periodic process which checks the last modified date of the property file, and if it has changed, reload the bean.

I'm wondering if there is already something that satisfies my requirements. If not, what would be the best approach to solving this problem?

Thanks for your help.

A: 

One way to do this is to embed a groovy console in your application. Here's some instructions. They were very simple to do, btw - took me very little time even though I'm not that familiar with groovy.

Once you do that you can simply go into the console and change values inside the live application on the fly.

Steve B.
+2  A: 

If you want dynamic properties at runtime, perhaps another way to do it is JMX.

duffymo
+2  A: 

Might also look into useing Spring's PropertyOverrideConfigurer. Could re-read the properties and re-apply it in some polling/schedular bean.

It does depend on how the actual configured beans use these properties. They might, for example, indirectly cache them somewhere themself.

jor
It seems this is the most straightforward approach, and is what we'll end up doing. Thanks
Il-Bhima