Package org.elasticsearch.watcher
Class AbstractResourceWatcher<Listener>
java.lang.Object
org.elasticsearch.watcher.AbstractResourceWatcher<Listener>
- All Implemented Interfaces:
ResourceWatcher
- Direct Known Subclasses:
FileWatcher
public abstract class AbstractResourceWatcher<Listener> extends java.lang.Object implements ResourceWatcher
Abstract resource watcher framework, which handles adding and removing listeners
and calling resource observer.
-
Constructor Summary
Constructors Constructor Description AbstractResourceWatcher()
-
Method Summary
Modifier and Type Method Description void
addListener(Listener listener)
Registers new listenervoid
checkAndNotify()
Called periodically byResourceWatcherService
so resource watcher can check the resourceprotected abstract void
doCheckAndNotify()
Will be called periodicallyprotected abstract void
doInit()
Will be called once on initializationvoid
init()
Called once when the resource watcher is added toResourceWatcherService
protected java.util.List<Listener>
listeners()
Returns a list of listenersvoid
remove(Listener listener)
Unregisters a listenerMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
-
Constructor Details
-
AbstractResourceWatcher
public AbstractResourceWatcher()
-
-
Method Details
-
init
public void init() throws java.io.IOExceptionDescription copied from interface:ResourceWatcher
Called once when the resource watcher is added toResourceWatcherService
- Specified by:
init
in interfaceResourceWatcher
- Throws:
java.io.IOException
-
checkAndNotify
public void checkAndNotify() throws java.io.IOExceptionDescription copied from interface:ResourceWatcher
Called periodically byResourceWatcherService
so resource watcher can check the resource- Specified by:
checkAndNotify
in interfaceResourceWatcher
- Throws:
java.io.IOException
-
addListener
Registers new listener -
remove
Unregisters a listener -
listeners
Returns a list of listeners -
doInit
protected abstract void doInit() throws java.io.IOExceptionWill be called once on initialization- Throws:
java.io.IOException
-
doCheckAndNotify
protected abstract void doCheckAndNotify() throws java.io.IOExceptionWill be called periodicallyImplementing watcher should check resource and notify all
listeners()
.- Throws:
java.io.IOException
-