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 voidaddListener(Listener listener)Registers new listenervoidcheckAndNotify()Called periodically byResourceWatcherServiceso resource watcher can check the resourceprotected abstract voiddoCheckAndNotify()Will be called periodicallyprotected abstract voiddoInit()Will be called once on initializationvoidinit()Called once when the resource watcher is added toResourceWatcherServiceprotected java.util.List<Listener>listeners()Returns a list of listenersvoidremove(Listener listener)Unregisters a listener
-
-
-
Method Detail
-
init
public void init() throws java.io.IOExceptionDescription copied from interface:ResourceWatcherCalled once when the resource watcher is added toResourceWatcherService- Specified by:
initin interfaceResourceWatcher- Throws:
java.io.IOException
-
checkAndNotify
public void checkAndNotify() throws java.io.IOExceptionDescription copied from interface:ResourceWatcherCalled periodically byResourceWatcherServiceso resource watcher can check the resource- Specified by:
checkAndNotifyin interfaceResourceWatcher- Throws:
java.io.IOException
-
addListener
public void addListener(Listener listener)
Registers new listener
-
remove
public void remove(Listener listener)
Unregisters a listener
-
listeners
protected java.util.List<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
-
-