public class FBEventManager extends java.lang.Object implements EventManager
EventManager implementation to listen for database events.| Constructor and Description |
|---|
FBEventManager() |
FBEventManager(GDSType gdsType) |
| Modifier and Type | Method and Description |
|---|---|
void |
addEventListener(java.lang.String eventName,
EventListener listener)
Register an EventListener that will be called when an event occurs.
|
void |
close()
If connected, disconnects, otherwise does nothing.
|
void |
connect()
Make a connection with a database to listen for events.
|
static EventManager |
createFor(java.sql.Connection connection)
Creates an
EventManager for a connection. |
void |
disconnect()
Close the connection to the database.
|
java.lang.String |
getAuthPlugins()
Get the list of authentication plugins to try.
|
java.lang.String |
getDatabase() |
java.lang.String |
getDbCryptConfig()
Get the database encryption plugin configuration.
|
java.lang.String |
getHost() |
java.lang.String |
getPassword() |
int |
getPort() |
java.lang.String |
getUser() |
long |
getWaitTimeout()
Get the poll timeout in milliseconds of the async thread to check whether it was stopped or not.
|
WireCrypt |
getWireCrypt()
Get the wire encryption level.
|
boolean |
isConnected() |
void |
removeEventListener(java.lang.String eventName,
EventListener listener)
Remove an EventListener for a given event.
|
void |
setAuthPlugins(java.lang.String authPlugins)
Sets the authentication plugins to try.
|
void |
setDatabase(java.lang.String database)
Sets the database path for the connection to the database.
|
void |
setDbCryptConfig(java.lang.String dbCryptConfig)
Sets the database encryption plugin configuration.
|
void |
setHost(java.lang.String host)
Sets the host for the connection to the database.
|
void |
setPassword(java.lang.String password)
Sets the password for the connection to the database.
|
void |
setPort(int port)
Sets the port for the connection to the database.
|
void |
setUser(java.lang.String user)
Sets the username for the connection to the database .
|
void |
setWaitTimeout(long waitTimeout)
Set the poll timeout in milliseconds of the async thread to check whether it was stopped or not.
|
void |
setWireCrypt(WireCrypt wireCrypt)
Set the wire encryption level.
|
int |
waitForEvent(java.lang.String eventName)
Wait for the one-time occurrence of an event.
|
int |
waitForEvent(java.lang.String eventName,
int timeout)
Wait for the one-time occurrence of an event.
|
public FBEventManager()
public FBEventManager(GDSType gdsType)
public static EventManager createFor(java.sql.Connection connection) throws java.sql.SQLException
EventManager for a connection.
The created event manager does not allow setting the properties and will instead
throw UnsupportedOperationException for the setters.
The returned instance is not necessarily an implementation of FBEventManager.
connection - A connection that unwraps to FirebirdConnectionjava.sql.SQLException - When connection does not unwrap to FirebirdConnectionpublic void connect()
throws java.sql.SQLException
EventManagerconnect in interface EventManagerjava.sql.SQLException - If a database communication error occurspublic void close()
throws java.sql.SQLException
EventManager
Contrary to EventManager.disconnect(), this method does not throw IllegalStateException when not connected.
close in interface java.lang.AutoCloseableclose in interface EventManagerjava.sql.SQLException - For errors during disconnectpublic void disconnect()
throws java.sql.SQLException
EventManagerdisconnect in interface EventManagerjava.sql.SQLException - If a database communication error occursEventManager.close()public boolean isConnected()
isConnected in interface EventManagertrue when connected and able to listen for eventsEventManager.connect(),
EventManager.disconnect()public void setUser(java.lang.String user)
EventManagersetUser in interface EventManageruser - for the connection to the database.public java.lang.String getUser()
getUser in interface EventManagerpublic void setPassword(java.lang.String password)
EventManagersetPassword in interface EventManagerpassword - for the connection to the database.public java.lang.String getPassword()
getPassword in interface EventManagerpublic void setDatabase(java.lang.String database)
EventManagersetDatabase in interface EventManagerdatabase - path for the connection to the database.public java.lang.String getDatabase()
getDatabase in interface EventManagerpublic java.lang.String getHost()
getHost in interface EventManagerpublic void setHost(java.lang.String host)
EventManagersetHost in interface EventManagerhost - for the connection to the database.public int getPort()
getPort in interface EventManagerpublic void setPort(int port)
EventManagersetPort in interface EventManagerport - for the connection to the database.public WireCrypt getWireCrypt()
EventManagergetWireCrypt in interface EventManagerpublic void setWireCrypt(WireCrypt wireCrypt)
EventManagersetWireCrypt in interface EventManagerwireCrypt - Wire encryption level (null not allowed)public java.lang.String getDbCryptConfig()
EventManagergetDbCryptConfig in interface EventManagerpublic void setDbCryptConfig(java.lang.String dbCryptConfig)
EventManagersetDbCryptConfig in interface EventManagerdbCryptConfig - Database encryption plugin configuration, meaning plugin specificpublic java.lang.String getAuthPlugins()
EventManagergetAuthPlugins in interface EventManagernull for driver defaultpublic void setAuthPlugins(java.lang.String authPlugins)
EventManagerInvalid names are skipped during authentication.
setAuthPlugins in interface EventManagerauthPlugins - comma-separated list of authentication plugins, or null for driver defaultpublic long getWaitTimeout()
EventManagerDefault value is 1000 (1 second).
getWaitTimeout in interface EventManagerpublic void setWaitTimeout(long waitTimeout)
EventManagerDefault value is 1000 (1 second).
setWaitTimeout in interface EventManagerwaitTimeout - wait timeout in millisecondspublic void addEventListener(java.lang.String eventName,
EventListener listener)
throws java.sql.SQLException
EventManageraddEventListener in interface EventManagereventName - The name of the event for which the listener will be notifiedlistener - The EventListener that will be called when the given event occursjava.sql.SQLException - If a database access error occurspublic void removeEventListener(java.lang.String eventName,
EventListener listener)
throws java.sql.SQLException
EventManagerremoveEventListener in interface EventManagereventName - The name of the event for which the listener will be unregistered.listener - The EventListener that is to be unregisteredjava.sql.SQLException - If a database access error occurspublic int waitForEvent(java.lang.String eventName)
throws java.lang.InterruptedException,
java.sql.SQLException
EventManager
This method blocks indefinitely until the event identified by the value of eventName occurs. The return
value is the number of occurrences of the requested event.
waitForEvent in interface EventManagereventName - The name of the event to wait forjava.lang.InterruptedException - If interrupted while waitingjava.sql.SQLException - If a database access error occurspublic int waitForEvent(java.lang.String eventName,
int timeout)
throws java.lang.InterruptedException,
java.sql.SQLException
EventManager
This method blocks for a maximum of timeout milliseconds, waiting for the event identified by
eventName to occur. A timeout value of 0 means wait indefinitely.
The return value is the number of occurences of the event in question, or -1 if the call timed out.
waitForEvent in interface EventManagereventName - The name of the event to wait fortimeout - The maximum number of milliseconds to wait1 if the call timed outjava.lang.InterruptedException - If interrupted while waitingjava.sql.SQLException - If a database access error occursCopyright © 2001-2023 Jaybird (Firebird JDBC/JCA) team. All rights reserved.