Package org.chenile.filewatch.handler
Class FileProcessor
java.lang.Object
org.chenile.filewatch.handler.FileProcessor
FileProcessor knows to handle each file that was discovered by the file watcher
This would process the file and finally dispose it off from the watched folder to the processed
folder.
The processor only starts reading with a header file. The header file is read for the following reasons:
- To obtain all the header records that are required to call a particular service
- To obtain the pointer to the actual file and encoding type
- To determine if the actual file has been up-loaded completely into the watched folder. It is assumed that the header file will be uploaded only after the actual file has been uploaded. Also, the last property of the header file should be the last line of the header file. Unless that property is written to, file processor will not process the file.
- Author:
- Raja Shankar Kolluru
-
Field Summary
Modifier and TypeFieldDescriptionstatic final String
static final String
private ChenileEntryPoint
private FileWatchEventLogger
static final String
static final String
private Path
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionprivate void
copyHeadersToExchange
(ChenileExchange exchange, Properties headers) private Properties
extractHeaders
(Path file) fileReader
(FileWatchDefinition fileWatchDefinition, Path file, String encodingType) private void
invokeServicesForFile
(FileWatchDefinition fileWatchDefinition, Path file, Properties headers) private void
invokeServicesPerRecord
(FileWatchDefinition fileWatchDefinition, Object record, Properties headers) private void
private void
moveFilesToProcessed
(Path headerFilename, Path recordsFile) void
processFile
(FileWatchDefinition fileWatchDefinition, Path fileDiscovered, Path processedDir)
-
Field Details
-
ACTUAL_FILE_NAME
- See Also:
-
ACTUAL_FILE_ENCODING
- See Also:
-
HEADER_EXTENSION
- See Also:
-
LAST_PROPERTY
- See Also:
-
chenileEntryPoint
-
eventLogger
-
processedDir
-
-
Constructor Details
-
FileProcessor
public FileProcessor()
-
-
Method Details
-
processFile
public void processFile(FileWatchDefinition fileWatchDefinition, Path fileDiscovered, Path processedDir) -
moveFilesToProcessed
-
move
-
extractHeaders
-
invokeServicesForFile
private void invokeServicesForFile(FileWatchDefinition fileWatchDefinition, Path file, Properties headers) -
fileReader
private Iterable<Object> fileReader(FileWatchDefinition fileWatchDefinition, Path file, String encodingType) throws Exception - Throws:
Exception
-
invokeServicesPerRecord
private void invokeServicesPerRecord(FileWatchDefinition fileWatchDefinition, Object record, Properties headers) -
copyHeadersToExchange
-