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 listener
    void checkAndNotify()
    Called periodically by ResourceWatcherService so resource watcher can check the resource
    protected abstract void doCheckAndNotify()
    Will be called periodically
    protected abstract void doInit()
    Will be called once on initialization
    void init()
    Called once when the resource watcher is added to ResourceWatcherService
    protected java.util.List<Listener> listeners()
    Returns a list of listeners
    void remove​(Listener listener)
    Unregisters a listener

    Methods 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.IOException
      Description copied from interface: ResourceWatcher
      Called once when the resource watcher is added to ResourceWatcherService
      Specified by:
      init in interface ResourceWatcher
      Throws:
      java.io.IOException
    • checkAndNotify

      public void checkAndNotify() throws java.io.IOException
      Description copied from interface: ResourceWatcher
      Called periodically by ResourceWatcherService so resource watcher can check the resource
      Specified by:
      checkAndNotify in interface ResourceWatcher
      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 periodically

      Implementing watcher should check resource and notify all listeners().

      Throws:
      java.io.IOException