Package org.chenile.filewatch.handler
Class FileWatcherExecutorService
java.lang.Object
org.chenile.filewatch.handler.FileWatcherExecutorService
The main file for file watch
This allows the handler to register
FileWatchDefinition
. It also starts the
file watch by executing the FileWatcher
in a separate thread.
Once a file is discovered by the file watcher, this class picks it up and hands it over to
the fileProcessor for further processing.- Author:
- Raja Shankar Kolluru
-
Nested Class Summary
-
Field Summary
Modifier and TypeFieldDescriptionprotected String
protected String
protected ExecutorService
private FileProcessor
private FileSystem
Ability to inject a file system facilitates mockingprotected int
private WatchService
-
Constructor Summary
ConstructorDescriptionFileWatcherExecutorService
(String baseWatchFolder, String baseProcessedFolder, int pollTimeInSeconds, FileSystem fileSystem) -
Method Summary
Modifier and TypeMethodDescriptionvoid
handleFile
(WatchKey key, Path fileSeen) This will be the callback for every file that has been discovered by theFileWatcher
private void
processExisting
(FileWatchDefinition fileWatchDefinition, Path watchDir, Path processedDir) void
registerWatch
(FileWatchDefinition fileWatchDefinition) void
-
Field Details
-
baseWatchFolder
-
baseProcessedFolder
-
pollTimeInSeconds
protected int pollTimeInSeconds -
executorService
-
watcher
-
fileProcessor
-
fileSystem
Ability to inject a file system facilitates mocking -
watchKeyToInfoMap
-
-
Constructor Details
-
FileWatcherExecutorService
public FileWatcherExecutorService(String baseWatchFolder, String baseProcessedFolder, int pollTimeInSeconds, FileSystem fileSystem)
-
-
Method Details
-
registerWatch
-
processExisting
private void processExisting(FileWatchDefinition fileWatchDefinition, Path watchDir, Path processedDir) -
startWatch
public void startWatch() -
handleFile
This will be the callback for every file that has been discovered by theFileWatcher
- Parameters:
key
-fileSeen
-
-