Class AbstractResourceWatcher<Listener>

  • All Implemented Interfaces:
    Direct Known Subclasses:

    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.
    • 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 Detail

      • AbstractResourceWatcher

        public AbstractResourceWatcher()
    • Method Detail

      • 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()
        Will be called once on initialization
      • doCheckAndNotify

        protected abstract void doCheckAndNotify()
        Will be called periodically

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