Example usage for org.apache.commons.vfs2.impl DefaultFileMonitor stop

List of usage examples for org.apache.commons.vfs2.impl DefaultFileMonitor stop

Introduction

In this page you can find the example usage for org.apache.commons.vfs2.impl DefaultFileMonitor stop.

Prototype

public void stop() 

Source Link

Document

Stops monitoring the files that have been added.

Usage

From source file:org.apache.accumulo.start.classloader.vfs.providers.VfsClassLoaderTest.java

@Test
public void testFileMonitor() throws Exception {
    MyFileMonitor listener = new MyFileMonitor();
    DefaultFileMonitor monitor = new DefaultFileMonitor(listener);
    monitor.setRecursive(true);/*  w ww .j a v a  2 s. co m*/
    FileObject testDir = vfs.resolveFile(TEST_DIR.toUri().toString());
    monitor.addFile(testDir);
    monitor.start();

    // Copy jar file to a new file name
    URL jarPath = this.getClass().getResource("/HelloWorld.jar");
    Path src = new Path(jarPath.toURI().toString());
    Path dst = new Path(TEST_DIR, "HelloWorld2.jar");
    this.hdfs.copyFromLocalFile(src, dst);

    // VFS-487 significantly wait to avoid failure
    Thread.sleep(7000);
    Assert.assertTrue(listener.isFileCreated());

    // Update the jar
    jarPath = this.getClass().getResource("/HelloWorld.jar");
    src = new Path(jarPath.toURI().toString());
    dst = new Path(TEST_DIR, "HelloWorld2.jar");
    this.hdfs.copyFromLocalFile(src, dst);

    // VFS-487 significantly wait to avoid failure
    Thread.sleep(7000);
    Assert.assertTrue(listener.isFileChanged());

    this.hdfs.delete(dst, false);
    // VFS-487 significantly wait to avoid failure
    Thread.sleep(7000);
    Assert.assertTrue(listener.isFileDeleted());

    monitor.stop();

}

From source file:org.pieShare.pieShareApp.service.fileService.fileListenerService.ApacheFileWatcherService.java

@Override
public void shutdown() {
    for (DefaultFileMonitor fm : this.fileMonitors) {
        fm.stop();
    }
}

From source file:org.pieshare.piespring.service.fileListenerService.ApacheFileWatcherService.java

@Override
public void shutdown() {
    for (DefaultFileMonitor fm : this.fileMonitors) {
        fm.stop();
        fm = null;/*from ww  w  .ja  v a2s  .c  o  m*/
    }
}