- All Implemented Interfaces:
AutoCloseable,EventManager,AttachmentProperties,BaseProperties
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.An unmodifiable view on the connection properties held by this BaseProperties implementation.static EventManagercreateFor(Connection connection) Creates anEventManagerfor a connection.voidClose the connection to the database.Get the list of authentication plugins to try.getBooleanProperty(String name) Retrieves abooleanproperty value by name.Get the database name.Get the database encryption plugin configuration.getIntProperty(String name) Retrieves anintproperty value by name.intGet the port number of the server.getProperty(String name) Retrieves a string property value by name.Get the hostname or IP address of the Firebird server.getUser()longGet the poll timeout in milliseconds of the async thread to check whether it was stopped or not.Get the wire encryption level.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.voidsetBooleanProperty(String name, Boolean value) Sets abooleanproperty by name.voidsetDatabaseName(String databaseName) Set the database name.voidsetDbCryptConfig(String dbCryptConfig) Sets the database encryption plugin configuration.voidsetIntProperty(String name, Integer value) Sets anintproperty by name.voidsetPassword(String password) voidsetPortNumber(int portNumber) Set the port number of the server.voidsetProperty(String name, String value) Sets a property by name.voidsetServerName(String serverName) Set the hostname or IP address of the Firebird server.final voidvoidvoidsetWaitTimeout(long waitTimeout) Set the poll timeout in milliseconds of the async thread to check whether it was stopped or not.voidsetWireCrypt(String wireCrypt) Set the wire encryption level.voidsetWireCryptAsEnum(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.protected final LockCloseablewithLock()Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.firebirdsql.jaybird.props.AttachmentProperties
getCharSet, getConnectTimeout, getEnableProtocol, getEncoding, getParallelWorkers, getProcessId, getProcessName, getRoleName, getSocketBufferSize, getSocketFactory, getSoTimeout, getType, isWireCompression, setCharSet, setConnectTimeout, setEnableProtocol, setEncoding, setParallelWorkers, setProcessId, setProcessName, setRoleName, setSocketBufferSize, setSocketFactory, setSoTimeout, setWireCompressionMethods inherited from interface org.firebirdsql.jaybird.props.BaseProperties
getBooleanProperty, getIntProperty, getProperty
-
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
-
withLock
-
setType
- Specified by:
setTypein interfaceAttachmentProperties- Parameters:
type- type of the connection, for example, "PURE_JAVA", "NATIVE", "EMBEDDED", depends on the GDS implementations installed in the system.
-
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
- Specified by:
setUserin interfaceAttachmentProperties- Parameters:
user- Name of the user to authenticate to the server.
-
getUser
- Specified by:
getUserin interfaceAttachmentProperties- Returns:
- Name of the user to authenticate to the server.
-
setPassword
- Specified by:
setPasswordin interfaceAttachmentProperties- Parameters:
password- Password to authenticate to the server.
-
getPassword
- Specified by:
getPasswordin interfaceAttachmentProperties- Returns:
- Password to authenticate to the server.
-
getServerName
Description copied from interface:AttachmentPropertiesGet the hostname or IP address of the Firebird server.- Specified by:
getServerNamein interfaceAttachmentProperties- Returns:
- Hostname or IP address of the server
- See Also:
-
setServerName
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 interfaceAttachmentProperties- Parameters:
serverName- Hostname or IP address of the server
-
getPortNumber
public int getPortNumber()Description copied from interface:AttachmentPropertiesGet the port number of the server.- Specified by:
getPortNumberin interfaceAttachmentProperties- Returns:
- Port number of the server
- See Also:
-
setPortNumber
public 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 interfaceAttachmentProperties- Parameters:
portNumber- Port number of the server- See Also:
-
getDatabaseName
Description copied from interface:EventManagerGet the database name.See
DatabaseConnectionProperties.getDatabaseName()for details.- Specified by:
getDatabaseNamein interfaceEventManager- Returns:
- database name
-
setDatabaseName
Description copied from interface:EventManagerSet the database name.See
DatabaseConnectionProperties.setDatabaseName(String)for details.- Specified by:
setDatabaseNamein interfaceEventManager- Parameters:
databaseName- database name
-
getWireCryptAsEnum
Description copied from interface:EventManagerGet the wire encryption level.- Specified by:
getWireCryptAsEnumin interfaceEventManager- Returns:
- Wire encryption level
-
setWireCryptAsEnum
Description copied from interface:EventManagerSet the wire encryption level.- Specified by:
setWireCryptAsEnumin interfaceEventManager- Parameters:
wireCrypt- Wire encryption level (nullnot allowed)
-
getWireCrypt
Description copied from interface:AttachmentPropertiesGet the wire encryption level.- Specified by:
getWireCryptin interfaceAttachmentProperties- Returns:
- Wire encryption level
-
setWireCrypt
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 interfaceAttachmentProperties- Parameters:
wireCrypt- Wire encryption level (nullnot allowed)
-
getDbCryptConfig
Description copied from interface:AttachmentPropertiesGet the database encryption plugin configuration.- Specified by:
getDbCryptConfigin interfaceAttachmentProperties- Returns:
- Database encryption plugin configuration, meaning plugin specific
-
setDbCryptConfig
Description copied from interface:AttachmentPropertiesSets the database encryption plugin configuration.- Specified by:
setDbCryptConfigin interfaceAttachmentProperties- Parameters:
dbCryptConfig- Database encryption plugin configuration, meaning plugin specific
-
getAuthPlugins
Description copied from interface:AttachmentPropertiesGet the list of authentication plugins to try.- Specified by:
getAuthPluginsin interfaceAttachmentProperties- Returns:
- comma-separated list of authentication plugins
-
setAuthPlugins
Description copied from interface:AttachmentPropertiesSets the authentication plugins to try.Invalid names are skipped during authentication.
- Specified by:
setAuthPluginsin interfaceAttachmentProperties- Parameters:
authPlugins- comma-separated list of authentication plugins
-
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
-
getProperty
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 interfaceBaseProperties- Parameters:
name- Property name (notnullor empty)- Returns:
- Value of the property, or
nullwhen not set or not a known property
-
setProperty
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 interfaceBaseProperties- Parameters:
name- Property name (notnullor empty)value- Property value (usenullto apply default)
-
getIntProperty
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 interfaceBaseProperties- Parameters:
name- Property name (notnullor empty)- Returns:
- Integer with value of the property, or
nullwhen not set
-
setIntProperty
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 interfaceBaseProperties- Parameters:
name- Property name (notnullor empty)value- Property value (usenullto apply default)
-
getBooleanProperty
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 abooleanproperty- Specified by:
getBooleanPropertyin interfaceBaseProperties- Parameters:
name- Property name (notnullor empty)- Returns:
- Integer with value of the property, or
nullwhen not set
-
setBooleanProperty
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 interfaceBaseProperties- Parameters:
name- Property name (notnullor empty)value- Property value (usenullto apply default)
-
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 interfaceBaseProperties- Returns:
- An unmodifiable view on the property values held in this properties instance
-