From 843322d33f502ab26cd49c368d58dd0419060846 Mon Sep 17 00:00:00 2001 From: harshanL Date: Thu, 4 Dec 2014 17:12:55 +0530 Subject: [PATCH] Added service registrations to Mobile DeviceManagerService component . --- .../pom.xml | 7 ++- .../MobileDeviceMgtServiceComponent.java | 43 ++++++++++++++++++- 2 files changed, 48 insertions(+), 2 deletions(-) diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml index 8226ca1fe..18f3cb20a 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/pom.xml @@ -33,7 +33,7 @@ ${project.artifactId} ${project.artifactId} ${project.version} - Device Management Core Bundle + Device Management Mobile Impl Bundle org.wso2.carbon.device.mgt.mobile.impl.internal org.osgi.framework, @@ -72,6 +72,11 @@ org.wso2.carbon org.wso2.carbon.logging + + org.eclipse.osgi + org.eclipse.osgi.services + 3.2.0.v20090520-1800 + \ No newline at end of file diff --git a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/internal/MobileDeviceMgtServiceComponent.java b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/internal/MobileDeviceMgtServiceComponent.java index e1a881795..af66453e6 100644 --- a/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/internal/MobileDeviceMgtServiceComponent.java +++ b/components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/internal/MobileDeviceMgtServiceComponent.java @@ -16,8 +16,49 @@ package org.wso2.carbon.device.mgt.mobile.impl.internal; +import org.apache.commons.logging.LogFactory; +import org.apache.commons.logging.Log; +import org.osgi.framework.ServiceRegistration; +import org.osgi.service.component.ComponentContext; +import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService; +import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManagerService; +import org.wso2.carbon.device.mgt.mobile.impl.ios.IOSDeviceManagerService; +import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagerService; + /** - * Created by harshan on 12/4/14. + * @scr.component name="org.wso2.carbon.device.manager.mobile" immediate="true" */ public class MobileDeviceMgtServiceComponent { + + private static final Log log = LogFactory.getLog(MobileDeviceMgtServiceComponent.class); + ServiceRegistration serviceRegistration; + + protected void activate(ComponentContext ctx) { + try { + if (log.isDebugEnabled()) { + log.debug("Activating Mobile Device Management Service"); + } + AndroidDeviceManagerService androidDeviceMgrService = new AndroidDeviceManagerService(); + IOSDeviceManagerService iOSDeviceMgrService = new IOSDeviceManagerService(); + WindowsDeviceManagerService windowsDeviceMgrService = new WindowsDeviceManagerService(); + serviceRegistration = + ctx.getBundleContext().registerService(DeviceManagerService.class.getName(), + androidDeviceMgrService, null); + serviceRegistration = + ctx.getBundleContext().registerService(DeviceManagerService.class.getName(), + iOSDeviceMgrService, null); + serviceRegistration = + ctx.getBundleContext().registerService(DeviceManagerService.class.getName(), + windowsDeviceMgrService, null); + } catch (Throwable e) { + log.error("Unable to activate Mobile Device Management Service Component", e); + } + } + + protected void deactivate(ComponentContext ctx) { + if (log.isDebugEnabled()) { + log.debug("Deactivating Mobile Device Management Service"); + } + serviceRegistration.unregister(); + } }