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, wait
getCharSet, getConnectTimeout, getEncoding, getProcessId, getProcessName, getRoleName, getSocketBufferSize, getSoTimeout, getType, isWireCompression, setCharSet, setConnectTimeout, setEncoding, setProcessId, setProcessName, setRoleName, setSocketBufferSize, setSoTimeout, setWireCompression
getBooleanProperty, getIntProperty, getProperty
public 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 FirebirdConnection
java.sql.SQLException
- When connection
does not unwrap to FirebirdConnection
protected final LockCloseable withLock()
public final void setType(java.lang.String type)
setType
in interface AttachmentProperties
type
- 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
EventManager
connect
in interface EventManager
java.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.AutoCloseable
close
in interface EventManager
java.sql.SQLException
- For errors during disconnectpublic void disconnect() throws java.sql.SQLException
EventManager
disconnect
in interface EventManager
java.sql.SQLException
- If a database communication error occursEventManager.close()
public boolean isConnected()
isConnected
in interface EventManager
true
when connected and able to listen for eventsEventManager.connect()
,
EventManager.disconnect()
public void setUser(java.lang.String user)
setUser
in interface AttachmentProperties
user
- Name of the user to authenticate to the server.public java.lang.String getUser()
getUser
in interface AttachmentProperties
public void setPassword(java.lang.String password)
setPassword
in interface AttachmentProperties
password
- Password to authenticate to the server.public java.lang.String getPassword()
getPassword
in interface AttachmentProperties
public java.lang.String getServerName()
AttachmentProperties
getServerName
in interface AttachmentProperties
AttachmentProperties.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 AttachmentProperties
serverName
- Hostname or IP address of the serverpublic int getPortNumber()
AttachmentProperties
getPortNumber
in interface AttachmentProperties
AttachmentProperties.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 AttachmentProperties
portNumber
- Port number of the serverAttachmentProperties.setServerName(String)
public java.lang.String getDatabaseName()
EventManager
See DatabaseConnectionProperties.getDatabaseName()
for details.
getDatabaseName
in interface EventManager
public void setDatabaseName(java.lang.String databaseName)
EventManager
See DatabaseConnectionProperties.setDatabaseName(String)
for details.
setDatabaseName
in interface EventManager
databaseName
- database name@Deprecated public void setDatabase(java.lang.String database)
EventManager
setDatabase
in interface EventManager
database
- 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 EventManager
host
- for the connection to the database.@Deprecated public int getPort()
getPort
in interface EventManager
@Deprecated public void setPort(int port)
EventManager
setPort
in interface EventManager
port
- for the connection to the database.public WireCrypt getWireCryptAsEnum()
EventManager
getWireCryptAsEnum
in interface EventManager
public void setWireCryptAsEnum(WireCrypt wireCrypt)
EventManager
setWireCryptAsEnum
in interface EventManager
wireCrypt
- Wire encryption level (null
not allowed)public java.lang.String getWireCrypt()
AttachmentProperties
getWireCrypt
in interface AttachmentProperties
public 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 AttachmentProperties
wireCrypt
- Wire encryption level (null
not allowed)public java.lang.String getDbCryptConfig()
AttachmentProperties
getDbCryptConfig
in interface AttachmentProperties
public void setDbCryptConfig(java.lang.String dbCryptConfig)
AttachmentProperties
setDbCryptConfig
in interface AttachmentProperties
dbCryptConfig
- Database encryption plugin configuration, meaning plugin specificpublic java.lang.String getAuthPlugins()
AttachmentProperties
getAuthPlugins
in interface AttachmentProperties
public void setAuthPlugins(java.lang.String authPlugins)
AttachmentProperties
Invalid names are skipped during authentication.
setAuthPlugins
in interface AttachmentProperties
authPlugins
- comma-separated list of authentication pluginspublic long getWaitTimeout()
EventManager
Default value is 1000 (1 second).
getWaitTimeout
in interface EventManager
public void setWaitTimeout(long waitTimeout)
EventManager
Default value is 1000 (1 second).
setWaitTimeout
in interface EventManager
waitTimeout
- wait timeout in millisecondspublic void addEventListener(java.lang.String eventName, EventListener listener) throws java.sql.SQLException
EventManager
addEventListener
in interface EventManager
eventName
- 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
EventManager
removeEventListener
in interface EventManager
eventName
- 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 EventManager
eventName
- 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 EventManager
eventName
- 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 BaseProperties
name
- 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 BaseProperties
name
- Property name (not null
or empty)value
- Property value (use null
to apply default)public java.lang.Integer getIntProperty(java.lang.String name)
BaseProperties
int
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 BaseProperties
name
- Property name (not null
or empty)null
when not setpublic void setIntProperty(java.lang.String name, java.lang.Integer value)
BaseProperties
int
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 BaseProperties
name
- Property name (not null
or empty)value
- Property value (use null
to apply default)public java.lang.Boolean getBooleanProperty(java.lang.String name)
BaseProperties
boolean
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 BaseProperties
name
- Property name (not null
or empty)null
when not setpublic void setBooleanProperty(java.lang.String name, java.lang.Boolean value)
BaseProperties
boolean
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 BaseProperties
name
- 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 BaseProperties
Copyright © 2001-2023 Jaybird (Firebird JDBC) team. All rights reserved.