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.
|
java.util.Map<ConnectionProperty,java.lang.Object> |
connectionPropertyValues()
An unmodifiable view on the connection properties held by this BaseProperties implementation.
|
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.Boolean |
getBooleanProperty(java.lang.String name)
Retrieves a
boolean property value by name. |
java.lang.String |
getDatabase()
Deprecated.
|
java.lang.String |
getDatabaseName()
Get the database name.
|
java.lang.String |
getDbCryptConfig()
Get the database encryption plugin configuration.
|
java.lang.String |
getHost()
Deprecated.
|
java.lang.Integer |
getIntProperty(java.lang.String name)
Retrieves an
int property value by name. |
java.lang.String |
getPassword() |
int |
getPort()
Deprecated.
|
int |
getPortNumber()
Get the port number of the server.
|
java.lang.String |
getProperty(java.lang.String name)
Retrieves a string property value by name.
|
java.lang.String |
getServerName()
Get the hostname or IP address of the Firebird server.
|
java.lang.String |
getUser() |
long |
getWaitTimeout()
Get the poll timeout in milliseconds of the async thread to check whether it was stopped or not.
|
java.lang.String |
getWireCrypt()
Get the wire encryption level.
|
WireCrypt |
getWireCryptAsEnum()
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 |
setBooleanProperty(java.lang.String name,
java.lang.Boolean value)
Sets a
boolean property by name. |
void |
setDatabase(java.lang.String database)
Deprecated.
|
void |
setDatabaseName(java.lang.String databaseName)
Set the database name.
|
void |
setDbCryptConfig(java.lang.String dbCryptConfig)
Sets the database encryption plugin configuration.
|
void |
setHost(java.lang.String host)
Deprecated.
|
void |
setIntProperty(java.lang.String name,
java.lang.Integer value)
Sets an
int property by name. |
void |
setPassword(java.lang.String password) |
void |
setPort(int port)
Deprecated.
|
void |
setPortNumber(int portNumber)
Set the port number of the server.
|
void |
setProperty(java.lang.String name,
java.lang.String value)
Sets a property by name.
|
void |
setServerName(java.lang.String serverName)
Set the hostname or IP address of the Firebird server.
|
void |
setType(java.lang.String type) |
void |
setUser(java.lang.String user) |
void |
setWaitTimeout(long waitTimeout)
Set the poll timeout in milliseconds of the async thread to check whether it was stopped or not.
|
void |
setWireCrypt(java.lang.String wireCrypt)
Set the wire encryption level.
|
void |
setWireCryptAsEnum(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.
|
protected LockCloseable |
withLock() |
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitgetCharSet, getConnectTimeout, getEncoding, getParallelWorkers, getProcessId, getProcessName, getRoleName, getSocketBufferSize, getSoTimeout, getType, isWireCompression, setCharSet, setConnectTimeout, setEncoding, setParallelWorkers, setProcessId, setProcessName, setRoleName, setSocketBufferSize, setSoTimeout, setWireCompressiongetBooleanProperty, getIntProperty, getPropertypublic 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 FirebirdConnectionprotected final LockCloseable withLock()
public final void setType(java.lang.String type)
setType in interface AttachmentPropertiestype - type of the connection, for example, "PURE_JAVA", "NATIVE", "EMBEDDED", depends on the GDS
implementations installed in the system.public 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)
setUser in interface AttachmentPropertiesuser - Name of the user to authenticate to the server.public java.lang.String getUser()
getUser in interface AttachmentPropertiespublic void setPassword(java.lang.String password)
setPassword in interface AttachmentPropertiespassword - Password to authenticate to the server.public java.lang.String getPassword()
getPassword in interface AttachmentPropertiespublic java.lang.String getServerName()
AttachmentPropertiesgetServerName in interface AttachmentPropertiesAttachmentProperties.setServerName(String)public void setServerName(java.lang.String serverName)
AttachmentProperties
When set to null (the default), the databaseName or serviceName is used as the full
identification of the database host, port and database path/alias. Protocol implementations, for example
PURE_JAVA, may default to localhost when this property is null, but
databaseName/serviceName does not (seem to) contain a host name.
setServerName in interface AttachmentPropertiesserverName - Hostname or IP address of the serverpublic int getPortNumber()
AttachmentPropertiesgetPortNumber in interface AttachmentPropertiesAttachmentProperties.setPortNumber(int)public void setPortNumber(int portNumber)
AttachmentProperties
Defaults to 3050. This property value will be ignored if serverName is null, unless the
protocol implementation needs a hostname, but cannot find a hostname in databaseName/serviceName.
setPortNumber in interface AttachmentPropertiesportNumber - Port number of the serverAttachmentProperties.setServerName(String)public java.lang.String getDatabaseName()
EventManager
See DatabaseConnectionProperties.getDatabaseName() for details.
getDatabaseName in interface EventManagerpublic void setDatabaseName(java.lang.String databaseName)
EventManager
See DatabaseConnectionProperties.setDatabaseName(String) for details.
setDatabaseName in interface EventManagerdatabaseName - database name@Deprecated public void setDatabase(java.lang.String database)
EventManagersetDatabase in interface EventManagerdatabase - path or url for the connection to the database.@Deprecated public java.lang.String getDatabase()
getDatabase in interface EventManager@Deprecated public java.lang.String getHost()
getHost in interface EventManager@Deprecated public void setHost(java.lang.String host)
EventManager
See AttachmentProperties.setServerName(String) for details.
setHost in interface EventManagerhost - for the connection to the database.@Deprecated public int getPort()
getPort in interface EventManager@Deprecated public void setPort(int port)
EventManagersetPort in interface EventManagerport - for the connection to the database.public WireCrypt getWireCryptAsEnum()
EventManagergetWireCryptAsEnum in interface EventManagerpublic void setWireCryptAsEnum(WireCrypt wireCrypt)
EventManagersetWireCryptAsEnum in interface EventManagerwireCrypt - Wire encryption level (null not allowed)public java.lang.String getWireCrypt()
AttachmentPropertiesgetWireCrypt in interface AttachmentPropertiespublic void setWireCrypt(java.lang.String wireCrypt)
AttachmentProperties
Values are defined by WireCrypt, values are handled case insensitive. Invalid values will throw an
exception.
setWireCrypt in interface AttachmentPropertieswireCrypt - Wire encryption level (null not allowed)public java.lang.String getDbCryptConfig()
AttachmentPropertiesgetDbCryptConfig in interface AttachmentPropertiespublic void setDbCryptConfig(java.lang.String dbCryptConfig)
AttachmentPropertiessetDbCryptConfig in interface AttachmentPropertiesdbCryptConfig - Database encryption plugin configuration, meaning plugin specificpublic java.lang.String getAuthPlugins()
AttachmentPropertiesgetAuthPlugins in interface AttachmentPropertiespublic void setAuthPlugins(java.lang.String authPlugins)
AttachmentPropertiesInvalid names are skipped during authentication.
setAuthPlugins in interface AttachmentPropertiesauthPlugins - comma-separated list of authentication pluginspublic 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 occurspublic java.lang.String getProperty(java.lang.String name)
BaseProperties
For properties with an explicit default, this method should return the string presentation of that default, not
null. For int or boolean the string equivalent is returned.
getProperty in interface BasePropertiesname - Property name (not null or empty)null when not set or not a known propertypublic void setProperty(java.lang.String name,
java.lang.String value)
BaseProperties
This method can be used to set all defined properties, but also properties not known by Jaybird. When setting
int or boolean properties, the appropriate conversions are applied. Using null will
reset to the default value. For boolean properties, an empty string is taken to mean true.
setProperty in interface BasePropertiesname - Property name (not null or empty)value - Property value (use null to apply default)public java.lang.Integer getIntProperty(java.lang.String name)
BasePropertiesint 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 an int property
getIntProperty in interface BasePropertiesname - Property name (not null or empty)null when not setpublic void setIntProperty(java.lang.String name,
java.lang.Integer value)
BasePropertiesint property by name.
For implementation simplicity, it is allowed to also set string properties. The value set will be the string equivalent.
setIntProperty in interface BasePropertiesname - Property name (not null or empty)value - Property value (use null to apply default)public java.lang.Boolean getBooleanProperty(java.lang.String name)
BasePropertiesboolean 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 an int property
getBooleanProperty in interface BasePropertiesname - Property name (not null or empty)null when not setpublic void setBooleanProperty(java.lang.String name,
java.lang.Boolean value)
BasePropertiesboolean property by name.
For implementation simplicity, it is allowed to also set string properties. The value set will be the string equivalent.
setBooleanProperty in interface BasePropertiesname - Property name (not null or empty)value - Property value (use null to apply default)public java.util.Map<ConnectionProperty,java.lang.Object> connectionPropertyValues()
BaseProperties
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.
connectionPropertyValues in interface BasePropertiesCopyright © 2001-2023 Jaybird (Firebird JDBC) team. All rights reserved.