Package de.xima.fc.db

Class DatabaseMonitor


  • @Named
    @Eager
    @ApplicationScoped
    public class DatabaseMonitor
    extends Object
    Monitors the database connection status.
    • Constructor Detail

      • DatabaseMonitor

        public DatabaseMonitor()
      • DatabaseMonitor

        @Inject
        public DatabaseMonitor​(IServerRegistries serverRegistries)
    • Method Detail

      • check

        public boolean check()
        Checks whether the database connection is healthy, i.e. whether the database is reachable.
        Returns:
        true if the database connection is healthy, false otherwise.
      • isConnected

        public static boolean isConnected()
        Checks whether the last known status of the database connection is connected. A check is run in a fixed interval. Use testConnection() to run a check now.
        Returns:
        true if the database connection is connected, false otherwise.
      • testConnection

        public static boolean testConnection()
        Checks whether the database connection is healthy, i.e. whether the database is reachable. In contrast with isConnected(), this method actually performs a check and tries to reach the database, instead of returning the current status.
        Returns:
        true if the database connection is healthy, false otherwise.
      • registerConnectionEstablishedListener

        public static void registerConnectionEstablishedListener​(IBaseNotificationListener listener)