Handler as
parameter and orchestrate the redeployment method when a matching file is modified (created, updated or deleted).
Users have the possibility to execute a shell command during the redeployment. On a file change, the undeploy
Handler is called, followed by the execution of the user command. Then the deploy Handler
is invoked.
The watcher watches all files from the current directory and sub-directories.
| Modifier and Type | Class and Description |
|---|---|
| private static class |
| Modifier and Type | Field and Description |
|---|---|
| private volatile boolean | |
| private final String | |
| private final File | |
| private final Handler | |
| private final Map | |
| private final Set | |
| private final long | |
| private final List | |
| private long | lastChange
This field is always access from the scan thread. |
| private static final Logger | |
| private final List | |
| private final long | |
| private final Handler |
| Access | Constructor and Description |
|---|---|
| public | Watcher(File
the root directory root, List<String> the list of include patterns, should not be includes, Handler<Handler<Void>> null or emptythe function called when deployment is required deploy, Handler<Handler<Void>> the function called when un-deployment is required undeploy, String an optional command executed after the un-deployment and before the deployment onRedeployCommand, long the amount of time in milliseconds to wait between two redeploy even
if there are changes gracePeriod, long the time in millisecond between 2 file system scans scanPeriod)Creates a new |
| Modifier and Type | Method and Description |
|---|---|
| private void | |
| private void | |
| private boolean | Returns: true if a change occurred requiring the redeployment.Checks whether or not a change has occurred in one of the watched file that match one of the given include pattern . |
| public void | |
| private void | |
| pack-priv static List | |
| protected boolean | |
| public void | |
| private List | |
| private void | |
| public Watcher |
| closed | back to summary |
|---|---|
| private volatile boolean closed | |
| cmd | back to summary |
|---|---|
| private final String cmd | |
| cwd | back to summary |
|---|---|
| private final File cwd | |
| deploy | back to summary |
|---|---|
| private final Handler<Handler<Void>> deploy | |
| fileMap | back to summary |
|---|---|
| private final Map<File, Map<File, Watcher. | |
| filesToWatch | back to summary |
|---|---|
| private final Set<File> filesToWatch | |
| gracePeriod | back to summary |
|---|---|
| private final long gracePeriod | |
| includes | back to summary |
|---|---|
| private final List<String> includes | |
| lastChange | back to summary |
|---|---|
| private long lastChange This field is always access from the scan thread. No need to be volatile. | |
| LOGGER | back to summary |
|---|---|
| private static final Logger LOGGER | |
| roots | back to summary |
|---|---|
| private final List<File> roots | |
| scanPeriod | back to summary |
|---|---|
| private final long scanPeriod | |
| undeploy | back to summary |
|---|---|
| private final Handler<Handler<Void>> undeploy | |
| Watcher | back to summary |
|---|---|
| public Watcher(File root, List<String> includes, Handler<Handler<Void>> deploy, Handler<Handler<Void>> undeploy, String onRedeployCommand, long gracePeriod, long scanPeriod) Creates a new
| |
| addFilesToWatchedList | back to summary |
|---|---|
| private void addFilesToWatchedList(List<File> roots) | |
| addFileToWatchedList | back to summary |
|---|---|
| private void addFileToWatchedList(File file) | |
| changesHaveOccurred | back to summary |
|---|---|
| private boolean changesHaveOccurred() Checks whether or not a change has occurred in one of the watched file that match one of the given include pattern
. Are detected: new files, modified file and deleted files. File modification is detected using
| |
| close | back to summary |
|---|---|
| public void close() Stops watching. This method stops the underlying | |
| executeUserCommand | back to summary |
|---|---|
| private void executeUserCommand(Handler<Void> onCompletion) | |
| extractRoots | back to summary |
|---|---|
| pack-priv static List | |
| match | back to summary |
|---|---|
| protected boolean match(File file) Checks whether the given file matches one of the
| |
| run | back to summary |
|---|---|
| public void run() Implements java. The watching thread runnable method.
| |
| sanitizeIncludePatterns | back to summary |
|---|---|
| private List | |
| trigger | back to summary |
|---|---|
| private void trigger() Redeployment process. | |
| watch | back to summary |
|---|---|
| public Watcher watch() Starts watching. The watch processing is made in another thread started in this method.
| |
| Modifier and Type | Field and Description |
|---|---|
| pack-priv long | |
| pack-priv long |
| Access | Constructor and Description |
|---|---|
| private |
| lastModified | back to summary |
|---|---|
| pack-priv long lastModified | |
| length | back to summary |
|---|---|
| pack-priv long length | |
| FileInfo | back to summary |
|---|---|
| private FileInfo(long lastModified, long length) | |