@Test(timeout = 2000) public void testWatchForOneEventType() throws IOException, InterruptedException { JimfsPath path = createDirectory(); watcher.register(path, ImmutableList.of(ENTRY_CREATE)); Files.createFile(path.resolve("foo")); assertWatcherHasEvents(new Event<>(ENTRY_CREATE, 1, fs.getPath("foo"))); Files.createFile(path.resolve("bar")); Files.createFile(path.resolve("baz")); assertWatcherHasEvents( new Event<>(ENTRY_CREATE, 1, fs.getPath("bar")), new Event<>(ENTRY_CREATE, 1, fs.getPath("baz"))); }
@Override public Key register(Watchable watchable, Iterable<? extends WatchEvent.Kind<?>> eventTypes) throws IOException { JimfsPath path = checkWatchable(watchable); Key key = super.register(path, eventTypes); Snapshot snapshot = takeSnapshot(path); synchronized (this) { snapshots.put(key, snapshot); if (pollingFuture == null) { startPolling(); } } return key; }
PollingWatchService extends AbstractWatchService { @Override public Key register(Watchable watchable, Iterable<? extends WatchEvent.Kind<?>> eventTypes) throws IOException { JimfsPath path = checkWatchable(watchable); Key key = super.register(path, eventTypes); Snapshot snapshot = takeSnapshot(path); synchronized (this) { snapshots.put(key, snapshot); if (pollingFuture == null) { startPolling(); } } return key; } }
PollingWatchService extends AbstractWatchService { @Override public Key register(Watchable watchable, Iterable<? extends WatchEvent.Kind<?>> eventTypes) throws IOException { JimfsPath path = checkWatchable(watchable); Key key = super.register(path, eventTypes); Snapshot snapshot = takeSnapshot(path); synchronized (this) { snapshots.put(key, snapshot); if (pollingFuture == null) { startPolling(); } } return key; } PollingWatchService(
      FileSystemView view,
      PathService pathService,
      FileSystemState fileSystemState,
      long interval,
      TimeUnit timeUnit); }
PollingWatchService extends AbstractWatchService { @Override public Key register(Watchable watchable, Iterable<? extends WatchEvent.Kind<?>> eventTypes) throws IOException { JimfsPath path = checkWatchable(watchable); Key key = super.register(path, eventTypes); Snapshot snapshot = takeSnapshot(path); synchronized (this) { snapshots.put(key, snapshot); if (pollingFuture == null) { startPolling(); } } return key; } PollingWatchService(
      FileSystemView view,
      PathService pathService,
      FileSystemState fileSystemState,
      long interval,
      TimeUnit timeUnit); @Override Key register(Watchable watchable, Iterable<? extends WatchEvent.Kind<?>> eventTypes); @Override synchronized void cancelled(Key key); @Override void close(); }
PollingWatchService extends AbstractWatchService { @Override public Key register(Watchable watchable, Iterable<? extends WatchEvent.Kind<?>> eventTypes) throws IOException { JimfsPath path = checkWatchable(watchable); Key key = super.register(path, eventTypes); Snapshot snapshot = takeSnapshot(path); synchronized (this) { snapshots.put(key, snapshot); if (pollingFuture == null) { startPolling(); } } return key; } PollingWatchService(
      FileSystemView view,
      PathService pathService,
      FileSystemState fileSystemState,
      long interval,
      TimeUnit timeUnit); @Override Key register(Watchable watchable, Iterable<? extends WatchEvent.Kind<?>> eventTypes); @Override synchronized void cancelled(Key key); @Override void close();  }