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

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

Loading…
Cancel
Save