- 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 TypeMethodDescriptionvoid
addEventListener
(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.An unmodifiable view on the connection properties held by this BaseProperties implementation.static EventManager
createFor
(Connection connection) Creates anEventManager
for a connection.void
Close the connection to the database.Get the list of authentication plugins to try.getBooleanProperty
(String name) Retrieves aboolean
property value by name.Get the database name.Get the database encryption plugin configuration.getIntProperty
(String name) Retrieves anint
property value by name.int
Get 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()
long
Get 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.boolean
void
removeEventListener
(String eventName, EventListener listener) Remove an EventListener for a given event.void
setAuthPlugins
(String authPlugins) Sets the authentication plugins to try.void
setBooleanProperty
(String name, Boolean value) Sets aboolean
property by name.void
setDatabaseName
(String databaseName) Set the database name.void
setDbCryptConfig
(String dbCryptConfig) Sets the database encryption plugin configuration.void
setIntProperty
(String name, Integer value) Sets anint
property by name.void
setPassword
(String password) void
setPortNumber
(int portNumber) Set the port number of the server.void
setProperty
(String name, String value) Sets a property by name.void
setServerName
(String serverName) Set the hostname or IP address of the Firebird server.final void
void
void
setWaitTimeout
(long waitTimeout) Set the poll timeout in milliseconds of the async thread to check whether it was stopped or not.void
setWireCrypt
(String wireCrypt) Set the wire encryption level.void
setWireCryptAsEnum
(WireCrypt wireCrypt) Set the wire encryption level.int
waitForEvent
(String eventName) Wait for the one-time occurrence of an event.int
waitForEvent
(String eventName, int timeout) Wait for the one-time occurrence of an event.protected final LockCloseable
withLock()
Methods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
Methods 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, setWireCompression
Methods inherited from interface org.firebirdsql.jaybird.props.BaseProperties
getBooleanProperty, getIntProperty, getProperty
-
Constructor Details
-
FBEventManager
public FBEventManager() -
FBEventManager
-
-
Method Details
-
createFor
Creates anEventManager
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
.- Parameters:
connection
- A connection that unwraps toFirebirdConnection
- Returns:
- An event manager
- Throws:
SQLException
- Whenconnection
does not unwrap toFirebirdConnection
- Since:
- 3.0.7
-
withLock
-
setType
- Specified by:
setType
in 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:EventManager
Make a connection with a database to listen for events.- Specified by:
connect
in interfaceEventManager
- Throws:
SQLException
- If a database communication error occurs
-
close
Description copied from interface:EventManager
If connected, disconnects, otherwise does nothing.Contrary to
EventManager.disconnect()
, this method does not throwIllegalStateException
when not connected.- Specified by:
close
in interfaceAutoCloseable
- Specified by:
close
in interfaceEventManager
- Throws:
SQLException
- For errors during disconnect
-
disconnect
Description copied from interface:EventManager
Close the connection to the database.- Specified by:
disconnect
in interfaceEventManager
- Throws:
SQLException
- If a database communication error occurs- See Also:
-
isConnected
public boolean isConnected()- Specified by:
isConnected
in interfaceEventManager
- Returns:
true
when connected and able to listen for events- See Also:
-
setUser
- Specified by:
setUser
in interfaceAttachmentProperties
- Parameters:
user
- Name of the user to authenticate to the server.
-
getUser
- Specified by:
getUser
in interfaceAttachmentProperties
- Returns:
- Name of the user to authenticate to the server.
-
setPassword
- Specified by:
setPassword
in interfaceAttachmentProperties
- Parameters:
password
- Password to authenticate to the server.
-
getPassword
- Specified by:
getPassword
in interfaceAttachmentProperties
- Returns:
- Password to authenticate to the server.
-
getServerName
Description copied from interface:AttachmentProperties
Get the hostname or IP address of the Firebird server.- Specified by:
getServerName
in interfaceAttachmentProperties
- Returns:
- Hostname or IP address of the server
- See Also:
-
setServerName
Description copied from interface:AttachmentProperties
Set the hostname or IP address of the Firebird server.When set to
null
(the default), thedatabaseName
orserviceName
is used as the full identification of the database host, port and database path/alias. Protocol implementations, for examplePURE_JAVA
, may default tolocalhost
when this property isnull
, butdatabaseName
/serviceName
does not (seem to) contain a host name.- Specified by:
setServerName
in interfaceAttachmentProperties
- Parameters:
serverName
- Hostname or IP address of the server
-
getPortNumber
public int getPortNumber()Description copied from interface:AttachmentProperties
Get the port number of the server.- Specified by:
getPortNumber
in interfaceAttachmentProperties
- Returns:
- Port number of the server
- See Also:
-
setPortNumber
public void setPortNumber(int portNumber) Description copied from interface:AttachmentProperties
Set the port number of the server.Defaults to
3050
. This property value will be ignored ifserverName
isnull
, unless the protocol implementation needs a hostname, but cannot find a hostname indatabaseName
/serviceName
.- Specified by:
setPortNumber
in interfaceAttachmentProperties
- Parameters:
portNumber
- Port number of the server- See Also:
-
getDatabaseName
Description copied from interface:EventManager
Get the database name.See
DatabaseConnectionProperties.getDatabaseName()
for details.- Specified by:
getDatabaseName
in interfaceEventManager
- Returns:
- database name
-
setDatabaseName
Description copied from interface:EventManager
Set the database name.See
DatabaseConnectionProperties.setDatabaseName(String)
for details.- Specified by:
setDatabaseName
in interfaceEventManager
- Parameters:
databaseName
- database name
-
getWireCryptAsEnum
Description copied from interface:EventManager
Get the wire encryption level.- Specified by:
getWireCryptAsEnum
in interfaceEventManager
- Returns:
- Wire encryption level
-
setWireCryptAsEnum
Description copied from interface:EventManager
Set the wire encryption level.- Specified by:
setWireCryptAsEnum
in interfaceEventManager
- Parameters:
wireCrypt
- Wire encryption level (null
not allowed)
-
getWireCrypt
Description copied from interface:AttachmentProperties
Get the wire encryption level.- Specified by:
getWireCrypt
in interfaceAttachmentProperties
- Returns:
- Wire encryption level
-
setWireCrypt
Description copied from interface:AttachmentProperties
Set the wire encryption level.Values are defined by
WireCrypt
, values are handled case insensitive. Invalid values will throw an exception.- Specified by:
setWireCrypt
in interfaceAttachmentProperties
- Parameters:
wireCrypt
- Wire encryption level (null
not allowed)
-
getDbCryptConfig
Description copied from interface:AttachmentProperties
Get the database encryption plugin configuration.- Specified by:
getDbCryptConfig
in interfaceAttachmentProperties
- Returns:
- Database encryption plugin configuration, meaning plugin specific
-
setDbCryptConfig
Description copied from interface:AttachmentProperties
Sets the database encryption plugin configuration.- Specified by:
setDbCryptConfig
in interfaceAttachmentProperties
- Parameters:
dbCryptConfig
- Database encryption plugin configuration, meaning plugin specific
-
getAuthPlugins
Description copied from interface:AttachmentProperties
Get the list of authentication plugins to try.- Specified by:
getAuthPlugins
in interfaceAttachmentProperties
- Returns:
- comma-separated list of authentication plugins
-
setAuthPlugins
Description copied from interface:AttachmentProperties
Sets the authentication plugins to try.Invalid names are skipped during authentication.
- Specified by:
setAuthPlugins
in interfaceAttachmentProperties
- Parameters:
authPlugins
- comma-separated list of authentication plugins
-
getWaitTimeout
public long getWaitTimeout()Description copied from interface:EventManager
Get 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:
getWaitTimeout
in interfaceEventManager
- Returns:
- wait timeout in milliseconds
-
setWaitTimeout
public void setWaitTimeout(long waitTimeout) Description copied from interface:EventManager
Set 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:
setWaitTimeout
in interfaceEventManager
- Parameters:
waitTimeout
- wait timeout in milliseconds
-
addEventListener
Description copied from interface:EventManager
Register an EventListener that will be called when an event occurs.- Specified by:
addEventListener
in 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:EventManager
Remove an EventListener for a given event.- Specified by:
removeEventListener
in 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:EventManager
Wait for the one-time occurrence of an event.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.- Specified by:
waitForEvent
in 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:EventManager
Wait for the one-time occurrence of an event.This method blocks for a maximum of
timeout
milliseconds, waiting for the event identified byeventName
to occur. A timeout value of0
means wait indefinitely.The return value is the number of occurences of the event in question, or
-1
if the call timed out.- Specified by:
waitForEvent
in 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
1
if the call timed out - Throws:
InterruptedException
- If interrupted while waitingSQLException
- If a database access error occurs
-
getProperty
Description copied from interface:BaseProperties
Retrieves a string property value by name.For properties with an explicit default, this method should return the string presentation of that default, not
null
. Forint
orboolean
the string equivalent is returned.- Specified by:
getProperty
in interfaceBaseProperties
- Parameters:
name
- Property name (notnull
or empty)- Returns:
- Value of the property, or
null
when not set or not a known property
-
setProperty
Description copied from interface:BaseProperties
Sets a property by name.This method can be used to set all defined properties, but also properties not known by Jaybird. When setting
int
orboolean
properties, the appropriate conversions are applied. Usingnull
will reset to the default value. Forboolean
properties, an empty string is taken to meantrue
.- Specified by:
setProperty
in interfaceBaseProperties
- Parameters:
name
- Property name (notnull
or empty)value
- Property value (usenull
to apply default)
-
getIntProperty
Description copied from interface:BaseProperties
Retrieves anint
property 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
int
instead of checking if something is actually anint
property- Specified by:
getIntProperty
in interfaceBaseProperties
- Parameters:
name
- Property name (notnull
or empty)- Returns:
- Integer with value of the property, or
null
when not set
-
setIntProperty
Description copied from interface:BaseProperties
Sets anint
property by name.For implementation simplicity, it is allowed to also set string properties. The value set will be the string equivalent.
- Specified by:
setIntProperty
in interfaceBaseProperties
- Parameters:
name
- Property name (notnull
or empty)value
- Property value (usenull
to apply default)
-
getBooleanProperty
Description copied from interface:BaseProperties
Retrieves aboolean
property 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
boolean
instead of checking if something is actually aboolean
property- Specified by:
getBooleanProperty
in interfaceBaseProperties
- Parameters:
name
- Property name (notnull
or empty)- Returns:
- Integer with value of the property, or
null
when not set
-
setBooleanProperty
Description copied from interface:BaseProperties
Sets aboolean
property by name.For implementation simplicity, it is allowed to also set string properties. The value set will be the string equivalent.
- Specified by:
setBooleanProperty
in interfaceBaseProperties
- Parameters:
name
- Property name (notnull
or empty)value
- Property value (usenull
to apply default)
-
connectionPropertyValues
Description copied from interface:BaseProperties
An 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:
connectionPropertyValues
in interfaceBaseProperties
- Returns:
- An unmodifiable view on the property values held in this properties instance
-