Interface EventManager

All Superinterfaces:
AutoCloseable
All Known Implementing Classes:
FBEventManager

public interface EventManager extends AutoCloseable
An interface for registering EventListener instances to listen for database events.
Author:
Gabriel Reid, Mark Rotteveel
  • Method Details

    • connect

      void connect() throws SQLException
      Make a connection with a database to listen for events.
      Throws:
      SQLException - If a database communication error occurs
      IllegalStateException - If already connected
    • close

      void close() throws SQLException
      If connected, disconnects, otherwise does nothing.

      Contrary to disconnect(), this method does not throw IllegalStateException when not connected.

      Specified by:
      close in interface AutoCloseable
      Throws:
      SQLException - For errors during disconnect
      Since:
      3.0.7
    • disconnect

      void disconnect() throws SQLException
      Close the connection to the database.
      Throws:
      SQLException - If a database communication error occurs
      IllegalStateException - If not currently connected
      See Also:
    • isConnected

      boolean isConnected()
      Returns:
      true when connected and able to listen for events
      See Also:
    • setUser

      void setUser(String user)
      Sets the username for the connection to the database .
      Parameters:
      user - for the connection to the database.
    • getUser

      String getUser()
      Returns:
      the username for the connection to the database.
    • setPassword

      void setPassword(String password)
      Sets the password for the connection to the database.
      Parameters:
      password - for the connection to the database.
    • getPassword

      String getPassword()
      Returns:
      the password for the connection to the database.
    • setDatabase

      void setDatabase(String database)
      Sets the database path for the connection to the database.
      Parameters:
      database - path for the connection to the database.
    • getDatabase

      String getDatabase()
      Returns:
      the database path for the connection to the database.
    • getHost

      String getHost()
      Returns:
      the host for the connection to the database.
    • setHost

      void setHost(String host)
      Sets the host for the connection to the database.
      Parameters:
      host - for the connection to the database.
    • getPort

      int getPort()
      Returns:
      the port for the connection to the database.
    • setPort

      void setPort(int port)
      Sets the port for the connection to the database.
      Parameters:
      port - for the connection to the database.
    • getWireCrypt

      WireCrypt getWireCrypt()
      Get the wire encryption level.
      Returns:
      Wire encryption level
      Since:
      3.0.4
    • setWireCrypt

      void setWireCrypt(WireCrypt wireCrypt)
      Set the wire encryption level.
      Parameters:
      wireCrypt - Wire encryption level (null not allowed)
      Since:
      3.0.4
    • getDbCryptConfig

      String getDbCryptConfig()
      Get the database encryption plugin configuration.
      Returns:
      Database encryption plugin configuration, meaning plugin specific
      Since:
      3.0.4
    • setDbCryptConfig

      void setDbCryptConfig(String dbCryptConfig)
      Sets the database encryption plugin configuration.
      Parameters:
      dbCryptConfig - Database encryption plugin configuration, meaning plugin specific
      Since:
      3.0.4
    • getAuthPlugins

      String getAuthPlugins()
      Get the list of authentication plugins to try.
      Returns:
      comma-separated list of authentication plugins, or null for driver default
      Since:
      4.0
    • setAuthPlugins

      void setAuthPlugins(String authPlugins)
      Sets the authentication plugins to try.

      Invalid names are skipped during authentication.

      Parameters:
      authPlugins - comma-separated list of authentication plugins, or null for driver default
      Since:
      4.0
    • getWaitTimeout

      long getWaitTimeout()
      Get the poll timeout in milliseconds of the async thread to check whether it was stopped or not.

      Default value is 1000 (1 second).

      Returns:
      wait timeout in milliseconds
    • setWaitTimeout

      void setWaitTimeout(long waitTimeout)
      Set the poll timeout in milliseconds of the async thread to check whether it was stopped or not.

      Default value is 1000 (1 second).

      Parameters:
      waitTimeout - wait timeout in milliseconds
    • addEventListener

      void addEventListener(String eventName, EventListener listener) throws SQLException
      Register an EventListener that will be called when an event occurs.
      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:
      SQLException - If a database access error occurs
    • removeEventListener

      void removeEventListener(String eventName, EventListener listener) throws SQLException
      Remove an EventListener for a given event.
      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

      int waitForEvent(String eventName) throws InterruptedException, SQLException
      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.

      Parameters:
      eventName - The name of the event to wait for
      Returns:
      The number of occurences of the requested event
      Throws:
      InterruptedException - If interrupted while waiting
      SQLException - If a database access error occurs
    • waitForEvent

      int waitForEvent(String eventName, int timeout) throws InterruptedException, SQLException
      Wait for the one-time occurrence of an event.

      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.

      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 1 if the call timed out
      Throws:
      InterruptedException - If interrupted while waiting
      SQLException - If a database access error occurs