Class FBEventManager
- java.lang.Object
- 
- org.firebirdsql.event.FBEventManager
 
- 
- All Implemented Interfaces:
- java.lang.AutoCloseable,- EventManager,- AttachmentProperties,- BaseProperties
 
 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 Deprecated 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.java.util.Map<ConnectionProperty,java.lang.Object>connectionPropertyValues()An unmodifiable view on the connection properties held by this BaseProperties implementation.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.BooleangetBooleanProperty(java.lang.String name)Retrieves abooleanproperty value by name.java.lang.StringgetDatabase()Deprecated.java.lang.StringgetDatabaseName()Get the database name.java.lang.StringgetDbCryptConfig()Get the database encryption plugin configuration.java.lang.StringgetHost()Deprecated.java.lang.IntegergetIntProperty(java.lang.String name)Retrieves anintproperty value by name.java.lang.StringgetPassword()intgetPort()Deprecated.intgetPortNumber()Get the port number of the server.java.lang.StringgetProperty(java.lang.String name)Retrieves a string property value by name.java.lang.StringgetServerName()Get the hostname or IP address of the Firebird server.java.lang.StringgetUser()longgetWaitTimeout()Get the poll timeout in milliseconds of the async thread to check whether it was stopped or not.java.lang.StringgetWireCrypt()Get the wire encryption level.WireCryptgetWireCryptAsEnum()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.voidsetBooleanProperty(java.lang.String name, java.lang.Boolean value)Sets abooleanproperty by name.voidsetDatabase(java.lang.String database)Deprecated.voidsetDatabaseName(java.lang.String databaseName)Set the database name.voidsetDbCryptConfig(java.lang.String dbCryptConfig)Sets the database encryption plugin configuration.voidsetHost(java.lang.String host)Deprecated.voidsetIntProperty(java.lang.String name, java.lang.Integer value)Sets anintproperty by name.voidsetPassword(java.lang.String password)voidsetPort(int port)Deprecated.voidsetPortNumber(int portNumber)Set the port number of the server.voidsetProperty(java.lang.String name, java.lang.String value)Sets a property by name.voidsetServerName(java.lang.String serverName)Set the hostname or IP address of the Firebird server.voidsetType(java.lang.String type)voidsetUser(java.lang.String user)voidsetWaitTimeout(long waitTimeout)Set the poll timeout in milliseconds of the async thread to check whether it was stopped or not.voidsetWireCrypt(java.lang.String wireCrypt)Set the wire encryption level.voidsetWireCryptAsEnum(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.protected LockCloseablewithLock()- 
Methods inherited from class java.lang.Objectclone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
 - 
Methods inherited from interface org.firebirdsql.jaybird.props.AttachmentPropertiesgetCharSet, getConnectTimeout, getEncoding, getParallelWorkers, getProcessId, getProcessName, getRoleName, getSocketBufferSize, getSoTimeout, getType, isWireCompression, setCharSet, setConnectTimeout, setEncoding, setParallelWorkers, setProcessId, setProcessName, setRoleName, setSocketBufferSize, setSoTimeout, setWireCompression
 - 
Methods inherited from interface org.firebirdsql.jaybird.props.BasePropertiesgetBooleanProperty, getIntProperty, getProperty
 
- 
 
- 
- 
- 
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
 
 - 
withLockprotected final LockCloseable withLock() 
 - 
setTypepublic final void setType(java.lang.String type) - Specified by:
- setTypein interface- AttachmentProperties
- Parameters:
- type- type of the connection, for example, "PURE_JAVA", "NATIVE", "EMBEDDED", depends on the GDS implementations installed in the system.
 
 - 
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) - Specified by:
- setUserin interface- AttachmentProperties
- Parameters:
- user- Name of the user to authenticate to the server.
 
 - 
getUserpublic java.lang.String getUser() - Specified by:
- getUserin interface- AttachmentProperties
- Returns:
- Name of the user to authenticate to the server.
 
 - 
setPasswordpublic void setPassword(java.lang.String password) - Specified by:
- setPasswordin interface- AttachmentProperties
- Parameters:
- password- Password to authenticate to the server.
 
 - 
getPasswordpublic java.lang.String getPassword() - Specified by:
- getPasswordin interface- AttachmentProperties
- Returns:
- Password to authenticate to the server.
 
 - 
getServerNamepublic java.lang.String getServerName() Description copied from interface:AttachmentPropertiesGet the hostname or IP address of the Firebird server.- Specified by:
- getServerNamein interface- AttachmentProperties
- Returns:
- Hostname or IP address of the server
- See Also:
- AttachmentProperties.setServerName(String)
 
 - 
setServerNamepublic void setServerName(java.lang.String serverName) Description copied from interface:AttachmentPropertiesSet the hostname or IP address of the Firebird server.When set to null(the default), thedatabaseNameorserviceNameis used as the full identification of the database host, port and database path/alias. Protocol implementations, for examplePURE_JAVA, may default tolocalhostwhen this property isnull, butdatabaseName/serviceNamedoes not (seem to) contain a host name.- Specified by:
- setServerNamein interface- AttachmentProperties
- Parameters:
- serverName- Hostname or IP address of the server
 
 - 
getPortNumberpublic int getPortNumber() Description copied from interface:AttachmentPropertiesGet the port number of the server.- Specified by:
- getPortNumberin interface- AttachmentProperties
- Returns:
- Port number of the server
- See Also:
- AttachmentProperties.setPortNumber(int)
 
 - 
setPortNumberpublic void setPortNumber(int portNumber) Description copied from interface:AttachmentPropertiesSet the port number of the server.Defaults to 3050. This property value will be ignored ifserverNameisnull, unless the protocol implementation needs a hostname, but cannot find a hostname indatabaseName/serviceName.- Specified by:
- setPortNumberin interface- AttachmentProperties
- Parameters:
- portNumber- Port number of the server
- See Also:
- AttachmentProperties.setServerName(String)
 
 - 
getDatabaseNamepublic java.lang.String getDatabaseName() Description copied from interface:EventManagerGet the database name.See DatabaseConnectionProperties.getDatabaseName()for details.- Specified by:
- getDatabaseNamein interface- EventManager
- Returns:
- database name
 
 - 
setDatabaseNamepublic void setDatabaseName(java.lang.String databaseName) Description copied from interface:EventManagerSet the database name.See DatabaseConnectionProperties.setDatabaseName(String)for details.- Specified by:
- setDatabaseNamein interface- EventManager
- Parameters:
- databaseName- database name
 
 - 
setDatabase@Deprecated public void setDatabase(java.lang.String database) Deprecated.Description copied from interface:EventManagerSets the database path or url for the connection to the database.- Specified by:
- setDatabasein interface- EventManager
- Parameters:
- database- path or url for the connection to the database.
 
 - 
getDatabase@Deprecated public java.lang.String getDatabase() Deprecated.- Specified by:
- getDatabasein interface- EventManager
- Returns:
- the database path or url for the connection to the database.
 
 - 
getHost@Deprecated public java.lang.String getHost() Deprecated.- Specified by:
- getHostin interface- EventManager
- Returns:
- the host for the connection to the database.
 
 - 
setHost@Deprecated public void setHost(java.lang.String host) Deprecated.Description copied from interface:EventManagerSets the host for the connection to the database.See AttachmentProperties.setServerName(String)for details.- Specified by:
- setHostin interface- EventManager
- Parameters:
- host- for the connection to the database.
 
 - 
getPort@Deprecated public int getPort() Deprecated.- Specified by:
- getPortin interface- EventManager
- Returns:
- the port for the connection to the database.
 
 - 
setPort@Deprecated public void setPort(int port) Deprecated.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.
 
 - 
getWireCryptAsEnumpublic WireCrypt getWireCryptAsEnum() Description copied from interface:EventManagerGet the wire encryption level.- Specified by:
- getWireCryptAsEnumin interface- EventManager
- Returns:
- Wire encryption level
 
 - 
setWireCryptAsEnumpublic void setWireCryptAsEnum(WireCrypt wireCrypt) Description copied from interface:EventManagerSet the wire encryption level.- Specified by:
- setWireCryptAsEnumin interface- EventManager
- Parameters:
- wireCrypt- Wire encryption level (- nullnot allowed)
 
 - 
getWireCryptpublic java.lang.String getWireCrypt() Description copied from interface:AttachmentPropertiesGet the wire encryption level.- Specified by:
- getWireCryptin interface- AttachmentProperties
- Returns:
- Wire encryption level
 
 - 
setWireCryptpublic void setWireCrypt(java.lang.String wireCrypt) Description copied from interface:AttachmentPropertiesSet the wire encryption level.Values are defined by WireCrypt, values are handled case insensitive. Invalid values will throw an exception.- Specified by:
- setWireCryptin interface- AttachmentProperties
- Parameters:
- wireCrypt- Wire encryption level (- nullnot allowed)
 
 - 
getDbCryptConfigpublic java.lang.String getDbCryptConfig() Description copied from interface:AttachmentPropertiesGet the database encryption plugin configuration.- Specified by:
- getDbCryptConfigin interface- AttachmentProperties
- Returns:
- Database encryption plugin configuration, meaning plugin specific
 
 - 
setDbCryptConfigpublic void setDbCryptConfig(java.lang.String dbCryptConfig) Description copied from interface:AttachmentPropertiesSets the database encryption plugin configuration.- Specified by:
- setDbCryptConfigin interface- AttachmentProperties
- Parameters:
- dbCryptConfig- Database encryption plugin configuration, meaning plugin specific
 
 - 
getAuthPluginspublic java.lang.String getAuthPlugins() Description copied from interface:AttachmentPropertiesGet the list of authentication plugins to try.- Specified by:
- getAuthPluginsin interface- AttachmentProperties
- Returns:
- comma-separated list of authentication plugins
 
 - 
setAuthPluginspublic void setAuthPlugins(java.lang.String authPlugins) Description copied from interface:AttachmentPropertiesSets the authentication plugins to try.Invalid names are skipped during authentication. - Specified by:
- setAuthPluginsin interface- AttachmentProperties
- Parameters:
- authPlugins- comma-separated list of authentication plugins
 
 - 
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
 
 - 
getPropertypublic java.lang.String getProperty(java.lang.String name) Description copied from interface:BasePropertiesRetrieves a string property value by name.For properties with an explicit default, this method should return the string presentation of that default, not null. Forintorbooleanthe string equivalent is returned.- Specified by:
- getPropertyin interface- BaseProperties
- Parameters:
- name- Property name (not- nullor empty)
- Returns:
- Value of the property, or nullwhen not set or not a known property
 
 - 
setPropertypublic void setProperty(java.lang.String name, java.lang.String value)Description copied from interface:BasePropertiesSets a property by name.This method can be used to set all defined properties, but also properties not known by Jaybird. When setting intorbooleanproperties, the appropriate conversions are applied. Usingnullwill reset to the default value. Forbooleanproperties, an empty string is taken to meantrue.- Specified by:
- setPropertyin interface- BaseProperties
- Parameters:
- name- Property name (not- nullor empty)
- value- Property value (use- nullto apply default)
 
 - 
getIntPropertypublic java.lang.Integer getIntProperty(java.lang.String name) Description copied from interface:BasePropertiesRetrieves anintproperty value by name.For properties with an explicit default, this method should return the integer presentation of that default. For implementation simplicity, it is allowed to convert any string property to intinstead of checking if something is actually anintproperty- Specified by:
- getIntPropertyin interface- BaseProperties
- Parameters:
- name- Property name (not- nullor empty)
- Returns:
- Integer with value of the property, or nullwhen not set
 
 - 
setIntPropertypublic void setIntProperty(java.lang.String name, java.lang.Integer value)Description copied from interface:BasePropertiesSets anintproperty by name.For implementation simplicity, it is allowed to also set string properties. The value set will be the string equivalent. - Specified by:
- setIntPropertyin interface- BaseProperties
- Parameters:
- name- Property name (not- nullor empty)
- value- Property value (use- nullto apply default)
 
 - 
getBooleanPropertypublic java.lang.Boolean getBooleanProperty(java.lang.String name) Description copied from interface:BasePropertiesRetrieves abooleanproperty value by name.For properties with an explicit default, this method should return the boolean presentation of that default. For implementation simplicity, it is allowed to convert any string property to booleaninstead of checking if something is actually anintproperty- Specified by:
- getBooleanPropertyin interface- BaseProperties
- Parameters:
- name- Property name (not- nullor empty)
- Returns:
- Integer with value of the property, or nullwhen not set
 
 - 
setBooleanPropertypublic void setBooleanProperty(java.lang.String name, java.lang.Boolean value)Description copied from interface:BasePropertiesSets abooleanproperty by name.For implementation simplicity, it is allowed to also set string properties. The value set will be the string equivalent. - Specified by:
- setBooleanPropertyin interface- BaseProperties
- Parameters:
- name- Property name (not- nullor empty)
- value- Property value (use- nullto apply default)
 
 - 
connectionPropertyValuespublic java.util.Map<ConnectionProperty,java.lang.Object> connectionPropertyValues() Description copied from interface:BasePropertiesAn unmodifiable view on the connection properties held by this BaseProperties implementation.Be aware, implementations can have additional properties that are not mapped from ConnectionProperty. Such properties will need to be retrieved in an implementation-specific manner.- Specified by:
- connectionPropertyValuesin interface- BaseProperties
- Returns:
- An unmodifiable view on the property values held in this properties instance
 
 
- 
 
-