Package org.casbin.jcasbin.persist
Interface Watcher
-
- All Known Subinterfaces:
WatcherEx
,WatcherUpdatable
public interface Watcher
Watcher is the interface for Casbin watchers.
-
-
Method Summary
All Methods Instance Methods Abstract Methods Modifier and Type Method Description void
setUpdateCallback(java.lang.Runnable runnable)
SetUpdateCallback sets the callback function that the watcher will call when the policy in DB has been changed by other instances.void
setUpdateCallback(java.util.function.Consumer<java.lang.String> func)
SetUpdateCallback sets the callback function that the watcher will call when the policy in DB has been changed by other instances.void
update()
Update calls the update callback of other instances to synchronize their policy.
-
-
-
Method Detail
-
setUpdateCallback
void setUpdateCallback(java.lang.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(java.util.function.Consumer<java.lang.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.
-
-