Merge pull request #19638 from rjernst/filewatcher_interface

Change file changes listener for resource watcher to an interface
This commit is contained in:
Ryan Ernst 2016-07-27 15:33:14 -07:00 committed by GitHub
commit dcf42b8d64
3 changed files with 10 additions and 24 deletions

View File

@ -487,7 +487,7 @@ public class ScriptService extends AbstractComponent implements Closeable, Clust
} }
} }
private class ScriptChangesListener extends FileChangesListener { private class ScriptChangesListener implements FileChangesListener {
private Tuple<String, String> getScriptNameExt(Path file) { private Tuple<String, String> getScriptNameExt(Path file) {
Path scriptPath = scriptsDirectory.relativize(file); Path scriptPath = scriptsDirectory.relativize(file);

View File

@ -23,53 +23,39 @@ import java.nio.file.Path;
/** /**
* Callback interface that file changes File Watcher is using to notify listeners about changes. * Callback interface that file changes File Watcher is using to notify listeners about changes.
*/ */
public class FileChangesListener { public interface FileChangesListener {
/** /**
* Called for every file found in the watched directory during initialization * Called for every file found in the watched directory during initialization
*/ */
public void onFileInit(Path file) { default void onFileInit(Path file) {}
}
/** /**
* Called for every subdirectory found in the watched directory during initialization * Called for every subdirectory found in the watched directory during initialization
*/ */
public void onDirectoryInit(Path file) { default void onDirectoryInit(Path file) {}
}
/** /**
* Called for every new file found in the watched directory * Called for every new file found in the watched directory
*/ */
public void onFileCreated(Path file) { default void onFileCreated(Path file) {}
}
/** /**
* Called for every file that disappeared in the watched directory * Called for every file that disappeared in the watched directory
*/ */
public void onFileDeleted(Path file) { default void onFileDeleted(Path file) {}
}
/** /**
* Called for every file that was changed in the watched directory * Called for every file that was changed in the watched directory
*/ */
public void onFileChanged(Path file) { default void onFileChanged(Path file) {}
}
/** /**
* Called for every new subdirectory found in the watched directory * Called for every new subdirectory found in the watched directory
*/ */
public void onDirectoryCreated(Path file) { default void onDirectoryCreated(Path file) {}
}
/** /**
* Called for every file that disappeared in the watched directory * Called for every file that disappeared in the watched directory
*/ */
public void onDirectoryDeleted(Path file) { default void onDirectoryDeleted(Path file) {}
}
} }

View File

@ -37,7 +37,7 @@ import static org.hamcrest.Matchers.hasSize;
@LuceneTestCase.SuppressFileSystems("ExtrasFS") @LuceneTestCase.SuppressFileSystems("ExtrasFS")
public class FileWatcherTests extends ESTestCase { public class FileWatcherTests extends ESTestCase {
private class RecordingChangeListener extends FileChangesListener { private class RecordingChangeListener implements FileChangesListener {
private Path rootDir; private Path rootDir;
private RecordingChangeListener(Path rootDir) { private RecordingChangeListener(Path rootDir) {