Interface ChangeWatcher<T>

Type Parameters:
T - target of this change watcher, such as Path
All Known Implementing Classes:
EtcdWatcher, FileSystemWatcher

public interface ChangeWatcher<T>
Similar to a PollingStrategy a change watcher is used to identify a change and trigger reload of a ConfigSource. Where a polling strategy provides polling events to check for changes, change watcher is capable of identifying a change in the underlying target using other means.
  • Nested Class Summary

    Nested Classes
    Modifier and Type
    Interface
    Description
    static interface 
    A change event, carrying the target, type of change and time of change.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    Start watching a target for changes.
    default void
    Stop watching all targets for changes.
    Target supported by this change watcher.
  • Method Details

    • start

      void start(T target, Consumer<ChangeWatcher.ChangeEvent<T>> listener)
      Start watching a target for changes. If a change happens, notify the listener.
      Parameters:
      target - target of this watcher, such as Path
      listener - listener that handles reloading of the resource being watched
    • stop

      default void stop()
      Stop watching all targets for changes.
    • type

      Class<T> type()
      Target supported by this change watcher.
      Returns:
      type supported