Package org.casbin.watcher
Class PostgresWatcher
- java.lang.Object
-
- org.casbin.watcher.PostgresWatcher
-
public class PostgresWatcher extends java.lang.Object
The core class of Postgres Watcher, responsible for database connection, listening, and notification.
-
-
Constructor Summary
Constructors Constructor Description PostgresWatcher(java.lang.String url, java.lang.String user, java.lang.String password)
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description void
close()
Close the connection and the listening thread.void
connect()
Connecting to the databasevoid
listen(java.lang.String channel, java.util.function.Consumer<java.lang.String> callback)
Listen to the specified channel and invoke a callback when a message is received.void
notify(java.lang.String channel, java.lang.String message)
sent NOTIFY
-
-
-
Method Detail
-
connect
public void connect() throws java.sql.SQLException
Connecting to the database- Throws:
java.sql.SQLException
-
listen
public void listen(java.lang.String channel, java.util.function.Consumer<java.lang.String> callback)
Listen to the specified channel and invoke a callback when a message is received.
-
notify
public void notify(java.lang.String channel, java.lang.String message) throws java.sql.SQLException
sent NOTIFY- Throws:
java.sql.SQLException
-
close
public void close()
Close the connection and the listening thread.
-
-