title: Is there a way for force polling using WatchService?
body: <p>I have working code that listens to a directory using the WatchService and responds to the events I specify.  This works fine and has been tested on both linux and mac (although on the latter it's clear that polling is used).</p>
  
  <p>However, when I deployed this in production it turns out the directory being monitored is an NFS mount.  Since the WatchService uses inotify when running on linux there were never any events triggered because NFS mounts don't trigger inotify events (or something like this, there's more info here, which explains my problem: <a href="https://stackoverflow.com/questions/8476419/java-watchservice-not-generating-events-while-watching-mapped-drives">Java WatchService not generating events while watching mapped drives</a>).</p>
  
  <p>Since my code is already written I'd prefer to force the WatchService to use the polling implementation rather than the inotify one.  Is there a way to do this?</p>
  
  <p>I attempted this by finding the sun.nio.fs.PollingWatchService source code and creating an object directly (instead of using FileSystems.getDefault().newWatchService()) but when registering the service with the Path I got this exception: java.nio.file.ProviderMismatchException.</p>
  
  <p>So, any ideas?  Since I've already implemented the code using the WatchService and WatchKey API it'd be a lot easier to just force polling than rewrite everything using a custom or 3rd-party poller.  Thanks!</p>