Class FBEventManager
- java.lang.Object
- 
- org.firebirdsql.event.FBEventManager
 
- 
- All Implemented Interfaces:
- java.lang.AutoCloseable,- EventManager
 
 public class FBEventManager extends java.lang.Object implements EventManager AnEventManagerimplementation to listen for database events.- Author:
- Gabriel Reid, Mark Rotteveel, Vasiliy Yashkov
 
- 
- 
Constructor SummaryConstructors Constructor Description FBEventManager()FBEventManager(GDSType gdsType)
 - 
Method SummaryAll Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description voidaddEventListener(java.lang.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(java.sql.Connection connection)Creates anEventManagerfor a connection.voiddisconnect()Close the connection to the database.java.lang.StringgetAuthPlugins()Get the list of authentication plugins to try.java.lang.StringgetDatabase()java.lang.StringgetDbCryptConfig()Get the database encryption plugin configuration.java.lang.StringgetHost()java.lang.StringgetPassword()intgetPort()java.lang.StringgetUser()longgetWaitTimeout()Get the poll timeout in milliseconds of the async thread to check whether it was stopped or not.WireCryptgetWireCrypt()Get the wire encryption level.booleanisConnected()voidremoveEventListener(java.lang.String eventName, EventListener listener)Remove an EventListener for a given event.voidsetAuthPlugins(java.lang.String authPlugins)Sets the authentication plugins to try.voidsetDatabase(java.lang.String database)Sets the database path for the connection to the database.voidsetDbCryptConfig(java.lang.String dbCryptConfig)Sets the database encryption plugin configuration.voidsetHost(java.lang.String host)Sets the host for the connection to the database.voidsetPassword(java.lang.String password)Sets the password for the connection to the database.voidsetPort(int port)Sets the port for the connection to the database.voidsetUser(java.lang.String user)Sets 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(java.lang.String eventName)Wait for the one-time occurrence of an event.intwaitForEvent(java.lang.String eventName, int timeout)Wait for the one-time occurrence of an event.
 
- 
- 
- 
Constructor Detail- 
FBEventManagerpublic FBEventManager() 
 - 
FBEventManagerpublic FBEventManager(GDSType gdsType) 
 
- 
 - 
Method Detail- 
createForpublic static EventManager createFor(java.sql.Connection connection) throws java.sql.SQLException 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 to- FirebirdConnection
- Returns:
- An event manager
- Throws:
- java.sql.SQLException- When- connectiondoes not unwrap to- FirebirdConnection
- Since:
- 3.0.7
 
 - 
connectpublic void connect() throws java.sql.SQLExceptionDescription copied from interface:EventManagerMake a connection with a database to listen for events.- Specified by:
- connectin interface- EventManager
- Throws:
- java.sql.SQLException- If a database communication error occurs
 
 - 
closepublic void close() throws java.sql.SQLExceptionDescription copied from interface:EventManagerIf connected, disconnects, otherwise does nothing.Contrary to EventManager.disconnect(), this method does not throwIllegalStateExceptionwhen not connected.- Specified by:
- closein interface- java.lang.AutoCloseable
- Specified by:
- closein interface- EventManager
- Throws:
- java.sql.SQLException- For errors during disconnect
 
 - 
disconnectpublic void disconnect() throws java.sql.SQLExceptionDescription copied from interface:EventManagerClose the connection to the database.- Specified by:
- disconnectin interface- EventManager
- Throws:
- java.sql.SQLException- If a database communication error occurs
- See Also:
- EventManager.close()
 
 - 
isConnectedpublic boolean isConnected() - Specified by:
- isConnectedin interface- EventManager
- Returns:
- truewhen connected and able to listen for events
- See Also:
- EventManager.connect(),- EventManager.disconnect()
 
 - 
setUserpublic void setUser(java.lang.String user) Description copied from interface:EventManagerSets the username for the connection to the database .- Specified by:
- setUserin interface- EventManager
- Parameters:
- user- for the connection to the database.
 
 - 
getUserpublic java.lang.String getUser() - Specified by:
- getUserin interface- EventManager
- Returns:
- the username for the connection to the database.
 
 - 
setPasswordpublic void setPassword(java.lang.String password) Description copied from interface:EventManagerSets the password for the connection to the database.- Specified by:
- setPasswordin interface- EventManager
- Parameters:
- password- for the connection to the database.
 
 - 
getPasswordpublic java.lang.String getPassword() - Specified by:
- getPasswordin interface- EventManager
- Returns:
- the password for the connection to the database.
 
 - 
setDatabasepublic void setDatabase(java.lang.String database) Description copied from interface:EventManagerSets the database path for the connection to the database.- Specified by:
- setDatabasein interface- EventManager
- Parameters:
- database- path for the connection to the database.
 
 - 
getDatabasepublic java.lang.String getDatabase() - Specified by:
- getDatabasein interface- EventManager
- Returns:
- the database path for the connection to the database.
 
 - 
getHostpublic java.lang.String getHost() - Specified by:
- getHostin interface- EventManager
- Returns:
- the host for the connection to the database.
 
 - 
setHostpublic void setHost(java.lang.String host) Description copied from interface:EventManagerSets the host for the connection to the database.- Specified by:
- setHostin interface- EventManager
- Parameters:
- host- for the connection to the database.
 
 - 
getPortpublic int getPort() - Specified by:
- getPortin interface- EventManager
- Returns:
- the port for the connection to the database.
 
 - 
setPortpublic void setPort(int port) Description copied from interface:EventManagerSets the port for the connection to the database.- Specified by:
- setPortin interface- EventManager
- Parameters:
- port- for the connection to the database.
 
 - 
getWireCryptpublic WireCrypt getWireCrypt() Description copied from interface:EventManagerGet the wire encryption level.- Specified by:
- getWireCryptin interface- EventManager
- Returns:
- Wire encryption level
 
 - 
setWireCryptpublic void setWireCrypt(WireCrypt wireCrypt) Description copied from interface:EventManagerSet the wire encryption level.- Specified by:
- setWireCryptin interface- EventManager
- Parameters:
- wireCrypt- Wire encryption level (- nullnot allowed)
 
 - 
getDbCryptConfigpublic java.lang.String getDbCryptConfig() Description copied from interface:EventManagerGet the database encryption plugin configuration.- Specified by:
- getDbCryptConfigin interface- EventManager
- Returns:
- Database encryption plugin configuration, meaning plugin specific
 
 - 
setDbCryptConfigpublic void setDbCryptConfig(java.lang.String dbCryptConfig) Description copied from interface:EventManagerSets the database encryption plugin configuration.- Specified by:
- setDbCryptConfigin interface- EventManager
- Parameters:
- dbCryptConfig- Database encryption plugin configuration, meaning plugin specific
 
 - 
getAuthPluginspublic java.lang.String getAuthPlugins() Description copied from interface:EventManagerGet the list of authentication plugins to try.- Specified by:
- getAuthPluginsin interface- EventManager
- Returns:
- comma-separated list of authentication plugins, or nullfor driver default
 
 - 
setAuthPluginspublic void setAuthPlugins(java.lang.String authPlugins) Description copied from interface:EventManagerSets the authentication plugins to try.Invalid names are skipped during authentication. - Specified by:
- setAuthPluginsin interface- EventManager
- Parameters:
- authPlugins- comma-separated list of authentication plugins, or- nullfor driver default
 
 - 
getWaitTimeoutpublic 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 interface- EventManager
- Returns:
- wait timeout in milliseconds
 
 - 
setWaitTimeoutpublic 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 interface- EventManager
- Parameters:
- waitTimeout- wait timeout in milliseconds
 
 - 
addEventListenerpublic void addEventListener(java.lang.String eventName, EventListener listener) throws java.sql.SQLExceptionDescription copied from interface:EventManagerRegister an EventListener that will be called when an event occurs.- Specified by:
- addEventListenerin interface- EventManager
- Parameters:
- eventName- The name of the event for which the listener will be notified
- listener- The EventListener that will be called when the given event occurs
- Throws:
- java.sql.SQLException- If a database access error occurs
 
 - 
removeEventListenerpublic void removeEventListener(java.lang.String eventName, EventListener listener) throws java.sql.SQLExceptionDescription copied from interface:EventManagerRemove an EventListener for a given event.- Specified by:
- removeEventListenerin interface- EventManager
- Parameters:
- eventName- The name of the event for which the listener will be unregistered.
- listener- The EventListener that is to be unregistered
- Throws:
- java.sql.SQLException- If a database access error occurs
 
 - 
waitForEventpublic int waitForEvent(java.lang.String eventName) throws java.lang.InterruptedException, java.sql.SQLExceptionDescription 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 interface- EventManager
- Parameters:
- eventName- The name of the event to wait for
- Returns:
- The number of occurences of the requested event
- Throws:
- java.lang.InterruptedException- If interrupted while waiting
- java.sql.SQLException- If a database access error occurs
 
 - 
waitForEventpublic int waitForEvent(java.lang.String eventName, int timeout) throws java.lang.InterruptedException, java.sql.SQLExceptionDescription 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 interface- EventManager
- Parameters:
- eventName- The name of the event to wait for
- timeout- The maximum number of milliseconds to wait
- Returns:
- The number of occurrences of the requested event, or 1if the call timed out
- Throws:
- java.lang.InterruptedException- If interrupted while waiting
- java.sql.SQLException- If a database access error occurs
 
 
- 
 
-