Example usage for org.apache.commons.vfs2 FileListener FileListener

List of usage examples for org.apache.commons.vfs2 FileListener FileListener

Introduction

In this page you can find the example usage for org.apache.commons.vfs2 FileListener FileListener.

Prototype

FileListener

Source Link

Usage

From source file:org.hotswap.agent.watch.vfs.WatcherVFS.java

public WatcherVFS() throws FileSystemException {
    fm = new DefaultFileMonitor(new FileListener() {
        @Override// w  w  w .j ava2s. c  o m
        public void fileCreated(FileChangeEvent fce) throws Exception {
            callListeners(fce, FileEvent.CREATE);
        }

        @Override
        public void fileDeleted(FileChangeEvent fce) throws Exception {
            callListeners(fce, FileEvent.DELETE);
        }

        @Override
        public void fileChanged(FileChangeEvent fce) throws Exception {
            callListeners(fce, FileEvent.MODIFY);
        }
    });

    fm.setRecursive(true);
    manager = VFS.getManager();
}

From source file:org.nuxeo.launcher.gui.NuxeoLauncherGUI.java

/**
 * @param aLauncher Launcher being used in background
 *//* ww  w. j ava  2 s  . c  o  m*/
public NuxeoLauncherGUI(NuxeoLauncher aLauncher) {
    launcher = aLauncher;
    // Set OS-specific decorations
    if (SystemUtils.IS_OS_MAC) {
        System.setProperty("apple.laf.useScreenMenuBar", "true");
        System.setProperty("com.apple.mrj.application.growbox.intrudes", "false");
        System.setProperty("com.apple.mrj.application.live-resize", "true");
        System.setProperty("com.apple.macos.smallTabs", "true");
    }
    initFrame();
    dumpedConfigMonitor = new DefaultFileMonitor(new FileListener() {
        @Override
        public void fileDeleted(FileChangeEvent event) {
            // Ignore
        }

        @Override
        public void fileCreated(FileChangeEvent event) {
            updateNuxeoFrame();
        }

        @Override
        public void fileChanged(FileChangeEvent event) {
            updateNuxeoFrame();
        }

        synchronized private void updateNuxeoFrame() {
            waitForFrameLoaded();
            log.debug("Configuration changed. Reloading frame...");
            launcher.init();
            updateServerStatus();
            try {
                Properties props = new Properties();
                props.load(new FileReader(getConfigurationGenerator().getDumpedConfig()));
                nuxeoFrame.updateLogsTab(props.getProperty("log.id"));
            } catch (IOException e) {
                log.error(e);
            }
        }
    });
    try {
        dumpedConfigMonitor.setRecursive(false);
        FileObject dumpedConfig = VFS.getManager()
                .resolveFile(getConfigurationGenerator().getDumpedConfig().getPath());
        dumpedConfigMonitor.addFile(dumpedConfig);
        dumpedConfigMonitor.start();
    } catch (FileSystemException e) {
        throw new RuntimeException("Couldn't find " + getConfigurationGenerator().getNuxeoConf(), e);
    }
}

From source file:tain.kr.test.vfs.v01.MainTestVfs03.java

public void execute() throws Exception {

    if (flag) {/*from ww w  .j a  v a  2s . c o  m*/
        /*
         * progress
         */
    }

    if (flag) {
        /*
         * event listener
         */
        try {
            FileSystemManager fileSystemManager = VFS.getManager();
            FileObject listenFolder = fileSystemManager.resolveFile("N:/tain/products/LucyCron/test");

            DefaultFileMonitor fileMonitor = new DefaultFileMonitor(new FileListener() {
                @Override
                public void fileChanged(FileChangeEvent fileChangeEvent) throws Exception {
                }

                @Override
                public void fileCreated(FileChangeEvent fileChangeEvent) throws Exception {
                }

                @Override
                public void fileDeleted(FileChangeEvent fileChangeEvent) throws Exception {
                }
            });

            fileMonitor.addFile(listenFolder);
            fileMonitor.setRecursive(true);
            fileMonitor.start();
        } catch (Exception e) {
            e.printStackTrace();
        }
    }
}