Package de.xima.fc.db
Class DatabaseMonitor
- java.lang.Object
-
- de.xima.fc.db.DatabaseMonitor
-
@Named @Eager @ApplicationScoped public class DatabaseMonitor extends Object
Monitors the database connection status.
-
-
Field Summary
Fields Modifier and Type Field Description static StringDB_HEALTHCHECK_NAMEDeprecated.
-
Constructor Summary
Constructors Constructor Description DatabaseMonitor()DatabaseMonitor(IServerRegistries serverRegistries)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description booleancheck()Checks whether the database connection is healthy, i.e.protected IServerRegistriesgetServerRegistries()static booleanisConnected()Checks whether the last known status of the database connection is connected.static voidregisterConnectionEstablishedListener(IBaseNotificationListener listener)static voidregisterDisconnectedListener(IBaseNotificationListener listener)static voidregisterReconnectedListener(IBaseNotificationListener listener)static booleantestConnection()Checks whether the database connection is healthy, i.e.
-
-
-
Field Detail
-
DB_HEALTHCHECK_NAME
@Deprecated public static final String DB_HEALTHCHECK_NAME
Deprecated.- See Also:
- Constant Field Values
-
-
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:
trueif the database connection is healthy,falseotherwise.
-
getServerRegistries
protected IServerRegistries getServerRegistries()
-
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. UsetestConnection()to run a check now.- Returns:
trueif the database connection is connected,falseotherwise.
-
testConnection
public static boolean testConnection()
Checks whether the database connection is healthy, i.e. whether the database is reachable. In contrast withisConnected(), this method actually performs a check and tries to reach the database, instead of returning the current status.- Returns:
trueif the database connection is healthy,falseotherwise.
-
registerConnectionEstablishedListener
public static void registerConnectionEstablishedListener(IBaseNotificationListener listener)
-
registerDisconnectedListener
public static void registerDisconnectedListener(IBaseNotificationListener listener)
-
registerReconnectedListener
public static void registerReconnectedListener(IBaseNotificationListener listener)
-
-