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);
}
}
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);
}
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: ");
}
}
Aggregations