Interface Watcher

All Known Subinterfaces:
WatcherEx, WatcherUpdatable

public interface Watcher
Watcher is the interface for Casbin watchers.
  • Method Summary

    Modifier and Type
    Method
    Description
    void
    SetUpdateCallback sets the callback function that the watcher will call when the policy in DB has been changed by other instances.
    void
    SetUpdateCallback sets the callback function that the watcher will call when the policy in DB has been changed by other instances.
    void
    Update calls the update callback of other instances to synchronize their policy.
  • Method Details

    • setUpdateCallback

      void setUpdateCallback(Runnable runnable)
      SetUpdateCallback sets the callback function that the watcher will call when the policy in DB has been changed by other instances. A classic callback is Enforcer.loadPolicy().
      Parameters:
      runnable - the callback function, will be called when policy is updated.
    • setUpdateCallback

      void setUpdateCallback(Consumer<String> func)
      SetUpdateCallback sets the callback function that the watcher will call when the policy in DB has been changed by other instances. A classic callback is Enforcer.loadPolicy().
      Parameters:
      func - the callback function, will be called when policy is updated.
    • update

      void update()
      Update calls the update callback of other instances to synchronize their policy. It is usually called after changing the policy in DB, like Enforcer.savePolicy(), Enforcer.addPolicy(), Enforcer.removePolicy(), etc.