Java Code Examples for java.nio.file.WatchEvent#Modifier
The following examples show how to use
java.nio.file.WatchEvent#Modifier .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: WindowsWatchService.java From TencentKona-8 with GNU General Public License v2.0 | 5 votes |
@Override WatchKey register(Path path, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException { // delegate to poller return poller.register(path, events, modifiers); }
Example 2
Source File: BuckUnixPath.java From buck with Apache License 2.0 | 5 votes |
@Override public WatchKey register( WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException { // TODO(buck_team): do not recourse to default Path implementation return asDefault().register(watcher, events, modifiers); }
Example 3
Source File: WatchablePath.java From directory-watcher with Apache License 2.0 | 5 votes |
@Override public WatchKey register( WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException { if (watcher == null) { throw new NullPointerException(); } if (!(watcher instanceof AbstractWatchService)) { throw new ProviderMismatchException(); } return ((AbstractWatchService) watcher).register(this, Arrays.asList(events)); }
Example 4
Source File: MacOSXListeningWatchService.java From RxJavaFileUtils with Apache License 2.0 | 5 votes |
@Override WatchKey register(WatchableFile watchableFile, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifers) throws IOException { final File file = watchableFile.toFile(); final Map<File, Long> lastModifiedMap = createLastModifiedMap(file); final String s = file.getAbsolutePath(); final Pointer[] values = {CFStringRef.toCFString(s).getPointer()}; final CFArrayRef pathsToWatch = CarbonAPI.INSTANCE.CFArrayCreate(null, values, CFIndex.valueOf(1), null); final MacOSXWatchKey watchKey = new MacOSXWatchKey(watchableFile, this, events); final double latency = 1.0; /* Latency in seconds */ final long kFSEventStreamEventIdSinceNow = -1; // this is 0xFFFFFFFFFFFFFFFF final int kFSEventStreamCreateFlagNoDefer = 0x00000002; final CarbonAPI.FSEventStreamCallback callback = new MacOSXListeningCallback(watchKey, lastModifiedMap); callbackList.add(callback); final FSEventStreamRef stream = CarbonAPI.INSTANCE.FSEventStreamCreate( Pointer.NULL, callback, Pointer.NULL, pathsToWatch, kFSEventStreamEventIdSinceNow, latency, kFSEventStreamCreateFlagNoDefer); final CFRunLoopThread thread = new CFRunLoopThread(stream, file); thread.setDaemon(true); thread.start(); threadList.add(thread); return watchKey; }
Example 5
Source File: AbstractNIO2Watcher.java From HotswapAgent with GNU General Public License v2.0 | 5 votes |
/** * Get a Watch event modifier. These are platform specific and hiden in sun api's * * @see <a href="https://github.com/HotswapProjects/HotswapAgent/issues/41"> * Issue#41</a> * @see <a href= * "http://stackoverflow.com/questions/9588737/is-java-7-watchservice-slow-for-anyone-else"> * Is Java 7 WatchService Slow for Anyone Else?</a> */ static WatchEvent.Modifier getWatchEventModifier(String claz, String field) { try { Class<?> c = Class.forName(claz); Field f = c.getField(field); return (WatchEvent.Modifier) f.get(c); } catch (Exception e) { return null; } }
Example 6
Source File: FSEventWatchService.java From cyberduck with GNU General Public License v3.0 | 5 votes |
@Override public WatchKey register(final Watchable folder, final WatchEvent.Kind<?>[] events, final WatchEvent.Modifier... modifiers) throws IOException { if(log.isInfoEnabled()) { log.info(String.format("Register file %s for events %s", folder, Arrays.toString(events))); } final Pointer[] values = { CFStringRef.toCFString(folder.toString()).getPointer()}; final MacOSXWatchKey key = new MacOSXWatchKey(folder, this, events); final double latency = 1.0; // Latency in seconds final Map<File, Long> timestamps = createLastModifiedMap(new File(folder.toString())); final FSEvents.FSEventStreamCallback callback = new Callback(key, timestamps); final FSEventStreamRef stream = library.FSEventStreamCreate( Pointer.NULL, callback, Pointer.NULL, library.CFArrayCreate(null, values, CFIndex.valueOf(1), null), -1, latency, kFSEventStreamCreateFlagNoDefer); final CountDownLatch lock = new CountDownLatch(1); final CFRunLoop loop = new CFRunLoop(lock, stream); threadFactory.newThread(loop).start(); Uninterruptibles.awaitUninterruptibly(lock); loops.put(key, loop); callbacks.put(key, callback); return key; }
Example 7
Source File: WindowsWatchService.java From openjdk-jdk8u with GNU General Public License v2.0 | 5 votes |
@Override WatchKey register(Path path, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException { // delegate to poller return poller.register(path, events, modifiers); }
Example 8
Source File: WindowsWatchService.java From dragonwell8_jdk with GNU General Public License v2.0 | 5 votes |
@Override WatchKey register(Path path, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException { // delegate to poller return poller.register(path, events, modifiers); }
Example 9
Source File: RegisterWatchService.java From cyberduck with GNU General Public License v3.0 | 4 votes |
WatchKey register(Watchable folder, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException;
Example 10
Source File: InMemoryPath.java From find with MIT License | 4 votes |
@Override public WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException { throw new NotImplementedException("register() has not been implemented"); }
Example 11
Source File: WritablePath.java From groovy with Apache License 2.0 | 4 votes |
@Override public WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException { return delegate.register(watcher, events, modifiers); }
Example 12
Source File: GcsPath.java From beam with Apache License 2.0 | 4 votes |
@Override public WatchKey register( WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException { throw new UnsupportedOperationException(); }
Example 13
Source File: ExtendedOptions.java From Bytecoder with Apache License 2.0 | 4 votes |
/** * Register this internal option as a WatchEvent.Modifier. */ public void register(WatchEvent.Modifier option) { registerInternal(option, null); }
Example 14
Source File: AbstractWatchServiceTest.java From jimfs with Apache License 2.0 | 4 votes |
@Override public WatchKey register( WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException { return register(watcher, events); }
Example 15
Source File: ExtendedOptions.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Register this internal option as a WatchEvent.Modifier. */ public void register(WatchEvent.Modifier option) { registerInternal(option, null); }
Example 16
Source File: PollingWatchService.java From openjdk-jdk9 with GNU General Public License v2.0 | 4 votes |
/** * Register the given file with this watch service */ @Override WatchKey register(final Path path, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException { // check events - CCE will be thrown if there are invalid elements final Set<WatchEvent.Kind<?>> eventSet = new HashSet<>(events.length); for (WatchEvent.Kind<?> event: events) { // standard events if (event == StandardWatchEventKinds.ENTRY_CREATE || event == StandardWatchEventKinds.ENTRY_MODIFY || event == StandardWatchEventKinds.ENTRY_DELETE) { eventSet.add(event); continue; } // OVERFLOW is ignored if (event == StandardWatchEventKinds.OVERFLOW) { continue; } // null/unsupported if (event == null) throw new NullPointerException("An element in event set is 'null'"); throw new UnsupportedOperationException(event.name()); } if (eventSet.isEmpty()) throw new IllegalArgumentException("No events to register"); // Extended modifiers may be used to specify the sensitivity level int sensitivity = 10; if (modifiers.length > 0) { for (WatchEvent.Modifier modifier: modifiers) { if (modifier == null) throw new NullPointerException(); if (ExtendedOptions.SENSITIVITY_HIGH.matches(modifier)) { sensitivity = ExtendedOptions.SENSITIVITY_HIGH.parameter(); } else if (ExtendedOptions.SENSITIVITY_MEDIUM.matches(modifier)) { sensitivity = ExtendedOptions.SENSITIVITY_MEDIUM.parameter(); } else if (ExtendedOptions.SENSITIVITY_LOW.matches(modifier)) { sensitivity = ExtendedOptions.SENSITIVITY_LOW.parameter(); } else { throw new UnsupportedOperationException("Modifier not supported"); } } } // check if watch service is closed if (!isOpen()) throw new ClosedWatchServiceException(); // registration is done in privileged block as it requires the // attributes of the entries in the directory. try { int value = sensitivity; return AccessController.doPrivileged( new PrivilegedExceptionAction<PollingWatchKey>() { @Override public PollingWatchKey run() throws IOException { return doPrivilegedRegister(path, eventSet, value); } }); } catch (PrivilegedActionException pae) { Throwable cause = pae.getCause(); if (cause != null && cause instanceof IOException) throw (IOException)cause; throw new AssertionError(pae); } }
Example 17
Source File: MetricPath.java From graphouse with Apache License 2.0 | 4 votes |
@Override public WatchKey register(WatchService watcher, WatchEvent.Kind<?>[] events, WatchEvent.Modifier... modifiers) throws IOException { throw new UnsupportedOperationException("Unexpected call!"); }
Example 18
Source File: FileSystemOption.java From Bytecoder with Apache License 2.0 | 2 votes |
/** * Register this internal option as a WatchEvent.Modifier with the * given parameter. */ public void register(WatchEvent.Modifier option, T param) { internalOption.register(option, param); }
Example 19
Source File: ExtendedOptions.java From Bytecoder with Apache License 2.0 | 2 votes |
/** * Register this internal option as a WatchEvent.Modifier with the * given parameter. */ public void register(WatchEvent.Modifier option, T param) { registerInternal(option, param); }
Example 20
Source File: ExtendedOptions.java From openjdk-jdk9 with GNU General Public License v2.0 | 2 votes |
/** * Register this internal option as a WatchEvent.Modifier with the * given parameter. */ public void register(WatchEvent.Modifier option, T param) { registerInternal(option, param); }