[ajug-members] File monitoring
Joe Sam Shirah
joe_sam at bellsouth.net
Fri Jun 15 12:59:38 EDT 2007
Hi Mike,
If the "file" is a table in a database, it's not very difficult to
accomplish what you want to do. The basics are to add a trigger that passes
information to a program that does the actual task. Usually the trigger
just sends a message to a queue of some description that the other program
monitors. Database performance and efficiency are the reasons for that sort
of design; the trigger can send minimal data and return.
That's probably the optimal solution and, if possible, I'd get the file
into a database if it isn't already.
If you're stuck with "just a file", you'll run into issues unless the OS
offers some sort of hook. Even then you're not going to be portable. As
you've probably already seen, the "file monitors" available only offer
coarse information about the file as a whole. So, usually with polling, you
can tell that the file was changed. Determining *what* changed is left up
to you.
In that situation, you usually end up making file changes through a
custom class that checks for changes at write time and does whatever is
necessary. Of course, that leaves a hole for changes that come from other
programs where the custom class is not used. That's why I recommend a
database that supports triggers.
That's been my experience; I'd be happy to hear of any other solutions.
HTH,
Joe Sam
Joe Sam Shirah - http://www.conceptgo.com
conceptGO - Consulting/Development/Outsourcing
Java Filter Forum: http://www.ibm.com/developerworks/java/
Just the JDBC FAQs: http://www.jguru.com/faq/JDBC
Going International? http://www.jguru.com/faq/I18N
Que Java400? http://www.jguru.com/faq/Java400
----- Original Message -----
From: "Barnes, Mike" <MB5745 at att.com>
To: "General AJUG membership forum (100-200 messages/month)"
<ajug-members at ajug.org>
Sent: Friday, June 15, 2007 11:13 AM
Subject: [ajug-members] File monitoring
I have a situation where I need to be able to monitor a file for changes
and then load the changes when this file changes.
After doing extensive research on the net I have not been able to come
up with a simple solution to this problem. Does anyone have suggestions
that may help me move forward?
Thanks
Mike Barnes
More information about the ajug-members
mailing list