@Override public WatchKey register( WatchService watcher, Kind<?>[] events, Modifier... modifiers ) throws UnsupportedOperationException, IllegalArgumentException, ClosedWatchServiceException, IOException, SecurityException { return watcher.poll(); }
@Override public void close() throws IOException { if ( isClose ) { return; } gitRepo.getRepository().close(); isClose = true; for ( final WatchService ws : watchServices ) { ws.close(); } watchServices.clear(); events.clear(); provider.onCloseFileSystem( this ); }
@Test @Ignore public void testDaemob() throws InterruptedException { final URI newRepo = URI.create( "git://repo-name" ); final Map<String, ?> env = new HashMap<String, Object>() {{ put( "init", Boolean.TRUE ); }}; FileSystem fs = PROVIDER.newFileSystem( newRepo, env ); WatchService ws = null; ws = fs.newWatchService(); final Path path = fs.getRootDirectories().iterator().next(); path.register( ws, StandardWatchEventKind.ENTRY_CREATE, StandardWatchEventKind.ENTRY_MODIFY, StandardWatchEventKind.ENTRY_DELETE, StandardWatchEventKind.ENTRY_RENAME ); final WatchKey k = ws.take(); final List<WatchEvent<?>> events = k.pollEvents(); for ( WatchEvent object : events ) { if ( object.kind() == StandardWatchEventKind.ENTRY_MODIFY ) { System.out.println( "Modify: " + object.context().toString() ); } if ( object.kind() == StandardWatchEventKind.ENTRY_RENAME ) { System.out.println( "Rename: " + object.context().toString() ); } if ( object.kind() == StandardWatchEventKind.ENTRY_DELETE ) { System.out.println( "Delete: " + object.context().toString() ); } if ( object.kind() == StandardWatchEventKind.ENTRY_CREATE ) { System.out.println( "Created: " + object.context().toString() ); } } }
@Override public WatchKey register( WatchService watcher, Kind<?>... events ) throws UnsupportedOperationException, IllegalArgumentException, ClosedWatchServiceException, IOException, SecurityException { return watcher.poll(); }