My requirement in my project to monitor a folder. Whenever a xml file gets added or xml file present in that folder gets updated i need to listen to those changes and parse the xml file to get the message. Do you have clue how we can approch that. I thought of using quartz but schedular will execute the job for every certain interval of time instead of executing the job whenever folder gets modified. Whether can we use joblistener or triggerlistener?
Assuming you can be happy with "reasonably quick" notification, say once a minute, its easy.
Better approach is to have a daemon thread sleep, look for file, and if its there, immediately rename it to another directory.
Then release semaphore or other sync technique, to have the "worker" thread do the processing while the "checking" thread takes a nap and does the next lookup.
Its only 30 or so lines of code.
pavithra M K
Joined: Oct 17, 2006
Thank you all for your replies.
i have thought of using JDK1.7 API's for folder monitoring, however JDK1.7 is not yet released we cannot suggest this to customers. And we dont want to use Threads here.
Can i use quartz- job, schedular and trigger listener in this scenario.
JOb -to read the xml file.
trigger listener - to listen to the folder changes and execute the Job.
Actually i want to know how to use trigger listener or job listener or schedule listener in my Java Application.