Announcement Announcement Module
No announcement yet.
Hot-reload/refresh of a Spring bean/context ? Page Title Module
Move Remove Collapse
Conversation Detail Module
  • Filter
  • Time
  • Show
Clear All
new posts

  • Hot-reload/refresh of a Spring bean/context ?


    I'm storing beans classes and applicationContext files in multiple jar files (all under app/WEB-INF/lib).

    I need to be able to do a live refresh of beans/contexts, after overwriting one of the jars with a new one : a tomcat shutdown is not an option, neither is a full webapp war reload/redeploy.

    Is there a programmatic way for doing this ? Ideally, I'd like to refresh a single bean definition (and refresh its bean dependencies/injections), without reloading the whole context : I've been looking into JMX support, and I believe some refresh() method coupled with a JMX listener/notification would be the best scenario (the listener would trigger some "please wait while the bean is being reloaded" information message).

    Is it possible to refresh a single bean ? If not, reloading the whole context is still an option, but in this case I'd like to be able to "tell" whenever the context is fully redeployed : I would like to "pause" some webapp flow until the context is truly available again.

    I've looked into the documentation, but it is still unclear to me.
    Could anyone help ?

    thanks !

  • #2


    • #3
      This doesn't seem to work with Spring 2.0.8:

      I'm using the getBeanFactory().destroySingletons() which works fine but after that Spring doesn't fully reinitialized it's configuration. I have an extended PropertyPlaceholderConfigurer to memorize the properties. I see that it's constructed but the properties aren't re-resolved.

      I've also looked into using the start()/stop() and close() methods but I have the same results. When I used Spring 1.2.x, I could call the refresh() method.

      Please help.