Change file changes listener for resource watcher to an interface
Currently to use the ResourceWatcherService to watch files, you implement a FileChangesListener. However, this is a class, not an interface, even though it has no base state or anything like that, just defining a few methods. This change converts FileChangesListener to an interface.
This commit is contained in:
parent
0876247bca
commit
95499c45a5
|
@ -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);
|
||||||
|
|
|
@ -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) {}
|
||||||
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue