From c1652b61f8287226e5accfe675e043ad25694aa4 Mon Sep 17 00:00:00 2001 From: Ace Date: Tue, 17 Nov 2020 11:57:58 +0530 Subject: [PATCH] Fixing issues with DS initialization --- .../heartbeat/beacon/HeartBeatBeaconConfig.java | 11 +++++++++++ .../beacon/internal/HeartBeatBeaconComponent.java | 4 ++++ 2 files changed, 15 insertions(+) diff --git a/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/src/main/java/io/entgra/server/bootup/heartbeat/beacon/HeartBeatBeaconConfig.java b/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/src/main/java/io/entgra/server/bootup/heartbeat/beacon/HeartBeatBeaconConfig.java index f8b741fec3..1d3efd95fd 100644 --- a/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/src/main/java/io/entgra/server/bootup/heartbeat/beacon/HeartBeatBeaconConfig.java +++ b/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/src/main/java/io/entgra/server/bootup/heartbeat/beacon/HeartBeatBeaconConfig.java @@ -18,6 +18,7 @@ package io.entgra.server.bootup.heartbeat.beacon; +import io.entgra.server.bootup.heartbeat.beacon.config.datasource.DataSourceConfig; import io.entgra.server.bootup.heartbeat.beacon.exception.InvalidConfigurationStateException; import org.w3c.dom.Document; import org.wso2.carbon.utils.CarbonUtils; @@ -36,6 +37,7 @@ public class HeartBeatBeaconConfig { private int notifierDelay; private int serverTimeOutIntervalInSeconds; private int timeSkew; + private DataSourceConfig dataSourceConfig; private static HeartBeatBeaconConfig config; @@ -89,6 +91,15 @@ public class HeartBeatBeaconConfig { this.serverTimeOutIntervalInSeconds = serverTimeOutIntervalInSeconds; } + @XmlElement(name = "DataSourceConfiguration", required = true) + public DataSourceConfig getDataSourceConfig() { + return dataSourceConfig; + } + + public void setDataSourceConfig(DataSourceConfig dataSourceConfig) { + this.dataSourceConfig = dataSourceConfig; + } + public static void init() throws HeartBeatBeaconConfigurationException { try { File emailSenderConfig = new File(HEART_BEAT_NOTIFIER_CONFIG_PATH); diff --git a/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/src/main/java/io/entgra/server/bootup/heartbeat/beacon/internal/HeartBeatBeaconComponent.java b/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/src/main/java/io/entgra/server/bootup/heartbeat/beacon/internal/HeartBeatBeaconComponent.java index 6d522910b8..524814da8f 100644 --- a/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/src/main/java/io/entgra/server/bootup/heartbeat/beacon/internal/HeartBeatBeaconComponent.java +++ b/components/heartbeat-management/io.entgra.server.bootup.heartbeat.beacon/src/main/java/io/entgra/server/bootup/heartbeat/beacon/internal/HeartBeatBeaconComponent.java @@ -20,6 +20,8 @@ package io.entgra.server.bootup.heartbeat.beacon.internal; import io.entgra.server.bootup.heartbeat.beacon.HeartBeatBeaconConfig; import io.entgra.server.bootup.heartbeat.beacon.HeartBeatBeaconUtils; +import io.entgra.server.bootup.heartbeat.beacon.config.datasource.DataSourceConfig; +import io.entgra.server.bootup.heartbeat.beacon.dao.HeartBeatBeaconDAOFactory; import io.entgra.server.bootup.heartbeat.beacon.service.HeartBeatManagementService; import io.entgra.server.bootup.heartbeat.beacon.service.HeartBeatManagementServiceImpl; import org.apache.commons.logging.Log; @@ -42,6 +44,8 @@ public class HeartBeatBeaconComponent { } //heart beat notifier configuration */ HeartBeatBeaconConfig.init(); + DataSourceConfig dsConfig = HeartBeatBeaconConfig.getInstance().getDataSourceConfig(); + HeartBeatBeaconDAOFactory.init(dsConfig); this.registerHeartBeatServices(componentContext);