Package org.firebirdsql.event
Interface EventManager
- All Superinterfaces:
AutoCloseable
- All Known Implementing Classes:
FBEventManager
An interface for registering
EventListener instances to listen for database events.- Author:
- Gabriel Reid, Mark Rotteveel
-
Method Summary
Modifier and TypeMethodDescriptionvoidaddEventListener(String eventName, EventListener listener) Register an EventListener that will be called when an event occurs.voidclose()If connected, disconnects, otherwise does nothing.voidconnect()Make a connection with a database to listen for events.voidClose the connection to the database.Get the list of authentication plugins to try.Get the database encryption plugin configuration.getHost()intgetPort()getUser()longGet the poll timeout in milliseconds of the async thread to check whether it was stopped or not.Get the wire encryption level.booleanvoidremoveEventListener(String eventName, EventListener listener) Remove an EventListener for a given event.voidsetAuthPlugins(String authPlugins) Sets the authentication plugins to try.voidsetDatabase(String database) Sets the database path for the connection to the database.voidsetDbCryptConfig(String dbCryptConfig) Sets the database encryption plugin configuration.voidSets the host for the connection to the database.voidsetPassword(String password) Sets the password for the connection to the database.voidsetPort(int port) Sets the port for the connection to the database.voidSets the username for the connection to the database .voidsetWaitTimeout(long waitTimeout) Set the poll timeout in milliseconds of the async thread to check whether it was stopped or not.voidsetWireCrypt(WireCrypt wireCrypt) Set the wire encryption level.intwaitForEvent(String eventName) Wait for the one-time occurrence of an event.intwaitForEvent(String eventName, int timeout) Wait for the one-time occurrence of an event.
-
Method Details
-
connect
Make a connection with a database to listen for events.- Throws:
SQLException- If a database communication error occursIllegalStateException- If already connected
-
close
If connected, disconnects, otherwise does nothing.Contrary to
disconnect(), this method does not throwIllegalStateExceptionwhen not connected.- Specified by:
closein interfaceAutoCloseable- Throws:
SQLException- For errors during disconnect- Since:
- 3.0.7
-
disconnect
Close the connection to the database.- Throws:
SQLException- If a database communication error occursIllegalStateException- If not currently connected- See Also:
-
isConnected
boolean isConnected()- Returns:
truewhen connected and able to listen for events- See Also:
-
setUser
Sets the username for the connection to the database .- Parameters:
user- for the connection to the database.
-
getUser
String getUser()- Returns:
- the username for the connection to the database.
-
setPassword
Sets the password for the connection to the database.- Parameters:
password- for the connection to the database.
-
getPassword
String getPassword()- Returns:
- the password for the connection to the database.
-
setDatabase
Sets the database path for the connection to the database.- Parameters:
database- path for the connection to the database.
-
getDatabase
String getDatabase()- Returns:
- the database path for the connection to the database.
-
getHost
String getHost()- Returns:
- the host for the connection to the database.
-
setHost
Sets the host for the connection to the database.- Parameters:
host- for the connection to the database.
-
getPort
int getPort()- Returns:
- the port for the connection to the database.
-
setPort
void setPort(int port) Sets the port for the connection to the database.- Parameters:
port- for the connection to the database.
-
getWireCrypt
WireCrypt getWireCrypt()Get the wire encryption level.- Returns:
- Wire encryption level
- Since:
- 3.0.4
-
setWireCrypt
Set the wire encryption level.- Parameters:
wireCrypt- Wire encryption level (nullnot allowed)- Since:
- 3.0.4
-
getDbCryptConfig
String getDbCryptConfig()Get the database encryption plugin configuration.- Returns:
- Database encryption plugin configuration, meaning plugin specific
- Since:
- 3.0.4
-
setDbCryptConfig
Sets the database encryption plugin configuration.- Parameters:
dbCryptConfig- Database encryption plugin configuration, meaning plugin specific- Since:
- 3.0.4
-
getAuthPlugins
String getAuthPlugins()Get the list of authentication plugins to try.- Returns:
- comma-separated list of authentication plugins, or
nullfor driver default - Since:
- 4.0
-
setAuthPlugins
Sets the authentication plugins to try.Invalid names are skipped during authentication.
- Parameters:
authPlugins- comma-separated list of authentication plugins, ornullfor driver default- Since:
- 4.0
-
getWaitTimeout
long getWaitTimeout()Get the poll timeout in milliseconds of the async thread to check whether it was stopped or not.Default value is 1000 (1 second).
- Returns:
- wait timeout in milliseconds
-
setWaitTimeout
void setWaitTimeout(long waitTimeout) Set the poll timeout in milliseconds of the async thread to check whether it was stopped or not.Default value is 1000 (1 second).
- Parameters:
waitTimeout- wait timeout in milliseconds
-
addEventListener
Register an EventListener that will be called when an event occurs.- Parameters:
eventName- The name of the event for which the listener will be notifiedlistener- The EventListener that will be called when the given event occurs- Throws:
SQLException- If a database access error occurs
-
removeEventListener
Remove an EventListener for a given event.- Parameters:
eventName- The name of the event for which the listener will be unregistered.listener- The EventListener that is to be unregistered- Throws:
SQLException- If a database access error occurs
-
waitForEvent
Wait for the one-time occurrence of an event.This method blocks indefinitely until the event identified by the value of
eventNameoccurs. The return value is the number of occurrences of the requested event.- Parameters:
eventName- The name of the event to wait for- Returns:
- The number of occurences of the requested event
- Throws:
InterruptedException- If interrupted while waitingSQLException- If a database access error occurs
-
waitForEvent
Wait for the one-time occurrence of an event.This method blocks for a maximum of
timeoutmilliseconds, waiting for the event identified byeventNameto occur. A timeout value of0means wait indefinitely.The return value is the number of occurences of the event in question, or
-1if the call timed out.- Parameters:
eventName- The name of the event to wait fortimeout- The maximum number of milliseconds to wait- Returns:
- The number of occurrences of the requested event, or
1if the call timed out - Throws:
InterruptedException- If interrupted while waitingSQLException- If a database access error occurs
-