Package org.firebirdsql.event
Interface EventManager
-
- All Superinterfaces:
java.lang.AutoCloseable
- All Known Implementing Classes:
FBEventManager
public interface EventManager extends java.lang.AutoCloseableAn interface for registeringEventListenerinstances to listen for database events.- Author:
- Gabriel Reid, Mark Rotteveel
-
-
Method Summary
All Methods Instance Methods Abstract 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.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.
-
-
-
Method Detail
-
connect
void connect() throws java.sql.SQLExceptionMake a connection with a database to listen for events.- Throws:
java.sql.SQLException- If a database communication error occursjava.lang.IllegalStateException- If already connected
-
close
void close() throws java.sql.SQLExceptionIf connected, disconnects, otherwise does nothing.Contrary to
disconnect(), this method does not throwIllegalStateExceptionwhen not connected.- Specified by:
closein interfacejava.lang.AutoCloseable- Throws:
java.sql.SQLException- For errors during disconnect- Since:
- 3.0.7
-
disconnect
void disconnect() throws java.sql.SQLExceptionClose the connection to the database.- Throws:
java.sql.SQLException- If a database communication error occursjava.lang.IllegalStateException- If not currently connected- See Also:
close()
-
isConnected
boolean isConnected()
- Returns:
truewhen connected and able to listen for events- See Also:
connect(),disconnect()
-
setUser
void setUser(java.lang.String user)
Sets the username for the connection to the database .- Parameters:
user- for the connection to the database.
-
getUser
java.lang.String getUser()
- Returns:
- the username for the connection to the database.
-
setPassword
void setPassword(java.lang.String password)
Sets the password for the connection to the database.- Parameters:
password- for the connection to the database.
-
getPassword
java.lang.String getPassword()
- Returns:
- the password for the connection to the database.
-
setDatabase
void setDatabase(java.lang.String database)
Sets the database path for the connection to the database.- Parameters:
database- path for the connection to the database.
-
getDatabase
java.lang.String getDatabase()
- Returns:
- the database path for the connection to the database.
-
getHost
java.lang.String getHost()
- Returns:
- the host for the connection to the database.
-
setHost
void setHost(java.lang.String host)
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
void setWireCrypt(WireCrypt wireCrypt)
Set the wire encryption level.- Parameters:
wireCrypt- Wire encryption level (nullnot allowed)- Since:
- 3.0.4
-
getDbCryptConfig
java.lang.String getDbCryptConfig()
Get the database encryption plugin configuration.- Returns:
- Database encryption plugin configuration, meaning plugin specific
- Since:
- 3.0.4
-
setDbCryptConfig
void setDbCryptConfig(java.lang.String dbCryptConfig)
Sets the database encryption plugin configuration.- Parameters:
dbCryptConfig- Database encryption plugin configuration, meaning plugin specific- Since:
- 3.0.4
-
getAuthPlugins
java.lang.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
void setAuthPlugins(java.lang.String authPlugins)
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
void addEventListener(java.lang.String eventName, EventListener listener) throws java.sql.SQLExceptionRegister 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:
java.sql.SQLException- If a database access error occurs
-
removeEventListener
void removeEventListener(java.lang.String eventName, EventListener listener) throws java.sql.SQLExceptionRemove 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:
java.sql.SQLException- If a database access error occurs
-
waitForEvent
int waitForEvent(java.lang.String eventName) throws java.lang.InterruptedException, java.sql.SQLExceptionWait 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:
java.lang.InterruptedException- If interrupted while waitingjava.sql.SQLException- If a database access error occurs
-
waitForEvent
int waitForEvent(java.lang.String eventName, int timeout) throws java.lang.InterruptedException, java.sql.SQLExceptionWait 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:
java.lang.InterruptedException- If interrupted while waitingjava.sql.SQLException- If a database access error occurs
-
-