@Override
public void execute( final ConfigServiceWatchServiceExecutor wsExecutor ) {
while ( active ) {
try {
final WatchKey wk;
try {
wk = ws.take();
} catch ( final Exception ex ) {
break;
}
final List<WatchEvent<?>> events = wk.pollEvents();
boolean markerFileModified = false;
for ( final WatchEvent<?> event : events ) {
final WatchContext context = (WatchContext) event.context();
if ( event.kind().equals( StandardWatchEventKind.ENTRY_MODIFY ) ) {
if ( context.getOldPath().getFileName().toString().equals( LAST_MODIFIED_MARKER_FILE ) ) {
markerFileModified = true;
break;
}
} else if ( event.kind().equals( StandardWatchEventKind.ENTRY_CREATE ) ) {
if ( context.getPath().getFileName().toString().equals( LAST_MODIFIED_MARKER_FILE ) ) {
markerFileModified = true;
break;
}
} else if ( event.kind().equals( StandardWatchEventKind.ENTRY_RENAME ) ) {
if ( context.getOldPath().getFileName().toString().equals( LAST_MODIFIED_MARKER_FILE ) ) {
markerFileModified = true;
break;
}
} else if ( event.kind().equals( StandardWatchEventKind.ENTRY_DELETE ) ) {
if ( context.getOldPath().getFileName().toString().equals( LAST_MODIFIED_MARKER_FILE ) ) {
markerFileModified = true;
break;
}
}
}
if ( markerFileModified ) {
wsExecutor.execute( wk, localLastModifiedValue.get(), ConfigurationServiceImpl.this );
}
boolean valid = wk.reset();
if ( !valid ) {
break;
}
} catch ( final Exception ignored ) {
}