Add all registerd devices to newly registerd plugin listner

revert-70aa11f8
manoj 10 years ago
parent 7497a1d033
commit aa8de8cb23

@ -24,6 +24,7 @@ import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService; import org.wso2.carbon.apimgt.impl.APIManagerConfigurationService;
import org.wso2.carbon.core.ServerStartupObserver; import org.wso2.carbon.core.ServerStartupObserver;
import org.wso2.carbon.device.mgt.common.DeviceManagementException; import org.wso2.carbon.device.mgt.common.DeviceManagementException;
import org.wso2.carbon.device.mgt.common.DeviceManager;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManagementException;
import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager; import org.wso2.carbon.device.mgt.common.app.mgt.ApplicationManager;
import org.wso2.carbon.device.mgt.common.license.mgt.License; import org.wso2.carbon.device.mgt.common.license.mgt.License;
@ -101,6 +102,7 @@ public class DeviceManagementServiceComponent {
private static final Object LOCK = new Object(); private static final Object LOCK = new Object();
private static List<PluginInitializationListener> listeners = new ArrayList<PluginInitializationListener>(); private static List<PluginInitializationListener> listeners = new ArrayList<PluginInitializationListener>();
private static List<DeviceManagementService> deviceManagers = new ArrayList<DeviceManagementService>();
protected void activate(ComponentContext componentContext) { protected void activate(ComponentContext componentContext) {
try { try {
@ -152,6 +154,9 @@ public class DeviceManagementServiceComponent {
public static void registerPluginInitializationListener(PluginInitializationListener listener) { public static void registerPluginInitializationListener(PluginInitializationListener listener) {
listeners.add(listener); listeners.add(listener);
for(DeviceManagementService deviceManagementService:deviceManagers){
listener.registerDeviceManagementService(deviceManagementService);
}
} }
private void initLicenseManager() throws LicenseManagementException { private void initLicenseManager() throws LicenseManagementException {
@ -184,11 +189,9 @@ public class DeviceManagementServiceComponent {
} }
/* Registering Device Management Service */ /* Registering Device Management Service */
BundleContext bundleContext = componentContext.getBundleContext(); BundleContext bundleContext = componentContext.getBundleContext();
DeviceManagementProviderService deviceManagementProvider = DeviceManagementProviderService deviceManagementProvider = new DeviceManagementProviderServiceImpl();
new DeviceManagementProviderServiceImpl(this.getPluginRepository());
DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceManagementProvider); DeviceManagementDataHolder.getInstance().setDeviceManagementProvider(deviceManagementProvider);
bundleContext.registerService(DeviceManagementProviderService.class.getName(), bundleContext.registerService(DeviceManagementProviderService.class.getName(), deviceManagementProvider, null);
deviceManagementProvider, null);
APIPublisherService publisher = new APIPublisherServiceImpl(); APIPublisherService publisher = new APIPublisherServiceImpl();
DeviceManagementDataHolder.getInstance().setApiPublisherService(publisher); DeviceManagementDataHolder.getInstance().setApiPublisherService(publisher);
@ -200,12 +203,9 @@ public class DeviceManagementServiceComponent {
bundleContext.registerService(ApplicationManager.class.getName(), new ApplicationManagementServiceImpl(), null); bundleContext.registerService(ApplicationManager.class.getName(), new ApplicationManagementServiceImpl(), null);
} }
private void setupDeviceManagementSchema(DataSourceConfig config) private void setupDeviceManagementSchema(DataSourceConfig config) throws DeviceManagementException {
throws DeviceManagementException { DeviceManagementSchemaInitializer initializer = new DeviceManagementSchemaInitializer(config);
DeviceManagementSchemaInitializer initializer =
new DeviceManagementSchemaInitializer(config);
log.info("Initializing device management repository database schema"); log.info("Initializing device management repository database schema");
try { try {
initializer.createRegistryDatabase(); initializer.createRegistryDatabase();
} catch (Exception e) { } catch (Exception e) {
@ -238,6 +238,7 @@ public class DeviceManagementServiceComponent {
log.debug("Setting Device Management Service Provider: '" + log.debug("Setting Device Management Service Provider: '" +
deviceManagementService.getProviderType() + "'"); deviceManagementService.getProviderType() + "'");
} }
deviceManagers.add(deviceManagementService);
for (PluginInitializationListener listener : listeners) { for (PluginInitializationListener listener : listeners) {
listener.registerDeviceManagementService(deviceManagementService); listener.registerDeviceManagementService(deviceManagementService);
} }

@ -55,14 +55,15 @@ public class DeviceManagementProviderServiceImpl implements
private static Log log = LogFactory.getLog(DeviceManagementProviderServiceImpl.class); private static Log log = LogFactory.getLog(DeviceManagementProviderServiceImpl.class);
public DeviceManagementProviderServiceImpl() { public DeviceManagementProviderServiceImpl() {
/* Registering a listener to retrieve events when some device management service plugin is installed after
* the component is done getting initialized */
DeviceManagementServiceComponent.registerPluginInitializationListener(this);
this.pluginRepository = new DeviceManagementPluginRepository(); this.pluginRepository = new DeviceManagementPluginRepository();
this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO(); this.deviceDAO = DeviceManagementDAOFactory.getDeviceDAO();
this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO(); this.deviceTypeDAO = DeviceManagementDAOFactory.getDeviceTypeDAO();
this.enrollmentDAO = DeviceManagementDAOFactory.getEnrollmentDAO(); this.enrollmentDAO = DeviceManagementDAOFactory.getEnrollmentDAO();
/* Registering a listener to retrieve events when some device management service plugin is installed after
* the component is done getting initialized */
DeviceManagementServiceComponent.registerPluginInitializationListener(this);
} }
@Override @Override

Loading…
Cancel
Save