Saving performance when reloading xml file

B

Bertram Hurtig

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
 
J

Joshua Cranmer

Bertram said:
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.
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,766
Messages
2,569,569
Members
45,042
Latest member
icassiem

Latest Threads

Top