Search in sources :

Example 1 with FileAlterationMonitor

use of org.apache.commons.io.monitor.FileAlterationMonitor in project ddf by codice.

the class PollingPolicyFinderModule method initialize.

private void initialize(long pollingInterval) {
    LOGGER.debug("initializing polling: {}, every {}", xacmlPolicyDirectories, pollingInterval);
    monitor = new FileAlterationMonitor(pollingInterval * MULTIPLIER);
    for (String xacmlPolicyDirectory : xacmlPolicyDirectories) {
        File directoryToMonitor = new File(xacmlPolicyDirectory);
        FileAlterationObserver observer = new FileAlterationObserver(directoryToMonitor, getXmlFileFilter());
        observer.addListener(this);
        monitor.addObserver(observer);
        LOGGER.debug("Monitoring directory: {}", directoryToMonitor);
    }
}
Also used : FileAlterationObserver(org.apache.commons.io.monitor.FileAlterationObserver) FileAlterationMonitor(org.apache.commons.io.monitor.FileAlterationMonitor) File(java.io.File)

Example 2 with FileAlterationMonitor

use of org.apache.commons.io.monitor.FileAlterationMonitor in project moco by dreamhead.

the class FileMocoRunnerWatcher method monitorFile.

private FileAlterationMonitor monitorFile(final File file, final FileAlterationListener listener) {
    File parentFile = file.getParentFile();
    File directory = toDirectory(parentFile);
    FileAlterationObserver observer = new FileAlterationObserver(directory, sameFile(file));
    observer.addListener(listener);
    return new FileAlterationMonitor(INTERVAL, observer);
}
Also used : FileAlterationObserver(org.apache.commons.io.monitor.FileAlterationObserver) FileAlterationMonitor(org.apache.commons.io.monitor.FileAlterationMonitor) File(java.io.File)

Example 3 with FileAlterationMonitor

use of org.apache.commons.io.monitor.FileAlterationMonitor in project ddf by codice.

the class ConfigurationFilesPoller method register.

public void register(ChangeListener listener) {
    notNull(listener, "ChangeListener cannot be null");
    changeListener = listener;
    fileAlterationObserver = new FileAlterationObserver(configurationDirectoryPath.toAbsolutePath().toString(), new SuffixFileFilter(fileExtension));
    fileAlterationObserver.addListener(this);
    watchService = new FileAlterationMonitor(POLLING_INTERVAL, fileAlterationObserver);
    try {
        watchService.start();
    } catch (Exception e) {
        logStackAndMessageSeparately(e, "Failed to start, 'Platform :: Migration' must be restarted: ");
    }
}
Also used : FileAlterationObserver(org.apache.commons.io.monitor.FileAlterationObserver) FileAlterationMonitor(org.apache.commons.io.monitor.FileAlterationMonitor) SuffixFileFilter(org.apache.commons.io.filefilter.SuffixFileFilter)

Aggregations

FileAlterationMonitor (org.apache.commons.io.monitor.FileAlterationMonitor)3 FileAlterationObserver (org.apache.commons.io.monitor.FileAlterationObserver)3 File (java.io.File)2 SuffixFileFilter (org.apache.commons.io.filefilter.SuffixFileFilter)1