Announcement Announcement Module
Collapse
No announcement yet.
Refreshing a single bean Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Refreshing a single bean

    Hi all,

    I have a situation where I load quite a lot of singletons into memory. Some of the beans have a large footprint and long load time so they are expensive to reload. I have to be able to "refresh" a single bean on request (ie. someone changed a value in the XML config) but leave the other singletons unaffected.

    I have looked at refreshing the application context but that seems to destroy and recreate all singleton beans - not an option since it is too expensive.
    The application is in a high-availability scenario (financial services) so I can't afford to refresh everything if only one bean needs a refresh.

    What options can I look at to achieve this?

    Thanks in advance for any assistance.

  • #2
    Hi,

    I am having to do the same. Could you let me know how you solved the problem, if you did?

    Thank you

    Comment


    • #3
      Have you thought of using spring jmx http://static.springframework.org/sp...#jmx-interface to accomplish this?

      Comment


      • #4
        Thank you - I did - but I do not want to reload the whole applicationContext - instead just one bean.

        something like
        Code:
        webContext.setBean("myObject", new myObject());
        thank you

        Comment


        • #5
          Still no real solution

          Hi,

          I have looked at JMX but in my opinion its not really a solution. Its great when you want to change a single simple value but in the event of an app context recycling you lose your changes - I have not yet seen a mechanism of persisting that JMX effected change back to the Spring XML.

          I have now decided to move most of my config to a DB, use Spring XML config to wire the high level beans but child beans that need to be "refreshed" are not configured in the XML at all. I then implement a refresh method on thos beans which you can call using JMX.

          Any suggestions or comments are welcome

          Comment


          • #6
            I dare to say that no "real solution" exists at all. Best that you can achive is todevelop some application-specific solution.

            Why?

            It is quite easy - imagine that your bean was injected in a lot of other beans, some of them with consturctor injection into final variables. Then you wish to "reload" this bean. How would you reinject it? And do not forget that source of some those classes may be out of your control.

            Regards,
            Oleksandr

            Originally posted by wjn View Post
            Hi,

            I have looked at JMX but in my opinion its not really a solution. Its great when you want to change a single simple value but in the event of an app context recycling you lose your changes - I have not yet seen a mechanism of persisting that JMX effected change back to the Spring XML.

            I have now decided to move most of my config to a DB, use Spring XML config to wire the high level beans but child beans that need to be "refreshed" are not configured in the XML at all. I then implement a refresh method on thos beans which you can call using JMX.

            Any suggestions or comments are welcome

            Comment

            Working...
            X