Announcement Announcement Module
Collapse
No announcement yet.
How to handle changing properties with PropertyPlaceholder without disrupting the app Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • How to handle changing properties with PropertyPlaceholder without disrupting the app

    I'd like to use the nice property placeholder syntax for our web-applications configuration, but some of the properties should be changeable at runtime without disrupting the application. (If you change, say, the connectionTimeout on a WebserviceTemplate, this should not interrupt the application.) It is possible to add a mutable PropertySource to the ApplicationContext and call ApplicationContext.refresh() when the configuration changes, but refresh shuts down the application, recreates it and then starts it up again - so a disruption occurs. Of course, you could handle such things with, say, JMX and loads of glue code, but I'd rather keep it simple. Do you have any ideas for that?

    Some things I tried:

    - ApplicationContext.refresh() does the trick, but disrupts the app.

    - One could introduce a custom scope that changes every time the configuration changes. Works but for the "tiny" detail that the provided ObjectFactory uses the preprocessed bean definition that already has the properties replaced with the old values. So nothing is changed for the new bean.

    - Possibly with the custom scope you could use a PropertyOverrideConfigurer and call its processProperties again on the bean factory, but I don't think a PropertyOverrideConfigurer is a good way to configure a large application - especially if the same property value is injected into many beans.

    I've heard that some people handled changing properties by creating a new ApplicationContext in the background and switch it for the old one when it has started, but I'd rather not do something that intrusive if I don't need to.
    Thanks so much!

    Best regards,

    Hans-Peter Störr

  • #2
    Yeah I don't know if there is anything in place for what you are trying to do. I was going to say JMX but looks like you already thought if that. I know they have

    http://static.springsource.org/sprin...ageSource.html

    I wonder if you could register that as a propertySource and set the cache timout to something low and make it work somehow. I have not tried it personally.

    Comment

    Working...
    X