Interface Watcher
- All Known Subinterfaces:
WatcherEx, WatcherUpdatable
public interface Watcher
Watcher is the interface for Casbin watchers.
-
Method Summary
Modifier and TypeMethodDescriptionvoidsetUpdateCallback(Runnable runnable) SetUpdateCallback sets the callback function that the watcher will call when the policy in DB has been changed by other instances.voidsetUpdateCallback(Consumer<String> func) SetUpdateCallback sets the callback function that the watcher will call when the policy in DB has been changed by other instances.voidupdate()Update calls the update callback of other instances to synchronize their policy.
-
Method Details
-
setUpdateCallback
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
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.
-