Skip to content

Commit

Permalink
recursion replaced with iteration
Browse files Browse the repository at this point in the history
  • Loading branch information
AdamBien committed Jan 2, 2019
1 parent 9b4604d commit dd0b020
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,10 @@ e.g.

`[THIN_WAR]/java -jar wad.jar /openliberty/wlp/usr/servers/defaultServer/dropins/`

or multiple servers:

`[THIN_WAR]/java -jar wad.jar /openliberty/wlp/usr/servers/defaultServer/dropins/ wildfly/standalone/deployments payara/glassfish/domains/domain1/autodeploy tomee/webapps`

On each source change WAD will:

1. Use the current directory as the service name
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,21 +19,24 @@ public interface FolderWatchService {

public static void listenForChanges(Path dir, Runnable listener) throws IOException {
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
checkForChanges(scheduler, POLLING_INTERVALL, dir, listener);
checkForChanges(scheduler, dir, listener);
}

static void checkForChanges(ScheduledExecutorService scheduler, long initialTimeStamp, Path dir, Runnable changeListener) {
static void checkForChanges(ScheduledExecutorService scheduler, Path dir, Runnable changeListener) {
long initialStamp = getFolderModificationId(dir);
boolean changeDetected = false;
try {
changeDetected = scheduler.schedule(() -> detectModification(dir, initialStamp), POLLING_INTERVALL, TimeUnit.MILLISECONDS).get();
while (true) {
try {
final long previous = initialStamp;
changeDetected = scheduler.schedule(() -> detectModification(dir, previous), POLLING_INTERVALL, TimeUnit.MILLISECONDS).get();
} catch (InterruptedException | ExecutionException ex) {
throw new IllegalStateException("Scheduler error", ex);
}
if (changeDetected) {
changeListener.run();
changeListener.run();
initialStamp = getFolderModificationId(dir);
}
}
checkForChanges(scheduler, getFolderModificationId(dir), dir, changeListener);

}

Expand Down

0 comments on commit dd0b020

Please sign in to comment.