methods to initialize a DirectoryPoller with a state from a previous running DirectoryPoller.
methods to read the current state of the last poll cycle. For example this information can be persisted and used later in a new running instance of a DirectoryPoller in a separate JVM, by using methods in 1).
NOTE!
PR #27 builds upon this PR and adds a simple file persisting mechanism.
Example for 1)
You can initialize the DirectoryPoller with a previous state by adding the files known to a previous running instance of DirectoryPoller by calling these methods:
Alternatively you can initialize the DirectoryPoller with a previous state by implementing DirectoryPollerListener.beforeStart(BeforeStartEventevent). Example:
Example for 2))
Implement the DirectoryPollerListener.afterStop(AfterStopEvent event) interface to get access to the state after last poll cycle. Example:
@Override
public void afterStop(AfterStopEvent event) {
/*
* cachedFileElements is a Map, where the keys are your PolledDirectories
* and the values are each directory's files in the last poll cycle.
* This can be used to persist the data using your choice of source (file/database etc.).
*/
Map<PolledDirectory, Set<CachedFileElement>> cachedFileElements = event.getCachedFileElements();
cachedFileElements.entrySet().forEach(entry -> /* persist your data here */);
}
This PR adds:
DirectoryPoller
with a state from a previous runningDirectoryPoller
.DirectoryPoller
in a separate JVM, by using methods in 1).NOTE! PR #27 builds upon this PR and adds a simple file persisting mechanism.
Example for 1) You can initialize the
DirectoryPoller
with a previous state by adding the files known to a previous running instance ofDirectoryPoller
by calling these methods:Alternatively you can initialize the
DirectoryPoller
with a previous state by implementingDirectoryPollerListener.beforeStart(BeforeStartEventevent)
. Example:Example for 2)) Implement the
DirectoryPollerListener.afterStop(AfterStopEvent event)
interface to get access to the state after last poll cycle. Example: