Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsWhite Papers
Discussion GroupsFirst AidDatabasesJavaBeansGUIJava 3DVirtual MachineCORBASecurityToolsGeneral
Java DirectoryOpen Source ProjectsSample Book ChaptersUser GroupsWeb Resources
Related Topics
Databases.NETMore Topics ...

Java Forum / General / September 2007

Tip: Looking for answers? Try searching our database.

Saving performance when reloading xml file

Thread view: 
Bertram Hurtig - 07 Sep 2007 07:32 GMT
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
Joshua Cranmer - 07 Sep 2007 21:46 GMT
> 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.

Signature

Beware of bugs in the above code; I have only proved it correct, not
tried it. -- Donald E. Knuth



Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.