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
All Methods Instance Methods Abstract Methods Concrete Methods 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 listener
-
-
-
Method Detail
-
init
public void init() throws java.io.IOException
Description 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.IOException
Description copied from interface:ResourceWatcher
Called periodically byResourceWatcherService
so resource watcher can check the resource- Specified by:
checkAndNotify
in 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.IOException
Will be called once on initialization- Throws:
java.io.IOException
-
doCheckAndNotify
protected abstract void doCheckAndNotify() throws java.io.IOException
Will be called periodicallyImplementing watcher should check resource and notify all
listeners()
.- Throws:
java.io.IOException
-
-