@Test(expected = IOException.class) public void testNotfound() throws Exception { final FileWatcher watcher = new FileWatcher(new NIOEventWatchService()); final Local file = new Local(System.getProperty("java.io.tmpdir") + "/notfound", UUID.randomUUID().toString()); assertFalse(file.exists()); watcher.register(file.getParent(), new FileWatcher.DefaultFileFilter(file), new DisabledFileWatcherListener()); }
@Override public WatchKey register(final Watchable folder, final WatchEvent.Kind<?>[] events, final WatchEvent.Modifier... modifiers) throws IOException { if(null == monitor) { monitor = FileSystems.getDefault().newWatchService(); } final WatchKey key = folder.register(monitor, events, modifiers); if(log.isInfoEnabled()) { log.info(String.format("Registered for events for %s", key)); } return key; }
NIOEventWatchService implements RegisterWatchService { @Override public WatchKey register(final Watchable folder, final WatchEvent.Kind<?>[] events, final WatchEvent.Modifier... modifiers) throws IOException { if(null == monitor) { monitor = FileSystems.getDefault().newWatchService(); } final WatchKey key = folder.register(monitor, events, modifiers); if(log.isInfoEnabled()) { log.info(String.format("Registered for events for %s", key)); } return key; } }
NIOEventWatchService implements RegisterWatchService { @Override public WatchKey register(final Watchable folder, final WatchEvent.Kind<?>[] events, final WatchEvent.Modifier... modifiers) throws IOException { if(null == monitor) { monitor = FileSystems.getDefault().newWatchService(); } final WatchKey key = folder.register(monitor, events, modifiers); if(log.isInfoEnabled()) { log.info(String.format("Registered for events for %s", key)); } return key; }  }
NIOEventWatchService implements RegisterWatchService { @Override public WatchKey register(final Watchable folder, final WatchEvent.Kind<?>[] events, final WatchEvent.Modifier... modifiers) throws IOException { if(null == monitor) { monitor = FileSystems.getDefault().newWatchService(); } final WatchKey key = folder.register(monitor, events, modifiers); if(log.isInfoEnabled()) { log.info(String.format("Registered for events for %s", key)); } return key; }  @Override WatchKey register(final Watchable folder, final WatchEvent.Kind<?>[] events,
                             final WatchEvent.Modifier... modifiers); @Override void release(); @Override void close(); @Override WatchKey poll(); @Override WatchKey poll(final long timeout, final TimeUnit unit); @Override WatchKey take(); }
NIOEventWatchService implements RegisterWatchService { @Override public WatchKey register(final Watchable folder, final WatchEvent.Kind<?>[] events, final WatchEvent.Modifier... modifiers) throws IOException { if(null == monitor) { monitor = FileSystems.getDefault().newWatchService(); } final WatchKey key = folder.register(monitor, events, modifiers); if(log.isInfoEnabled()) { log.info(String.format("Registered for events for %s", key)); } return key; }  @Override WatchKey register(final Watchable folder, final WatchEvent.Kind<?>[] events,
                             final WatchEvent.Modifier... modifiers); @Override void release(); @Override void close(); @Override WatchKey poll(); @Override WatchKey poll(final long timeout, final TimeUnit unit); @Override WatchKey take();  }