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 String
DB_HEALTHCHECK_NAME
Deprecated.
-
Constructor Summary
Constructors Constructor Description DatabaseMonitor()
DatabaseMonitor(IServerRegistries serverRegistries)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description boolean
check()
Checks whether the database connection is healthy, i.e.protected IServerRegistries
getServerRegistries()
static boolean
isConnected()
Checks whether the last known status of the database connection is connected.static void
registerConnectionEstablishedListener(IBaseNotificationListener listener)
static void
registerDisconnectedListener(IBaseNotificationListener listener)
static void
registerReconnectedListener(IBaseNotificationListener listener)
static boolean
testConnection()
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:
true
if the database connection is healthy,false
otherwise.
-
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:
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 withisConnected()
, 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)
-
registerDisconnectedListener
public static void registerDisconnectedListener(IBaseNotificationListener listener)
-
registerReconnectedListener
public static void registerReconnectedListener(IBaseNotificationListener listener)
-
-