revert-70aa11f8
manoj 10 years ago
commit 105bc2c6cf

@ -53,6 +53,9 @@ import org.wso2.carbon.device.mgt.core.util.DeviceManagementSchemaInitializer;
import org.wso2.carbon.registry.core.service.RegistryService; import org.wso2.carbon.registry.core.service.RegistryService;
import org.wso2.carbon.user.core.service.RealmService; import org.wso2.carbon.user.core.service.RealmService;
import java.util.ArrayList;
import java.util.List;
/** /**
* @scr.component name="org.wso2.carbon.device.manager" immediate="true" * @scr.component name="org.wso2.carbon.device.manager" immediate="true"
* @scr.reference name="user.realmservice.default" * @scr.reference name="user.realmservice.default"
@ -85,6 +88,10 @@ public class DeviceManagementServiceComponent {
private static Log log = LogFactory.getLog(DeviceManagementServiceComponent.class); private static Log log = LogFactory.getLog(DeviceManagementServiceComponent.class);
private DeviceManagementRepository pluginRepository = new DeviceManagementRepository(); private DeviceManagementRepository pluginRepository = new DeviceManagementRepository();
private static final Object LOCK = new Object();
private boolean isInitialized;
private List<DeviceManager> deviceManagers = new ArrayList<DeviceManager>();
protected void activate(ComponentContext componentContext) { protected void activate(ComponentContext componentContext) {
try { try {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
@ -132,6 +139,13 @@ public class DeviceManagementServiceComponent {
this.setupDefaultLicenses(licenseConfig); this.setupDefaultLicenses(licenseConfig);
} }
synchronized (LOCK) {
for (DeviceManager deviceManager : deviceManagers) {
this.registerDeviceManagementProvider(deviceManager);
}
this.isInitialized = true;
}
/* Registering declarative service instances exposed by DeviceManagementServiceComponent */ /* Registering declarative service instances exposed by DeviceManagementServiceComponent */
this.registerServices(componentContext); this.registerServices(componentContext);
@ -139,8 +153,7 @@ public class DeviceManagementServiceComponent {
log.debug("Device management core bundle has been successfully initialized"); log.debug("Device management core bundle has been successfully initialized");
} }
} catch (Throwable e) { } catch (Throwable e) {
String msg = "Error occurred while initializing device management core bundle"; log.error("Error occurred while initializing device management core bundle", e);
log.error(msg, e);
} }
} }
@ -163,10 +176,8 @@ public class DeviceManagementServiceComponent {
bundleContext.registerService(ServerStartupObserver.class, new APIRegistrationStartupObserver(), null); bundleContext.registerService(ServerStartupObserver.class, new APIRegistrationStartupObserver(), null);
/* Registering App Management service */ /* Registering App Management service */
bundleContext.registerService(AppManager.class.getName(), bundleContext.registerService(AppManager.class.getName(), new AppManagementServiceImpl(), null);
new AppManagementServiceImpl(), null);
} }
private void setupDeviceManagementSchema(DataSourceConfig config) private void setupDeviceManagementSchema(DataSourceConfig config)
@ -193,25 +204,34 @@ public class DeviceManagementServiceComponent {
for (License license : licenseConfig.getLicenses()) { for (License license : licenseConfig.getLicenses()) {
License extLicense = licenseManager.getLicense(license.getName(), license.getLanguage()); License extLicense = licenseManager.getLicense(license.getName(), license.getLanguage());
if (extLicense == null) { if (extLicense == null) {
licenseManager.addLicense(license.getName(), license);; licenseManager.addLicense(license.getName(), license);
} }
} }
} }
private void registerDeviceManagementProvider(DeviceManager deviceManager) {
try {
this.getPluginRepository().addDeviceManagementProvider(deviceManager);
} catch (DeviceManagementException e) {
log.error("Error occurred while adding device management provider '" +
deviceManager.getProviderType() + "'");
}
}
/** /**
* Sets Device Manager service. * Sets Device Manager service.
* *
* @param deviceManager An instance of DeviceManager * @param deviceManager An instance of DeviceManager
*/ */
protected void setDeviceManager(DeviceManager deviceManager) { protected void setDeviceManager(DeviceManager deviceManager) {
if (log.isDebugEnabled()) { if (log.isDebugEnabled()) {
log.debug("Setting Device Management Service Provider: '" + deviceManager.getProviderType() + "'"); log.debug("Setting Device Management Service Provider: '" + deviceManager.getProviderType() + "'");
} }
try { synchronized (LOCK) {
this.getPluginRepository().addDeviceManagementProvider(deviceManager); if (isInitialized) {
} catch (DeviceManagementException e) { this.registerDeviceManagementProvider(deviceManager);
log.error("Error occurred while adding device management provider '" + }
deviceManager.getProviderType() + "'"); deviceManagers.add(deviceManager);
} }
} }

@ -21,7 +21,7 @@
<parent> <parent>
<groupId>org.wso2.carbon.devicemgt</groupId> <groupId>org.wso2.carbon.devicemgt</groupId>
<artifactId>device-mgt-feature</artifactId> <artifactId>webapp-authenticator-framework-feature</artifactId>
<version>0.9.2-SNAPSHOT</version> <version>0.9.2-SNAPSHOT</version>
<relativePath>../pom.xml</relativePath> <relativePath>../pom.xml</relativePath>
</parent> </parent>

Loading…
Cancel
Save