Skip to content

Commit

Permalink
Change file changes listener for resource watcher to an interface
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
rjernst committed Jul 27, 2016
1 parent 0876247 commit 95499c4
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 24 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -487,7 +487,7 @@ public void onRemoval(RemovalNotification<CacheKey, CompiledScript> notification
}
}

private class ScriptChangesListener extends FileChangesListener {
private class ScriptChangesListener implements FileChangesListener {

private Tuple<String, String> getScriptNameExt(Path file) {
Path scriptPath = scriptsDirectory.relativize(file);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,53 +23,39 @@
/**
* 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
*/
public void onFileInit(Path file) {

}
default void onFileInit(Path file) {}

/**
* 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
*/
public void onFileCreated(Path file) {

}
default void onFileCreated(Path file) {}

/**
* 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
*/
public void onFileChanged(Path file) {

}
default void onFileChanged(Path file) {}

/**
* 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
*/
public void onDirectoryDeleted(Path file) {

}
default void onDirectoryDeleted(Path file) {}
}
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@

@LuceneTestCase.SuppressFileSystems("ExtrasFS")
public class FileWatcherTests extends ESTestCase {
private class RecordingChangeListener extends FileChangesListener {
private class RecordingChangeListener implements FileChangesListener {
private Path rootDir;

private RecordingChangeListener(Path rootDir) {
Expand Down

0 comments on commit 95499c4

Please sign in to comment.