Class FBEventManager
- All Implemented Interfaces:
AutoCloseable,EventManager
EventManager implementation to listen for database events.- Author:
- Gabriel Reid, Mark Rotteveel, Vasiliy Yashkov
-
Constructor Summary
Constructors -
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.static EventManagercreateFor(Connection connection) Creates anEventManagerfor a connection.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.
-
Constructor Details
-
FBEventManager
public FBEventManager() -
FBEventManager
-
-
Method Details
-
createFor
Creates anEventManagerfor a connection.The created event manager does not allow setting the properties and will instead throw
UnsupportedOperationExceptionfor the setters.The returned instance is not necessarily an implementation of
FBEventManager.- Parameters:
connection- A connection that unwraps toFirebirdConnection- Returns:
- An event manager
- Throws:
SQLException- Whenconnectiondoes not unwrap toFirebirdConnection- Since:
- 3.0.7
-
connect
Description copied from interface:EventManagerMake a connection with a database to listen for events.- Specified by:
connectin interfaceEventManager- Throws:
SQLException- If a database communication error occurs
-
close
Description copied from interface:EventManagerIf connected, disconnects, otherwise does nothing.Contrary to
EventManager.disconnect(), this method does not throwIllegalStateExceptionwhen not connected.- Specified by:
closein interfaceAutoCloseable- Specified by:
closein interfaceEventManager- Throws:
SQLException- For errors during disconnect
-
disconnect
Description copied from interface:EventManagerClose the connection to the database.- Specified by:
disconnectin interfaceEventManager- Throws:
SQLException- If a database communication error occurs- See Also:
-
isConnected
public boolean isConnected()- Specified by:
isConnectedin interfaceEventManager- Returns:
truewhen connected and able to listen for events- See Also:
-
setUser
Description copied from interface:EventManagerSets the username for the connection to the database .- Specified by:
setUserin interfaceEventManager- Parameters:
user- for the connection to the database.
-
getUser
- Specified by:
getUserin interfaceEventManager- Returns:
- the username for the connection to the database.
-
setPassword
Description copied from interface:EventManagerSets the password for the connection to the database.- Specified by:
setPasswordin interfaceEventManager- Parameters:
password- for the connection to the database.
-
getPassword
- Specified by:
getPasswordin interfaceEventManager- Returns:
- the password for the connection to the database.
-
setDatabase
Description copied from interface:EventManagerSets the database path for the connection to the database.- Specified by:
setDatabasein interfaceEventManager- Parameters:
database- path for the connection to the database.
-
getDatabase
- Specified by:
getDatabasein interfaceEventManager- Returns:
- the database path for the connection to the database.
-
getHost
- Specified by:
getHostin interfaceEventManager- Returns:
- the host for the connection to the database.
-
setHost
Description copied from interface:EventManagerSets the host for the connection to the database.- Specified by:
setHostin interfaceEventManager- Parameters:
host- for the connection to the database.
-
getPort
public int getPort()- Specified by:
getPortin interfaceEventManager- Returns:
- the port for the connection to the database.
-
setPort
public void setPort(int port) Description copied from interface:EventManagerSets the port for the connection to the database.- Specified by:
setPortin interfaceEventManager- Parameters:
port- for the connection to the database.
-
getWireCrypt
Description copied from interface:EventManagerGet the wire encryption level.- Specified by:
getWireCryptin interfaceEventManager- Returns:
- Wire encryption level
-
setWireCrypt
Description copied from interface:EventManagerSet the wire encryption level.- Specified by:
setWireCryptin interfaceEventManager- Parameters:
wireCrypt- Wire encryption level (nullnot allowed)
-
getDbCryptConfig
Description copied from interface:EventManagerGet the database encryption plugin configuration.- Specified by:
getDbCryptConfigin interfaceEventManager- Returns:
- Database encryption plugin configuration, meaning plugin specific
-
setDbCryptConfig
Description copied from interface:EventManagerSets the database encryption plugin configuration.- Specified by:
setDbCryptConfigin interfaceEventManager- Parameters:
dbCryptConfig- Database encryption plugin configuration, meaning plugin specific
-
getAuthPlugins
Description copied from interface:EventManagerGet the list of authentication plugins to try.- Specified by:
getAuthPluginsin interfaceEventManager- Returns:
- comma-separated list of authentication plugins, or
nullfor driver default
-
setAuthPlugins
Description copied from interface:EventManagerSets the authentication plugins to try.Invalid names are skipped during authentication.
- Specified by:
setAuthPluginsin interfaceEventManager- Parameters:
authPlugins- comma-separated list of authentication plugins, ornullfor driver default
-
getWaitTimeout
public long getWaitTimeout()Description copied from interface:EventManagerGet the poll timeout in milliseconds of the async thread to check whether it was stopped or not.Default value is 1000 (1 second).
- Specified by:
getWaitTimeoutin interfaceEventManager- Returns:
- wait timeout in milliseconds
-
setWaitTimeout
public void setWaitTimeout(long waitTimeout) Description copied from interface:EventManagerSet the poll timeout in milliseconds of the async thread to check whether it was stopped or not.Default value is 1000 (1 second).
- Specified by:
setWaitTimeoutin interfaceEventManager- Parameters:
waitTimeout- wait timeout in milliseconds
-
addEventListener
Description copied from interface:EventManagerRegister an EventListener that will be called when an event occurs.- Specified by:
addEventListenerin interfaceEventManager- 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
Description copied from interface:EventManagerRemove an EventListener for a given event.- Specified by:
removeEventListenerin interfaceEventManager- 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
Description copied from interface:EventManagerWait 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.- Specified by:
waitForEventin interfaceEventManager- 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
Description copied from interface:EventManagerWait 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.- Specified by:
waitForEventin interfaceEventManager- 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
-