org.apache.commons.io.monitor.FileAlterationListener Java Examples
The following examples show how to use
org.apache.commons.io.monitor.FileAlterationListener.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: FileMonitor.java From MercuryTrade with MIT License | 6 votes |
public void start() { String gamePath = Configuration.get().applicationConfiguration().get().getGamePath(); File folder = new File(gamePath + "logs"); this.fileHandler = new MessageFileHandler(gamePath + "logs/Client.txt"); FileAlterationObserver observer = new FileAlterationObserver(folder); monitor = new FileAlterationMonitor(POLLING_INTERVAL); FileAlterationListener listener = new FileAlterationListenerAdaptor() { @Override public void onFileChange(File file) { fileHandler.parse(); } }; observer.addListener(listener); monitor.addObserver(observer); try { monitor.start(); } catch (Exception e) { e.printStackTrace(); } }
Example #2
Source File: TorrentFileWatcher.java From joal with Apache License 2.0 | 5 votes |
TorrentFileWatcher(final FileAlterationListener listener, final Path monitoredFolder, final Integer interval) { Preconditions.checkNotNull(listener, "listener cannot be null"); Preconditions.checkNotNull(monitoredFolder, "monitoredFolder cannot be null"); Preconditions.checkArgument(Files.exists(monitoredFolder), "Folder '" + monitoredFolder.toAbsolutePath() + "' does not exists."); Preconditions.checkNotNull(interval, "interval cannot be null"); Preconditions.checkArgument(interval > 0, "interval cannot be less than 1"); this.listener = listener; this.monitoredFolder = monitoredFolder.toFile(); this.monitor = new FileAlterationMonitor(interval); this.monitor.setThreadFactory(new ThreadFactoryBuilder().setNameFormat("torrent-file-watcher-%d").build()); this.observer = new FileAlterationObserver(this.monitoredFolder, TORRENT_FILE_FILTER); this.observer.addListener(this.listener); monitor.addObserver(this.observer); }
Example #3
Source File: FileObserver.java From Hive2Hive with MIT License | 5 votes |
public List<FileObserverListener> getFileObserverListeners() { List<FileObserverListener> listeners = new ArrayList<FileObserverListener>(); // TODO check if this interface casting is allowed for (FileAlterationListener listener : observer.getListeners()) { listeners.add((FileObserverListener) listener); } return listeners; }
Example #4
Source File: TorrentFileWatcher.java From joal with Apache License 2.0 | 4 votes |
TorrentFileWatcher(final FileAlterationListener listener, final Path monitoredFolder) { this(listener, monitoredFolder, DEFAULT_SCAN_INTERVAL); }
Example #5
Source File: DefaultTopologyService.java From knox with Apache License 2.0 | 4 votes |
private void initListener(String monitorName, FileAlterationMonitor monitor, File directory, FileFilter filter, FileAlterationListener listener) { monitors.put(monitorName, monitor); FileAlterationObserver observer = new FileAlterationObserver(directory, filter); observer.addListener(listener); monitor.addObserver(observer); }
Example #6
Source File: DefaultTopologyService.java From knox with Apache License 2.0 | 4 votes |
private void initListener(String monitorName, File directory, FileFilter filter, FileAlterationListener listener) { // Increasing the monitoring interval to 5 seconds as profiling has shown // this is rather expensive in terms of generated garbage objects. initListener(monitorName, new FileAlterationMonitor(5000L), directory, filter, listener); }
Example #7
Source File: DefaultTopologyServiceTest.java From knox with Apache License 2.0 | 4 votes |
TestTopologyDeleteListener(FileAlterationListener delegate) { this.delegate = delegate; }