Java 类java.nio.file.WatchEvent.Modifier 实例源码

项目:che    文件:FileWatcherService.java   
/**
 * This is required to speed up mac based file watcher implementations
 *
 * @return sensitivity watch event modifier
 */
private static Modifier[] getWatchEventModifiers() {
  String className = "com.sun.nio.file.SensitivityWatchEventModifier";

  try {
    Class<?> c = Class.forName(className);
    Field f = c.getField("HIGH");
    Modifier modifier = cast(f.get(c));
    LOG.debug("Class '{}' is found in classpath setting corresponding watch modifier", className);

    return new Modifier[] {modifier};
  } catch (Exception e) {
    LOG.debug("Class '{}' is not found in classpath, falling to default mode", className, e);

    return new Modifier[] {};
  }
}
项目:jooby    文件:FileMonitorTest.java   
@SuppressWarnings("unchecked")
@Test
public void registerTreeRecursive() throws Exception {
  new MockUnit(Injector.class, Env.class, WatchService.class, FileEventOptions.class, Path.class,
      WatchEvent.Kind.class, WatchEvent.Modifier.class, WatchKey.class)
      .expect(newThread)
      .expect(registerTree(true, false))
      .expect(takeInterrupt)
      .run(unit -> {
        FileMonitor monitor = new FileMonitor(unit.get(Injector.class), unit.get(Env.class),
            unit.get(WatchService.class),
            ImmutableSet.of(unit.get(FileEventOptions.class)));
        unit.captured(ThreadFactory.class).get(0).newThread(monitor);
      }, unit -> {
        unit.captured(Runnable.class).get(0).run();
        unit.captured(FileVisitor.class).get(0).preVisitDirectory(unit.get(Path.class), null);
      });
}
项目:jooby    文件:FileMonitorTest.java   
@Test
public void registerTree() throws Exception {
  new MockUnit(Injector.class, Env.class, WatchService.class, FileEventOptions.class, Path.class,
      WatchEvent.Kind.class, WatchEvent.Modifier.class, WatchKey.class)
      .expect(newThread)
      .expect(registerTree(false, false))
      .expect(takeInterrupt)
      .run(unit -> {
        FileMonitor monitor = new FileMonitor(unit.get(Injector.class), unit.get(Env.class),
            unit.get(WatchService.class),
            ImmutableSet.of(unit.get(FileEventOptions.class)));
        unit.captured(ThreadFactory.class).get(0).newThread(monitor);
      }, unit -> {
        unit.captured(Runnable.class).get(0).run();
      });
}
项目:jooby    文件:FileMonitorTest.java   
@Test
public void registerTreeErr() throws Exception {
  new MockUnit(Injector.class, Env.class, WatchService.class, FileEventOptions.class, Path.class,
      WatchEvent.Kind.class, WatchEvent.Modifier.class, WatchKey.class)
      .expect(newThread)
      .expect(registerTree(false, true))
      .expect(takeInterrupt)
      .run(unit -> {
        FileMonitor monitor = new FileMonitor(unit.get(Injector.class), unit.get(Env.class),
            unit.get(WatchService.class),
            ImmutableSet.of(unit.get(FileEventOptions.class)));
        unit.captured(ThreadFactory.class).get(0).newThread(monitor);
      }, unit -> {
        unit.captured(Runnable.class).get(0).run();
      });
}
项目:jooby    文件:FileMonitorTest.java   
@Test
public void pollIgnoreMissing() throws Exception {
  new MockUnit(Injector.class, Env.class, WatchService.class, FileEventOptions.class, Path.class,
      WatchEvent.Kind.class, WatchEvent.Modifier.class, WatchKey.class)
      .expect(newThread)
      .expect(registerTree(false, false))
      .expect(takeIgnore)
      .expect(takeInterrupt)
      .run(unit -> {
        FileMonitor monitor = new FileMonitor(unit.get(Injector.class), unit.get(Env.class),
            unit.get(WatchService.class),
            ImmutableSet.of(unit.get(FileEventOptions.class)));
        unit.captured(ThreadFactory.class).get(0).newThread(monitor);
      }, unit -> {
        unit.captured(Runnable.class).get(0).run();
      });
}
项目:jooby    文件:FileMonitorTest.java   
@Test
public void pollEvents() throws Exception {
  Path path = Paths.get("target/foo.txt");
  new MockUnit(Injector.class, Env.class, WatchService.class, FileEventOptions.class, Path.class,
      WatchEvent.Kind.class, WatchEvent.Modifier.class, WatchKey.class, WatchEvent.class,
      PathMatcher.class, FileEventHandler.class)
      .expect(newThread)
      .expect(registerTree(false, false))
      .expect(take)
      .expect(poll(StandardWatchEventKinds.ENTRY_MODIFY, path))
      .expect(filter(true))
      .expect(handler(StandardWatchEventKinds.ENTRY_MODIFY, false))
      .expect(recursive(false, false))
      .expect(reset(true))
      .expect(takeInterrupt)
      .run(unit -> {
        FileMonitor monitor = new FileMonitor(unit.get(Injector.class), unit.get(Env.class),
            unit.get(WatchService.class),
            ImmutableSet.of(unit.get(FileEventOptions.class)));
        unit.captured(ThreadFactory.class).get(0).newThread(monitor);
      }, unit -> {
        unit.captured(Runnable.class).get(0).run();
      });
}
项目:jooby    文件:FileMonitorTest.java   
@Test
public void pollEventsInvalid() throws Exception {
  Path path = Paths.get("target/foo.txt");
  new MockUnit(Injector.class, Env.class, WatchService.class, FileEventOptions.class, Path.class,
      WatchEvent.Kind.class, WatchEvent.Modifier.class, WatchKey.class, WatchEvent.class,
      PathMatcher.class, FileEventHandler.class)
      .expect(newThread)
      .expect(registerTree(false, false))
      .expect(take)
      .expect(poll(StandardWatchEventKinds.ENTRY_MODIFY, path))
      .expect(filter(true))
      .expect(handler(StandardWatchEventKinds.ENTRY_MODIFY, false))
      .expect(recursive(false, false))
      .expect(reset(false))
      .run(unit -> {
        FileMonitor monitor = new FileMonitor(unit.get(Injector.class), unit.get(Env.class),
            unit.get(WatchService.class),
            ImmutableSet.of(unit.get(FileEventOptions.class)));
        unit.captured(ThreadFactory.class).get(0).newThread(monitor);
      }, unit -> {
        unit.captured(Runnable.class).get(0).run();
      });
}
项目:jooby    文件:FileMonitorTest.java   
@Test
public void pollEventsRecursive() throws Exception {
  Path path = Paths.get("target/foo.txt");
  new MockUnit(Injector.class, Env.class, WatchService.class, FileEventOptions.class, Path.class,
      WatchEvent.Kind.class, WatchEvent.Modifier.class, WatchKey.class, WatchEvent.class,
      PathMatcher.class, FileEventHandler.class)
      .expect(newThread)
      .expect(registerTree(false, false))
      .expect(take)
      .expect(poll(StandardWatchEventKinds.ENTRY_CREATE, path))
      .expect(filter(true))
      .expect(handler(StandardWatchEventKinds.ENTRY_CREATE, false))
      .expect(recursive(true, false))
      .expect(reset(true))
      .expect(takeInterrupt)
      .run(unit -> {
        FileMonitor monitor = new FileMonitor(unit.get(Injector.class), unit.get(Env.class),
            unit.get(WatchService.class),
            ImmutableSet.of(unit.first(FileEventOptions.class)));
        unit.captured(ThreadFactory.class).get(0).newThread(monitor);
      }, unit -> {
        unit.captured(Runnable.class).get(0).run();
      });
}
项目:jooby    文件:FileMonitorTest.java   
@Test
public void pollEventsRecursiveErr() throws Exception {
  Path path = Paths.get("target/foo.txt");
  new MockUnit(Injector.class, Env.class, WatchService.class, FileEventOptions.class, Path.class,
      WatchEvent.Kind.class, WatchEvent.Modifier.class, WatchKey.class, WatchEvent.class,
      PathMatcher.class, FileEventHandler.class)
      .expect(newThread)
      .expect(registerTree(false, false))
      .expect(take)
      .expect(poll(StandardWatchEventKinds.ENTRY_CREATE, path))
      .expect(filter(true))
      .expect(handler(StandardWatchEventKinds.ENTRY_CREATE, false))
      .expect(recursive(true, true))
      .expect(reset(true))
      .expect(takeInterrupt)
      .run(unit -> {
        FileMonitor monitor = new FileMonitor(unit.get(Injector.class), unit.get(Env.class),
            unit.get(WatchService.class),
            ImmutableSet.of(unit.first(FileEventOptions.class)));
        unit.captured(ThreadFactory.class).get(0).newThread(monitor);
      }, unit -> {
        unit.captured(Runnable.class).get(0).run();
      });
}
项目:jooby    文件:FileMonitorTest.java   
@Test
public void pollEventWithHandleErr() throws Exception {
  Path path = Paths.get("target/foo.txt");
  new MockUnit(Injector.class, Env.class, WatchService.class, FileEventOptions.class, Path.class,
      WatchEvent.Kind.class, WatchEvent.Modifier.class, WatchKey.class, WatchEvent.class,
      PathMatcher.class, FileEventHandler.class)
      .expect(newThread)
      .expect(registerTree(false, false))
      .expect(take)
      .expect(poll(StandardWatchEventKinds.ENTRY_MODIFY, path))
      .expect(filter(true))
      .expect(handler(StandardWatchEventKinds.ENTRY_MODIFY, true))
      .expect(recursive(false, false))
      .expect(reset(true))
      .expect(takeInterrupt)
      .run(unit -> {
        FileMonitor monitor = new FileMonitor(unit.get(Injector.class), unit.get(Env.class),
            unit.get(WatchService.class),
            ImmutableSet.of(unit.get(FileEventOptions.class)));
        unit.captured(ThreadFactory.class).get(0).newThread(monitor);
      }, unit -> {
        unit.captured(Runnable.class).get(0).run();
      });
}
项目:jooby    文件:FileMonitorTest.java   
@Test
public void pollEventsNoMatches() throws Exception {
  Path path = Paths.get("target/foo.txt");
  new MockUnit(Injector.class, Env.class, WatchService.class, FileEventOptions.class, Path.class,
      WatchEvent.Kind.class, WatchEvent.Modifier.class, WatchKey.class, WatchEvent.class,
      PathMatcher.class, FileEventHandler.class)
      .expect(newThread)
      .expect(registerTree(false, false))
      .expect(take)
      .expect(poll(StandardWatchEventKinds.ENTRY_MODIFY, path))
      .expect(filter(false))
      .expect(recursive(false, false))
      .expect(reset(true))
      .expect(takeInterrupt)
      .run(unit -> {
        FileMonitor monitor = new FileMonitor(unit.get(Injector.class), unit.get(Env.class),
            unit.get(WatchService.class),
            ImmutableSet.of(unit.get(FileEventOptions.class)));
        unit.captured(ThreadFactory.class).get(0).newThread(monitor);
      }, unit -> {
        unit.captured(Runnable.class).get(0).run();
      });
}
项目:java-cloud-filesystem-provider    文件:CloudPath.java   
@Override
public WatchKey register(WatchService watcher, Kind<?>[] events, Modifier... modifiers) throws IOException {
    if (!CloudWatchService.class.isAssignableFrom(watcher.getClass())) {
        throw new IllegalArgumentException("The file system watcher must be of type " +
                CloudWatchService.class + " but was " + watcher.getClass());
    }

    return ((CloudWatchService)watcher).register(this, events, modifiers);
}
项目:baratine    文件:JWatchService.java   
protected JWatchKey register(JPath path, Kind<?>[] events, Modifier ... modifiers)
{
  JWatchKey key = new JWatchKey(this, path, events, modifiers);

  synchronized (this) {
    _watchList.add(key);
  }

  return key;
}
项目:baratine    文件:JWatchKey.java   
public JWatchKey(JWatchService watchService,
                 JPath path,
                 Kind<?>[] events,
                 Modifier ... modifiers)
{
  Objects.requireNonNull(events);

  _watchService = watchService;
  _path = path;
  _events = events;
  _modifiers = modifiers;

  _watchHandle = path.getBfsFile().watch(pathString -> onWatch(pathString));
}
项目:baratine    文件:JPath.java   
@Override
public WatchKey register(WatchService watcher, Kind<?>[] events,
                         Modifier... modifiers) throws IOException
{
  if (events.length == 0) {
    throw new IllegalArgumentException(L.l("no events specified to watch on: {0}", toUri()));
  }

  JWatchService jWatcher = (JWatchService) watcher;

  WatchKey key = jWatcher.register(this, events, modifiers);

  return key;
}
项目:rug-cli    文件:ArtifactSourceFileWatcherThread.java   
public ArtifactSourceFileWatcherThread(ArtifactDescriptor artifact, Modifier... modifiers) {
    this.artifact = artifact;
    this.modifiers = modifiers;
    setDaemon(true);
    setName("FS File Watcher Thread");
    init();
    start();
}
项目:ephemeralfs    文件:EphemeralFsPath.java   
@Override
public WatchKey register(WatchService watcher, Kind<?>[] events,
        Modifier... modifiers) throws IOException {

    //no standard modifiers are defined
    if(modifiers != null && modifiers.length != 0) {
        throw new IllegalStateException("unsupported modifiers");
    }

    synchronized(fs.fsLock) {
        ResolvedPath resolvedThis = ResolvedPath.resolve(this, false);
        if(!resolvedThis.hasTarget()) {
            throw new NoSuchFileException(toString());
        }
        if(!resolvedThis.getTarget().isDir()) {
            throw new NotDirectoryException(toString());
        }
        if(!(watcher instanceof EphemeralFsWatchService)) {
            throw new IllegalArgumentException("watcher not created by this fs");
        }
        EphemeralFsWatchService service = (EphemeralFsWatchService) watcher;
        if(service.getFs() != fs) {
            throw new IllegalArgumentException("watch service from different fs");
        }
        EphemeralFsWatchKey answer = 
                new EphemeralFsWatchKey(service, this, resolvedThis.getTarget(),  fs, events);
        fs.getWatchRegistry().register(resolvedThis.getTarget(), answer);
        return answer;
    }
}
项目:jsr203-hadoop    文件:HadoopPath.java   
@Override
public WatchKey register(WatchService watcher, Kind<?>[] events,
    Modifier... modifiers) throws IOException {
  if (watcher == null || events == null || modifiers == null) {
    throw new NullPointerException();
  }

  // Not implemented now
  // The Hadoop API for notification is not stable
  throw new IOException("Not implemented");
}
项目:studio-workspace-refresher    文件:WorkspaceRefreshMonitor.java   
/**
 * "HIGH" modifier should improve the file detection speed.
 * 
 * @return SensitivityWatchEventModifier.HIGH
 */
private Modifier get_com_sun_nio_file_SensitivityWatchEventModifier_HIGH() {
    try {
        Class<?> c = Class
                .forName("com.sun.nio.file.SensitivityWatchEventModifier"); //$NON-NLS-1$
        Field f = c.getField("HIGH"); //$NON-NLS-1$
        return (Modifier) f.get(c);
    } catch (Exception e) {
        return null;
    }
}
项目:agent7    文件:ClassFileWatch.java   
private void register(Path dir) throws IOException {
  Modifier high = get_com_sun_nio_file_SensitivityWatchEventModifier_HIGH();
  WatchKey key =
    (high == null) ?
    dir.register(watcher, ENTRY_CREATE, ENTRY_MODIFY) :
    dir.register(watcher, new WatchEvent.Kind<?>[]{ENTRY_CREATE, ENTRY_MODIFY}, high);
  keys.put(key, dir);
}
项目:agent7    文件:ClassFileWatch.java   
private Modifier get_com_sun_nio_file_SensitivityWatchEventModifier_HIGH() {
  try {
    Class<?> c = Class.forName("com.sun.nio.file.SensitivityWatchEventModifier");
    Field    f = c.getField("HIGH");
    return (Modifier) f.get(c);
  } catch (Exception e) {
    return null;
  }
}
项目:jooby    文件:FileMonitor.java   
private void register(final Path path, final FileEventOptions options) throws IOException {
  Kind<?>[] kinds = options.kinds();
  Modifier modifier = options.modifier();
  WatchKey key = path.register(watcher, kinds, modifier);
  this.keys.put(key, path);
  this.options.put(path, options);
}
项目:truevfs    文件:TPath.java   
/** @throws UnsupportedOperationException always */
@Override
public WatchKey register(WatchService watcher, Kind<?>[] events, Modifier... modifiers) throws IOException {
    throw new UnsupportedOperationException("Not supported yet.");
}
项目:openjdk-systemtest    文件:MemoryPath.java   
@Override
public WatchKey register(WatchService watcher, Kind<?>[] events,
        Modifier... modifiers) throws IOException {
    return null;
}
项目:mycore    文件:MCRPath.java   
@Override
public WatchKey register(final WatchService watcher, final Kind<?>... events) throws IOException {
    return register(watcher, events, new WatchEvent.Modifier[0]);
}
项目:mycore    文件:MCRPath.java   
@Override
public WatchKey register(final WatchService watcher, final Kind<?>[] events, final Modifier... modifiers)
    throws IOException {
    throw new UnsupportedOperationException();
}
项目:baratine    文件:PathBase.java   
@Override
public WatchKey register(WatchService watcher, Kind<?>[] events,
                         Modifier... modifiers) throws IOException
{
  throw new UnsupportedOperationException();
}
项目:baratine    文件:JPath.java   
@Override
public WatchKey register(WatchService watcher, Kind<?>... events)
    throws IOException
{
  return register(watcher, events, new Modifier[0]);
}
项目:rug-cli    文件:ArtifactSourceFileWatcherThread.java   
public ArtifactSourceFileWatcherThread(ArtifactDescriptor artifact) {
    this(artifact, new Modifier[0]);
}
项目:MatroskaBatch    文件:RESTPath.java   
@Override
public WatchKey register(WatchService watcher, Kind<?>[] events, Modifier... modifiers) throws IOException {
    throw new UnsupportedOperationException();
}
项目:incubator-taverna-language    文件:BundlePath.java   
@Override
public WatchKey register(WatchService watcher, Kind<?>[] events,
        Modifier... modifiers) throws IOException {
    throw new UnsupportedOperationException();
}
项目:bugminer    文件:TemporaryDirectory.java   
@Override
public WatchKey register(WatchService watcher, Kind<?>[] events, Modifier... modifiers)
        throws IOException {
    return getPath().register(watcher, events, modifiers);
}
项目:bugminer    文件:SelfDestroyingPathBean.java   
@Override
public WatchKey register(WatchService watcher, Kind<?>[] events, Modifier... modifiers)
        throws IOException {
    return path.register(watcher, events, modifiers);
}
项目:test-fs    文件:TestPath.java   
/** {@inheritDoc} */
@Override
public WatchKey register(WatchService watcher, Kind< ? >[] events, Modifier... modifiers) throws IOException {
    return p.register(watcher, events, modifiers);
}
项目:ephemeralfs    文件:EphemeralFsPath.java   
@Override
public WatchKey register(WatchService watcher, Kind<?>... events)
        throws IOException {
    return register(watcher, events, new Modifier[0]);
}
项目:dstream    文件:HdfsPath.java   
@Override
public WatchKey register(WatchService watcher, Kind<?>[] events,
        Modifier... modifiers) throws IOException {
    // TODO Auto-generated method stub
    return null;
}
项目:jsr203-hadoop    文件:HadoopPath.java   
@Override
public WatchKey register(WatchService watcher, Kind<?>... events)
    throws IOException {
  return register(watcher, events, new WatchEvent.Modifier[0]);
}
项目:jooby    文件:FileEventOptions.java   
Modifier modifier() {
  return modifier;
}
项目:forgeide    文件:ResourcePath.java   
@Override
public WatchKey register(WatchService watcher, Kind<?>[] events, Modifier... modifiers) throws IOException
{
   // TODO Auto-generated method stub
   return null;
}
项目:java-cloud-filesystem-provider    文件:CloudWatchService.java   
/**
 * Registers this path for watching
 * @param path
 * @param events
 * @param modifiers
 * @return The watch key
 */
WatchKey register(CloudPath path, Kind<?>[] events, Modifier... modifiers);