Saving performance when reloading xml file

Discussion in 'Java' started by Bertram Hurtig, Sep 7, 2007.

  1. Hi, I got a J2EE (Spring MVC) application,
    that reads data from an xml file.
    1. Now the client wants to be able to edit this xml file
    just in time, and he wants the application to notice these changes
    and to reload the xml file -
    How can this be done without wasting too much performance?
    I would
    I would like to avoid to load the xml file each time the Controller gets
    called. The only ideas I have would all poll the xml file.

    When polling, maybe there is a way to just poll the date when the file
    has been updated the last time, and to just reload the file in this
    case? (Instead of reloading the entire file each time)

    Anyway, I am not even sure if the reloading thing is a good idea -
    if there is a user that sees the webpage just in the time the xml file
    is beeing updated, and then he does a request to data that doesn't exist
    anymore, wouldn't that crash the entire page, and how could I prevent this?


    Any ideas are welcome.

    Thanks in advance,

    Bertram
    Bertram Hurtig, Sep 7, 2007
    #1
    1. Advertising

  2. Bertram Hurtig wrote:
    > 1. Now the client wants to be able to edit this xml file
    > just in time, and he wants the application to notice these changes
    > and to reload the xml file -
    > How can this be done without wasting too much performance?
    > I would like to avoid to load the xml file each time the Controller gets
    > called. The only ideas I have would all poll the xml file.


    Typically, most update-on-external-edit applications will tend to use
    two methods: file timestamping and filesystem/OS-level notification.
    Java provides no easy way to utilize the latter (to my knowledge; there
    may be some open-source packages that can handle inotify). Therefore,
    your best bet is to poll the file's last-modification time.

    > When polling, maybe there is a way to just poll the date when the file
    > has been updated the last time, and to just reload the file in this
    > case? (Instead of reloading the entire file each time)


    See above.

    > Anyway, I am not even sure if the reloading thing is a good idea -
    > if there is a user that sees the webpage just in the time the xml file
    > is beeing updated, and then he does a request to data that doesn't exist
    > anymore, wouldn't that crash the entire page, and how could I prevent this?


    Any project should have graceful invalidation procedures whenever human
    input is required. For websites, it is not sufficient to assume that an
    error cannot happen just because no internal links access it or the
    webpage does client-side validation. Just validate the data, see that it
    doesn't exist, and gracefully point this out to the user.

    --
    Beware of bugs in the above code; I have only proved it correct, not
    tried it. -- Donald E. Knuth
    Joshua Cranmer, Sep 7, 2007
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John Kandell
    Replies:
    4
    Views:
    4,146
    eeebop
    Dec 10, 2004
  2. Luis Esteban Valencia
    Replies:
    0
    Views:
    2,497
    Luis Esteban Valencia
    Jan 6, 2005
  3. Darren Dale
    Replies:
    4
    Views:
    337
    Darren Dale
    Jul 28, 2004
  4. jacob navia
    Replies:
    37
    Views:
    1,004
    gwowen
    Apr 8, 2010
  5. Lovely Angel For You

    Saving Images While Saving ASP Pages !

    Lovely Angel For You, Oct 2, 2003, in forum: ASP General
    Replies:
    1
    Views:
    196
    Curt_C [MVP]
    Oct 3, 2003
Loading...

Share This Page