From ef1b304b142e1c6f01f0851e34553831e10c6705 Mon Sep 17 00:00:00 2001 From: manoj Date: Thu, 26 Mar 2015 20:34:40 +0530 Subject: [PATCH] Create databases in plugin level --- .../dao/MobileDeviceManagementDAOFactory.java | 2 ++ .../MobileDeviceManagementServiceComponent.java | 15 ++++++--------- 2 files changed, 8 insertions(+), 9 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java index 0dc2d7fbd..c1eebf913 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/dao/MobileDeviceManagementDAOFactory.java @@ -28,6 +28,7 @@ import org.wso2.carbon.device.mgt.mobile.dao.impl.*; import org.wso2.carbon.device.mgt.mobile.dao.util.MobileDeviceManagementDAOUtil; import javax.sql.DataSource; +import java.util.HashMap; import java.util.Hashtable; import java.util.List; import java.util.Map; @@ -51,6 +52,7 @@ public class MobileDeviceManagementDAOFactory { public static void init() throws DeviceManagementException { + dataSourceMap = new HashMap(); DataSource dataSource; for (String pluginType : mobileDataSourceConfigMap.keySet()) { dataSource = MobileDeviceManagementDAOFactory.resolveDataSource(mobileDataSourceConfigMap.get diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java index 4798236c3..96d1bb95f 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/internal/MobileDeviceManagementServiceComponent.java @@ -25,7 +25,6 @@ import org.osgi.framework.ServiceRegistration; import org.osgi.service.component.ComponentContext; import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.spi.DeviceManager; -import org.wso2.carbon.device.mgt.mobile.DataSourceListener; import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceConfigurationManager; import org.wso2.carbon.device.mgt.mobile.config.MobileDeviceManagementConfig; import org.wso2.carbon.device.mgt.mobile.config.datasource.MobileDataSourceConfig; @@ -56,9 +55,9 @@ import java.util.Map; public class MobileDeviceManagementServiceComponent { private ServiceRegistration serverStartupObserverRef; - private ServiceRegistration androidServiceRegRef; - private ServiceRegistration iOSServiceRegRef; - private ServiceRegistration windowsServiceRegRef; + private ServiceRegistration androidServiceRegRef; + private ServiceRegistration iOSServiceRegRef; + private ServiceRegistration windowsServiceRegRef; private static final Log log = LogFactory.getLog(MobileDeviceManagementServiceComponent.class); @@ -136,11 +135,9 @@ public class MobileDeviceManagementServiceComponent { protected void setDataSourceService(DataSourceService dataSourceService) { /* This is to avoid mobile device management component getting initialized before the underlying datasources are registered */ - try { - MobileDeviceManagementDAOFactory.init(); - } catch (DeviceManagementException e) { - log.error("Error occurred while initializing mobile device management repository datasource", e); - } + if (log.isDebugEnabled()){ + log.debug("Data source service set to mobile service component"); + } } protected void unsetDataSourceService(DataSourceService dataSourceService) {