Code cleanup

revert-70aa11f8
prabathabey 10 years ago
parent 8ac5cb47a7
commit 1f587bddf8

@ -34,6 +34,7 @@ import org.wso2.carbon.device.mgt.core.DeviceManagementServiceProviderImpl;
import org.wso2.carbon.device.mgt.core.api.mgt.APIPublisherService; import org.wso2.carbon.device.mgt.core.api.mgt.APIPublisherService;
import org.wso2.carbon.device.mgt.core.api.mgt.APIPublisherServiceImpl; import org.wso2.carbon.device.mgt.core.api.mgt.APIPublisherServiceImpl;
import org.wso2.carbon.device.mgt.core.api.mgt.APIRegistrationStartupObserver; import org.wso2.carbon.device.mgt.core.api.mgt.APIRegistrationStartupObserver;
import org.wso2.carbon.device.mgt.core.app.mgt.AppManagementException;
import org.wso2.carbon.device.mgt.core.app.mgt.AppManagerImplHttp; import org.wso2.carbon.device.mgt.core.app.mgt.AppManagerImplHttp;
import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager; import org.wso2.carbon.device.mgt.core.config.DeviceConfigurationManager;
import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig; import org.wso2.carbon.device.mgt.core.config.DeviceManagementConfig;
@ -117,20 +118,10 @@ public class DeviceManagementServiceComponent {
new DeviceManagementServiceProviderImpl(this.getPluginRepository()); new DeviceManagementServiceProviderImpl(this.getPluginRepository());
DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceManagementProvider); DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceManagementProvider);
LicenseConfigurationManager.getInstance().initConfig(); /* Initializing license manager */
LicenseConfig licenseConfig = this.initLicenseManager();
LicenseConfigurationManager.getInstance().getLicenseConfig(); /* Initializing app manager connector */
this.initAppManagerConnector();
LicenseManager licenseManager = new LicenseManagerImpl();
DeviceManagementDataHolder.getInstance().setLicenseManager(licenseManager);
DeviceManagementDataHolder.getInstance().setLicenseConfig(licenseConfig);
AppManagementConfigurationManager.getInstance().initConfig();
AppManagementConfig appConfig =
AppManagementConfigurationManager.getInstance().getAppManagementConfig();
DeviceManagementDataHolder.getInstance().setAppManagerConfig(appConfig);
AppManagerImplHttp appManager = new AppManagerImplHttp(appConfig);
DeviceManagementDataHolder.getInstance().setAppManager(appManager);
OperationManagementDAOFactory.init(dsConfig); OperationManagementDAOFactory.init(dsConfig);
@ -143,7 +134,7 @@ public class DeviceManagementServiceComponent {
"begin"); "begin");
} }
this.setupDeviceManagementSchema(dsConfig); this.setupDeviceManagementSchema(dsConfig);
this.setupDefaultLicenses(licenseConfig); this.setupDefaultLicenses(DeviceManagementDataHolder.getInstance().getLicenseConfig());
} }
synchronized (LOCK) { synchronized (LOCK) {
@ -164,6 +155,25 @@ public class DeviceManagementServiceComponent {
} }
} }
private void initLicenseManager() throws LicenseManagementException {
LicenseConfigurationManager.getInstance().initConfig();
LicenseConfig licenseConfig =
LicenseConfigurationManager.getInstance().getLicenseConfig();
LicenseManager licenseManager = new LicenseManagerImpl();
DeviceManagementDataHolder.getInstance().setLicenseManager(licenseManager);
DeviceManagementDataHolder.getInstance().setLicenseConfig(licenseConfig);
}
private void initAppManagerConnector() throws AppManagementException {
AppManagementConfigurationManager.getInstance().initConfig();
AppManagementConfig appConfig =
AppManagementConfigurationManager.getInstance().getAppManagementConfig();
DeviceManagementDataHolder.getInstance().setAppManagerConfig(appConfig);
AppManagerImplHttp appManager = new AppManagerImplHttp(appConfig);
DeviceManagementDataHolder.getInstance().setAppManager(appManager);
}
protected void deactivate(ComponentContext componentContext) { protected void deactivate(ComponentContext componentContext) {
//do nothing //do nothing
} }
@ -197,8 +207,7 @@ public class DeviceManagementServiceComponent {
initializer.createRegistryDatabase(); initializer.createRegistryDatabase();
} catch (Exception e) { } catch (Exception e) {
throw new DeviceManagementException( throw new DeviceManagementException(
"Error occurred while initializing Device Management " + "Error occurred while initializing Device Management database schema", e);
"database schema", e);
} }
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Device management metadata repository schema has been successfully initialized"); log.debug("Device management metadata repository schema has been successfully initialized");
@ -330,4 +339,5 @@ public class DeviceManagementServiceComponent {
protected void unsetDataSourceService(DataSourceService dataSourceService) { protected void unsetDataSourceService(DataSourceService dataSourceService) {
//do nothing //do nothing
} }
} }

Loading…
Cancel
Save