forked from community/device-mgt-plugins
parent
b55afc31e2
commit
6045ad7704
6
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagementService.java → components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java
6
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManagementService.java → components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManagementService.java
14
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManager.java → components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManager.java
14
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidDeviceManager.java → components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidDeviceManager.java
5
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidFeatureManager.java → components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidFeatureManager.java
5
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidFeatureManager.java → components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidFeatureManager.java
2
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java → components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidPolicyMonitoringService.java
2
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/AndroidPolicyMonitoringService.java → components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/AndroidPolicyMonitoringService.java
11
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/AndroidDAOFactory.java → components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidDAOFactory.java
11
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/AndroidDAOFactory.java → components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidDAOFactory.java
2
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/AndroidFeatureManagementDAOException.java → components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidFeatureManagementDAOException.java
2
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/AndroidFeatureManagementDAOException.java → components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/AndroidFeatureManagementDAOException.java
6
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/impl/AndroidDeviceDAOImpl.java → components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidDeviceDAOImpl.java
6
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/impl/AndroidDeviceDAOImpl.java → components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidDeviceDAOImpl.java
8
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/impl/AndroidFeatureDAOImpl.java → components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidFeatureDAOImpl.java
8
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/dao/impl/AndroidFeatureDAOImpl.java → components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/dao/impl/AndroidFeatureDAOImpl.java
2
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/util/AndroidPluginConstants.java → components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidPluginConstants.java
2
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/util/AndroidPluginConstants.java → components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidPluginConstants.java
4
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/util/AndroidPluginUtils.java → components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidPluginUtils.java
4
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/util/AndroidPluginUtils.java → components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidPluginUtils.java
2
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/util/AndroidUtils.java → components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidUtils.java
2
components/device-mgt/org.wso2.carbon.device.mgt.mobile.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/impl/android/util/AndroidUtils.java → components/device-mgt-mdm-android/org.wso2.carbon.device.mgt.mobile.android.impl/src/main/java/org/wso2/carbon/device/mgt/mobile/android/impl/util/AndroidUtils.java
@ -0,0 +1,47 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* you may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.device.mgt.mobile.android.internal;
|
||||||
|
|
||||||
|
import org.wso2.carbon.registry.core.service.RegistryService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* DataHolder class of Mobile plugins component.
|
||||||
|
*/
|
||||||
|
public class AndroidDeviceManagementDataHolder {
|
||||||
|
|
||||||
|
private RegistryService registryService;
|
||||||
|
|
||||||
|
private static AndroidDeviceManagementDataHolder thisInstance = new AndroidDeviceManagementDataHolder();
|
||||||
|
|
||||||
|
private AndroidDeviceManagementDataHolder() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public static AndroidDeviceManagementDataHolder getInstance() {
|
||||||
|
return thisInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
public RegistryService getRegistryService() {
|
||||||
|
return registryService;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRegistryService(RegistryService registryService) {
|
||||||
|
this.registryService = registryService;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
|
||||||
|
*
|
||||||
|
* WSO2 Inc. licenses this file to you under the Apache License,
|
||||||
|
* Version 2.0 (the "License"); you may not use this file except
|
||||||
|
* in compliance with the License.
|
||||||
|
* you may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing,
|
||||||
|
* software distributed under the License is distributed on an
|
||||||
|
* "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
|
||||||
|
* KIND, either express or implied. See the License for the
|
||||||
|
* specific language governing permissions and limitations
|
||||||
|
* under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.wso2.carbon.device.mgt.mobile.android.internal;
|
||||||
|
|
||||||
|
import org.apache.commons.logging.Log;
|
||||||
|
import org.apache.commons.logging.LogFactory;
|
||||||
|
import org.osgi.framework.BundleContext;
|
||||||
|
import org.osgi.framework.ServiceRegistration;
|
||||||
|
import org.osgi.service.component.ComponentContext;
|
||||||
|
import org.wso2.carbon.device.mgt.common.spi.DeviceManagementService;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.android.impl.AndroidDeviceManagementService;
|
||||||
|
import org.wso2.carbon.device.mgt.mobile.android.impl.AndroidPolicyMonitoringService;
|
||||||
|
import org.wso2.carbon.ndatasource.core.DataSourceService;
|
||||||
|
import org.wso2.carbon.policy.mgt.common.spi.PolicyMonitoringService;
|
||||||
|
import org.wso2.carbon.registry.core.service.RegistryService;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @scr.component name="org.wso2.carbon.device.mgt.mobile.android.impl.internal.AndroidDeviceManagementServiceComponent"
|
||||||
|
* immediate="true"
|
||||||
|
* @scr.reference name="org.wso2.carbon.ndatasource"
|
||||||
|
* interface="org.wso2.carbon.ndatasource.core.DataSourceService"
|
||||||
|
* cardinality="1..1"
|
||||||
|
* policy="dynamic"
|
||||||
|
* bind="setDataSourceService"
|
||||||
|
* unbind="unsetDataSourceService"
|
||||||
|
* @scr.reference name="registry.service"
|
||||||
|
* interface="org.wso2.carbon.registry.core.service.RegistryService" cardinality="0..1"
|
||||||
|
* policy="dynamic" bind="setRegistryService" unbind="unsetRegistryService"
|
||||||
|
* <p/>
|
||||||
|
* Adding reference to API Manager Configuration service is an unavoidable hack to get rid of NPEs thrown while
|
||||||
|
* initializing APIMgtDAOs attempting to register APIs programmatically. APIMgtDAO needs to be proper cleaned up
|
||||||
|
* to avoid as an ideal fix
|
||||||
|
*/
|
||||||
|
public class AndroidDeviceManagementServiceComponent {
|
||||||
|
|
||||||
|
private ServiceRegistration androidServiceRegRef;
|
||||||
|
|
||||||
|
private static final Log log = LogFactory.getLog(AndroidDeviceManagementServiceComponent.class);
|
||||||
|
|
||||||
|
protected void activate(ComponentContext ctx) {
|
||||||
|
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Activating Android Mobile Device Management Service Component");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
BundleContext bundleContext = ctx.getBundleContext();
|
||||||
|
|
||||||
|
androidServiceRegRef =
|
||||||
|
bundleContext.registerService(DeviceManagementService.class.getName(),
|
||||||
|
new AndroidDeviceManagementService(), null);
|
||||||
|
|
||||||
|
// Policy management service
|
||||||
|
|
||||||
|
bundleContext.registerService(PolicyMonitoringService.class,
|
||||||
|
new AndroidPolicyMonitoringService(), null);
|
||||||
|
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Android Mobile Device Management Service Component has been successfully activated");
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
log.error("Error occurred while activating Android Mobile Device Management Service Component", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void deactivate(ComponentContext ctx) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("De-activating Android Mobile Device Management Service Component");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
if (androidServiceRegRef != null) {
|
||||||
|
androidServiceRegRef.unregister();
|
||||||
|
}
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug(
|
||||||
|
"Android Mobile Device Management Service Component has been successfully de-activated");
|
||||||
|
}
|
||||||
|
} catch (Throwable e) {
|
||||||
|
log.error("Error occurred while de-activating Android Mobile Device Management bundle", e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setDataSourceService(DataSourceService dataSourceService) {
|
||||||
|
/* This is to avoid mobile device management component getting initialized before the underlying datasources
|
||||||
|
are registered */
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("Data source service set to android mobile service component");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void unsetDataSourceService(DataSourceService dataSourceService) {
|
||||||
|
//do nothing
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setRegistryService(RegistryService registryService) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug("RegistryService acquired");
|
||||||
|
}
|
||||||
|
AndroidDeviceManagementDataHolder.getInstance().setRegistryService(registryService);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void unsetRegistryService(RegistryService registryService) {
|
||||||
|
AndroidDeviceManagementDataHolder.getInstance().setRegistryService(null);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in new issue