Example usage for org.apache.commons.vfs FileChangeEvent getFile

List of usage examples for org.apache.commons.vfs FileChangeEvent getFile

Introduction

In this page you can find the example usage for org.apache.commons.vfs FileChangeEvent getFile.

Prototype

public FileObject getFile() 

Source Link

Document

Returns the file that changed.

Usage

From source file:com.sonatype.nexus.plugin.groovyconsole.DefaultScriptStorage.java

public void fileChanged(FileChangeEvent e) throws Exception {
    if (!isScriptFile(e.getFile())) {
        return;/*from w  w w. j av a2 s  .  c om*/
    }

    updateScript(e.getFile());
}

From source file:com.sonatype.nexus.plugin.groovyconsole.DefaultScriptStorage.java

public void fileCreated(FileChangeEvent e) throws Exception {
    if (!isScriptFile(e.getFile())) {
        return;/* w w w. j a  va2s  . c  o  m*/
    }

    updateScript(e.getFile());
}

From source file:com.sonatype.nexus.plugin.groovyconsole.DefaultScriptStorage.java

public void fileDeleted(FileChangeEvent e) throws Exception {
    if (!isScriptFile(e.getFile())) {
        return;/*  w  ww  .j ava  2  s . c om*/
    }

    synchronized (scripts) {
        scripts.remove(getName(e.getFile().getName()));
    }
}

From source file:org.ambud.marauder.source.ids.IDSFileSource.java

@Override
public void configure(Context context) {
    super.configure(context);
    context = new Context(context.getSubProperties(getPrefix()));
    this.watchDirectory = new File(context.getString(PROP_DIRECTORY, getDefaultDirectory()));
    this.logBaseName = context.getString(PROP_BASE_NAME, getDefaultFilename());
    this.isSequential = context.getBoolean(PROP_IS_SEQUENTIAL, true);
    logger.info("Snort Source will spool/watch - " + this.watchDirectory.getAbsolutePath()
            + " for Snort log files whose names start with:" + this.logBaseName);
    FileSystemManager fsMgr = null;//from w  w w  .  j av  a  2s  .  com
    try {
        fsMgr = VFS.getManager();
    } catch (FileSystemException e) {
        Throwables.propagate(e);
    }
    try {
        this.watchObject = fsMgr.resolveFile(watchDirectory.getAbsolutePath());
    } catch (FileSystemException e) {
        Throwables.propagate(e);
    }
    this.monitor = new DefaultFileMonitor(new FileListener() {

        @Override
        public void fileChanged(FileChangeEvent arg0) throws Exception {
            // ignore these
        }

        @Override
        public void fileCreated(FileChangeEvent fileEvent) throws Exception {
            if (acceptFile(fileEvent.getFile().getName().getBaseName())) {
                logger.info("Acknowledged new file:" + fileEvent.getFile().getName().getPath());
                builderFileReader(fileEvent.getFile(), true);
            }
        }

        @Override
        public void fileDeleted(FileChangeEvent arg0) throws Exception {
            // acknowledge these
        }

    });
    int bufferSize = context.getInteger(PROP_BUFFER_SIZE, 500);
    this.outputQueue = new ArrayBlockingQueue<MarauderIDSEvent>(bufferSize);
}

From source file:org.ambud.marauder.source.snort.SnortSourceBack.java

@Override
public void configure(Context context) {
    super.configure(context);
    context = new Context(context.getSubProperties(PROP_PREFIX));
    this.watchDirectory = new File(context.getString(PROP_DIRECTORY, PROP_DEFAULT_DIR));
    this.logBaseName = context.getString(PROP_BASE_NAME, PROP_DEFAULT_FILENAME);
    this.isSequential = context.getBoolean(PROP_IS_SEQUENTIAL, true);
    logger.info("Snort Source will spool/watch - " + this.watchDirectory.getAbsolutePath()
            + " for Snort log files whose names start with:" + this.logBaseName);
    FileSystemManager fsMgr = null;//  w ww . j  ava  2  s  .c  o m
    try {
        fsMgr = VFS.getManager();
    } catch (FileSystemException e) {
        Throwables.propagate(e);
    }
    try {
        this.watchObject = fsMgr.resolveFile(watchDirectory.getAbsolutePath());
    } catch (FileSystemException e) {
        Throwables.propagate(e);
    }
    this.monitor = new DefaultFileMonitor(new FileListener() {

        @Override
        public void fileChanged(FileChangeEvent arg0) throws Exception {
            // ignore these
        }

        @Override
        public void fileCreated(FileChangeEvent fileEvent) throws Exception {
            if (acceptFile(fileEvent.getFile().getName().getBaseName())) {
                logger.info("Acknowledged new file:" + fileEvent.getFile().getName().getPath());
                processFile(fileEvent.getFile(), true);
            }
        }

        @Override
        public void fileDeleted(FileChangeEvent arg0) throws Exception {
            // acknowledge these
        }

    });
    int bufferSize = context.getInteger("buffer.size", 500);
    this.outputQueue = new ArrayBlockingQueue<MarauderIDSEvent>(bufferSize);
}