@UsesJava7 public class WatchServiceDirectoryScanner extends DefaultDirectoryScanner implements org.springframework.context.SmartLifecycle
WatchService.
The initial state of the directory is collected during start(). Subsequent
polls return new files as reported by ENTRY_CREATE events.
While initially walking the directory, any subdirectories encountered are registered to watch for creation events.
If subdirectories are subsequently added, they are walked and registered for new creation events, too.
When a StandardWatchEventKinds.OVERFLOW WatchKey event is occurred,
the directory is rescanned to avoid the loss for any new entries according
to the "missed events" logic around StandardWatchEventKinds.OVERFLOW.
| Constructor and Description |
|---|
WatchServiceDirectoryScanner(java.lang.String directory)
Construct an instance for the given directory.
|
| Modifier and Type | Method and Description |
|---|---|
int |
getPhase() |
boolean |
isAutoStartup() |
boolean |
isRunning() |
protected java.io.File[] |
listEligibleFiles(java.io.File directory)
Subclasses may refine the listing strategy by overriding this method.
|
void |
setAutoStartup(boolean autoStartup) |
void |
setPhase(int phase)
see
getPhase() |
void |
setRunning(boolean running) |
void |
start() |
void |
stop() |
void |
stop(java.lang.Runnable callback) |
listFiles, setFilter, setLocker, tryClaimpublic WatchServiceDirectoryScanner(java.lang.String directory)
directory - the directory.public int getPhase()
getPhase in interface org.springframework.context.Phasedpublic void setPhase(int phase)
getPhase()phase - the phase.public boolean isRunning()
isRunning in interface org.springframework.context.Lifecyclepublic void setRunning(boolean running)
running - true if running.isRunning()public boolean isAutoStartup()
isAutoStartup in interface org.springframework.context.SmartLifecyclepublic void setAutoStartup(boolean autoStartup)
autoStartup - true to auto start.isAutoStartup()public void start()
start in interface org.springframework.context.Lifecyclepublic void stop()
stop in interface org.springframework.context.Lifecyclepublic void stop(java.lang.Runnable callback)
stop in interface org.springframework.context.SmartLifecycleprotected java.io.File[] listEligibleFiles(java.io.File directory)
DefaultDirectoryScannerlistEligibleFiles in class DefaultDirectoryScannerdirectory - root directory to use for listing