Announcement Announcement Module
Collapse
No announcement yet.
Bean actualization problem Page Title Module
Move Remove Collapse
X
Conversation Detail Module
Collapse
  • Filter
  • Time
  • Show
Clear All
new posts

  • Bean actualization problem

    I've got 2 beans:

    xmlBean is responsible for reading data from xml file
    Code:
     <bean id="xmlBean" class="XmlBean">
               <constructor-arg value="${xmlPath}"/>
    </bean>
    controller is one of many similar beans, that do something with data from xml files
    Code:
      <bean id="controller" class="Controller">
                   <property name="xml" ref="xmlBean"/>
    </bean>
    Everything is working, but when user change xml while it is in use, beans are still getting the old data. Only after application restart I can recive new information.

    I've tried "scoping". I set this two beans scope to "prototype", but with no positive results :/, I'm still getting data from time beans where initialized...

    How I can forced bean reinitialization?

    Help

  • #2
    What I woud do is change the behaviour of your xmlBean. Add a method to it that makes it re-read its content. Then call this method every time there is a change to the XML.

    If the change to the XML is done from outside of your application, the you will have to re-read the XML at every access, or at least at regular intervals ...

    Comment


    • #3
      Originally posted by gehel View Post
      What I woud do is change the behaviour of your xmlBean. Add a method to it that makes it re-read its content. Then call this method every time there is a change to the XML.

      If the change to the XML is done from outside of your application, the you will have to re-read the XML at every access, or at least at regular intervals ...

      Really, it is not very advisable as you would have a mix of objects created from old definitions, new definitions etc. The singleton problem arises - they will be no more sigletons As singletons created during first context read will not be destoryed as far as you have application objects that hold references to them, then by second context read ne copies of "singletons" will be created ... . And you end up with enormous mess.

      If you really need dynamic changes, you have to take a look into OSGi direction.

      Regards,
      Oleksandr

      Comment

      Working...
      X