Package com.ibm.fhir.bucket.scanner
Class LocalFileScanner
- java.lang.Object
-
- com.ibm.fhir.bucket.scanner.LocalFileScanner
-
- All Implemented Interfaces:
IResourceScanner
public class LocalFileScanner extends java.lang.Object implements IResourceScanner
Active object to periodically scan a local directory looking for new objects to load
-
-
Field Summary
Fields Modifier and Type Field Description static long
HEARTBEAT_INTERVAL_MS
-
Constructor Summary
Constructors Constructor Description LocalFileScanner(java.util.Collection<java.lang.String> dirs, DataAccess dataAccess, java.util.Set<FileType> fileTypes, java.lang.String pathPrefix, int scanIntervalMs)
Public constructor
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description protected static FileType
fileTyper(java.lang.String itemName)
Determine the type of the file based on the suffixprotected void
handle(CosItem item)
Process the item returned by the scanprotected void
heartbeat()
Update the heartbeat on a (reasonably) regular basis to demonstrate this loader instance is still alivevoid
init()
Start the scannervoid
mainLoop()
The main loop running inside this active object's threadprotected void
scan()
Perform a scan for each of the configured directoriesprotected void
scan(java.lang.String dir)
Scan the given directoryvoid
signalStop()
Tells the scanner to stopvoid
waitForStop()
Tell the main loop thread to stop if it hasn't already and wait a reasonable time for the main thread loop to terminate
-
-
-
Field Detail
-
HEARTBEAT_INTERVAL_MS
public static final long HEARTBEAT_INTERVAL_MS
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
LocalFileScanner
public LocalFileScanner(java.util.Collection<java.lang.String> dirs, DataAccess dataAccess, java.util.Set<FileType> fileTypes, java.lang.String pathPrefix, int scanIntervalMs)
Public constructor- Parameters:
dirs
- the directories to scandataAccess
- the data access layer for persisting items discovered during the scanfileTypes
- set of FileType values accepted for processingprefix
- only scan items with this prefix if setscanIntervalMs
- the number of milliseconds between scans. -1 for automatic
-
-
Method Detail
-
init
public void init()
Description copied from interface:IResourceScanner
Start the scanner- Specified by:
init
in interfaceIResourceScanner
-
signalStop
public void signalStop()
Description copied from interface:IResourceScanner
Tells the scanner to stop- Specified by:
signalStop
in interfaceIResourceScanner
-
waitForStop
public void waitForStop()
Description copied from interface:IResourceScanner
Tell the main loop thread to stop if it hasn't already and wait a reasonable time for the main thread loop to terminate- Specified by:
waitForStop
in interfaceIResourceScanner
-
mainLoop
public void mainLoop()
The main loop running inside this active object's thread
-
scan
protected void scan()
Perform a scan for each of the configured directories
-
scan
protected void scan(java.lang.String dir)
Scan the given directory- Parameters:
dir
-
-
fileTyper
protected static FileType fileTyper(java.lang.String itemName)
Determine the type of the file based on the suffix- Parameters:
itemName
-- Returns:
-
handle
protected void handle(CosItem item)
Process the item returned by the scan- Parameters:
item
-
-
heartbeat
protected void heartbeat()
Update the heartbeat on a (reasonably) regular basis to demonstrate this loader instance is still alive
-
-