Forums Register Login

WatchService to return something on a continuous basis to trigger something

+Pie Number of slices to send: Send
Hello,

I have a requirement where I have to call some method based on the changes in the filesystem. I just had a quick look into the WatchService API of Java7 but not sure if it returns something ( variable or object) while in the process of listening, that can be read to trigger another call.
Any hints here will be highly appreciated.

Thanks.
FKA
+Pie Number of slices to send: Send
+Pie Number of slices to send: Send
 

Faraz Ka wrote: have a requirement where I have to call some method based on the changes in the filesystem. I just had a quick look into the WatchService API of Java7 but not sure if it returns something ( variable or object) while in the process of listening, that can be read to trigger another call.


I'm pretty sure it does.

The only thing I would suggest is that you may want to think carefully about this business of "continuous". "Busy" checkers (ie, ones that constantly monitor something, and maintain a state based on what they're monitoring) can be quite resource-intensive; and they can often be substituted with a "passive" check (ie, one that only does a check on request) that may also be able to give you more "up-to-date" results.

The choice will depend on your requirements - obviously, if you have a million requests a second, you might not want to deal with each one individually; but if they're only once an hour, then a passive approach may well be better.

I'm not familiar enough with the WatchService API to know how it works, but I suspect that the docs will tell you. It may even support both approaches.

HIH

Winston
Of course, I found a very beautiful couch. Definitely. And this tiny ad:
a bit of art, as a gift, the permaculture playing cards
https://gardener-gift.com


reply
reply
This thread has been viewed 412 times.
Similar Threads
JTextField ActionListener - user edits vs programmatic edits
jQuery live() custom events
obtain the form "name parameter"
Need a Better way for postgreSOL Triggers
Clarification about WatchService function for ENTRY_MODIFY
More...

All times above are in ranch (not your local) time.
The current ranch time is
Apr 16, 2024 07:39:50.