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
Nested Classes -
Field Summary
FieldsModifier and TypeFieldDescriptionprotected Stringprotected Stringprotected ExecutorServiceprivate FileProcessorprivate FileSystemAbility to inject a file system facilitates mockingprotected intprivate WatchService -
Constructor Summary
ConstructorsConstructorDescriptionFileWatcherExecutorService(String baseWatchFolder, String baseProcessedFolder, int pollTimeInSeconds, FileSystem fileSystem) -
Method Summary
Modifier and TypeMethodDescriptionvoidhandleFile(WatchKey key, Path fileSeen) This will be the callback for every file that has been discovered by theFileWatcherprivate voidprocessExisting(FileWatchDefinition fileWatchDefinition, Path watchDir, Path processedDir) voidregisterWatch(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-
-