mirror of
https://repository.entgra.net/community/device-mgt-core.git
synced 2025-10-06 02:01:45 +00:00
code cleanup
This commit is contained in:
parent
f563e1f448
commit
674735d9db
@ -17,7 +17,7 @@ package org.wso2.carbon.device.mgt.mobile.impl.dao;
|
|||||||
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.DataSourceListener;
|
import org.wso2.carbon.device.mgt.mobile.impl.DataSourceListener;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileDeviceDAOImpl;
|
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileDeviceDAOImpl;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileDeviceModelImpl;
|
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileDeviceModelDAOImpl;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileDeviceVendorDAOImpl;
|
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileDeviceVendorDAOImpl;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileOSVersionDAOImpl;
|
import org.wso2.carbon.device.mgt.mobile.impl.dao.impl.MobileOSVersionDAOImpl;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.util.MobileDeviceManagementDAOUtil;
|
import org.wso2.carbon.device.mgt.mobile.impl.dao.util.MobileDeviceManagementDAOUtil;
|
||||||
@ -27,7 +27,7 @@ import javax.sql.DataSource;
|
|||||||
|
|
||||||
public class MobileDeviceDAOFactory implements DataSourceListener {
|
public class MobileDeviceDAOFactory implements DataSourceListener {
|
||||||
|
|
||||||
private DataSource dataSource;
|
private static DataSource dataSource;
|
||||||
|
|
||||||
public MobileDeviceDAOFactory() {
|
public MobileDeviceDAOFactory() {
|
||||||
MobileDeviceManagementBundleActivator.registerDataSourceListener(this);
|
MobileDeviceManagementBundleActivator.registerDataSourceListener(this);
|
||||||
@ -35,27 +35,23 @@ public class MobileDeviceDAOFactory implements DataSourceListener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void notifyObserver() {
|
public void notifyObserver() {
|
||||||
this.dataSource = MobileDeviceManagementDAOUtil.resolveDataSource();
|
dataSource = MobileDeviceManagementDAOUtil.resolveDataSource();
|
||||||
}
|
|
||||||
|
|
||||||
private DataSource getDataSource() {
|
|
||||||
return dataSource;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MobileDeviceDAO getMobileDeviceDAO() {
|
public static MobileDeviceDAO getMobileDeviceDAO() {
|
||||||
return new MobileDeviceDAOImpl();
|
return new MobileDeviceDAOImpl(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MobileDeviceModelDAO getMobileDeviceModelDAO() {
|
public static MobileDeviceModelDAO getMobileDeviceModelDAO() {
|
||||||
return new MobileDeviceModelImpl();
|
return new MobileDeviceModelDAOImpl(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MobileDeviceVendorDAO getMobileDeviceVendorDAO() {
|
public static MobileDeviceVendorDAO getMobileDeviceVendorDAO() {
|
||||||
return new MobileDeviceVendorDAOImpl();
|
return new MobileDeviceVendorDAOImpl(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static MobileOSVersionDAO getMobileOSVersionDAO() {
|
public static MobileOSVersionDAO getMobileOSVersionDAO() {
|
||||||
return new MobileOSVersionDAOImpl();
|
return new MobileOSVersionDAOImpl(dataSource);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,9 +16,9 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.device.mgt.mobile.impl.dao.util;
|
package org.wso2.carbon.device.mgt.mobile.impl.dao.util;
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
import javax.sql.DataSource;
|
import javax.sql.DataSource;
|
||||||
=======
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.device.mgt.common.Device;
|
import org.wso2.carbon.device.mgt.common.Device;
|
||||||
@ -32,19 +32,16 @@ import java.sql.PreparedStatement;
|
|||||||
import java.sql.ResultSet;
|
import java.sql.ResultSet;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
>>>>>>> 95f72f77f1a86f8f7e92b8cceafd63b40374dcbb
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Utility method required by MobileDeviceManagement DAO classes.
|
* Utility method required by MobileDeviceManagement DAO classes.
|
||||||
*/
|
*/
|
||||||
public class MobileDeviceManagementDAOUtil {
|
public class MobileDeviceManagementDAOUtil {
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
public static DataSource resolveDataSource() {
|
public static DataSource resolveDataSource() {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
=======
|
|
||||||
private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOUtil.class);
|
private static final Log log = LogFactory.getLog(MobileDeviceManagementDAOUtil.class);
|
||||||
|
|
||||||
public static void cleanupResources(Connection conn, PreparedStatement stmt, ResultSet rs) {
|
public static void cleanupResources(Connection conn, PreparedStatement stmt, ResultSet rs) {
|
||||||
@ -89,5 +86,5 @@ public class MobileDeviceManagementDAOUtil {
|
|||||||
MobileDevice mobileDeviceBO = new MobileDevice();
|
MobileDevice mobileDeviceBO = new MobileDevice();
|
||||||
return mobileDeviceBO;
|
return mobileDeviceBO;
|
||||||
}
|
}
|
||||||
>>>>>>> 95f72f77f1a86f8f7e92b8cceafd63b40374dcbb
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -16,27 +16,15 @@
|
|||||||
|
|
||||||
package org.wso2.carbon.device.mgt.mobile.impl.internal;
|
package org.wso2.carbon.device.mgt.mobile.impl.internal;
|
||||||
|
|
||||||
import org.apache.commons.logging.LogFactory;
|
|
||||||
import org.apache.commons.logging.Log;
|
import org.apache.commons.logging.Log;
|
||||||
<<<<<<< HEAD
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.osgi.framework.*;
|
import org.osgi.framework.*;
|
||||||
=======
|
|
||||||
import org.osgi.framework.BundleActivator;
|
|
||||||
import org.osgi.framework.BundleContext;
|
|
||||||
import org.osgi.framework.ServiceRegistration;
|
|
||||||
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
import org.wso2.carbon.device.mgt.common.DeviceManagementException;
|
||||||
>>>>>>> 95f72f77f1a86f8f7e92b8cceafd63b40374dcbb
|
|
||||||
import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService;
|
import org.wso2.carbon.device.mgt.common.spi.DeviceManagerService;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.DataSourceListener;
|
import org.wso2.carbon.device.mgt.mobile.impl.DataSourceListener;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManagerService;
|
import org.wso2.carbon.device.mgt.mobile.impl.android.AndroidDeviceManagerService;
|
||||||
<<<<<<< HEAD
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceDAOFactory;
|
|
||||||
=======
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.config.MobileDeviceConfigurationManager;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.config.MobileDeviceManagementConfig;
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.MobileDataSourceConfig;
|
import org.wso2.carbon.device.mgt.mobile.impl.config.datasource.MobileDataSourceConfig;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceManagementDAOFactory;
|
import org.wso2.carbon.device.mgt.mobile.impl.dao.MobileDeviceDAOFactory;
|
||||||
>>>>>>> 95f72f77f1a86f8f7e92b8cceafd63b40374dcbb
|
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.ios.IOSDeviceManagerService;
|
import org.wso2.carbon.device.mgt.mobile.impl.ios.IOSDeviceManagerService;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.util.MobileDeviceManagementSchemaInitializer;
|
import org.wso2.carbon.device.mgt.mobile.impl.util.MobileDeviceManagementSchemaInitializer;
|
||||||
import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagerService;
|
import org.wso2.carbon.device.mgt.mobile.impl.windows.WindowsDeviceManagerService;
|
||||||
@ -54,7 +42,6 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator, B
|
|||||||
private static final Log log = LogFactory.getLog(MobileDeviceManagementBundleActivator.class);
|
private static final Log log = LogFactory.getLog(MobileDeviceManagementBundleActivator.class);
|
||||||
private static final String SYMBOLIC_NAME_DATA_SOURCE_COMPONENT = "org.wso2.carbon.ndatasource.core";
|
private static final String SYMBOLIC_NAME_DATA_SOURCE_COMPONENT = "org.wso2.carbon.ndatasource.core";
|
||||||
|
|
||||||
<<<<<<< HEAD
|
|
||||||
@Override
|
@Override
|
||||||
public void start(BundleContext bundleContext) throws Exception {
|
public void start(BundleContext bundleContext) throws Exception {
|
||||||
try {
|
try {
|
||||||
@ -63,6 +50,17 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator, B
|
|||||||
}
|
}
|
||||||
bundleContext.addBundleListener(this);
|
bundleContext.addBundleListener(this);
|
||||||
|
|
||||||
|
/* If -Dsetup option enabled then create device management database schema */
|
||||||
|
String setupOption = System.getProperty("setup");
|
||||||
|
if (setupOption != null) {
|
||||||
|
if (log.isDebugEnabled()) {
|
||||||
|
log.debug(
|
||||||
|
"-Dsetup is enabled. Mobile Device management repository schema initialization is about " +
|
||||||
|
"to begin");
|
||||||
|
}
|
||||||
|
setupMobileDeviceManagementSchema(null);
|
||||||
|
}
|
||||||
|
|
||||||
MobileDeviceDAOFactory daoFactory = new MobileDeviceDAOFactory();
|
MobileDeviceDAOFactory daoFactory = new MobileDeviceDAOFactory();
|
||||||
//TODO Register this dao to an appropriate config file
|
//TODO Register this dao to an appropriate config file
|
||||||
|
|
||||||
@ -113,49 +111,6 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator, B
|
|||||||
private List<DataSourceListener> getDataSourceListeners() {
|
private List<DataSourceListener> getDataSourceListeners() {
|
||||||
return dataSourceListeners;
|
return dataSourceListeners;
|
||||||
}
|
}
|
||||||
=======
|
|
||||||
@Override
|
|
||||||
public void start(BundleContext bundleContext) throws Exception {
|
|
||||||
try {
|
|
||||||
//Initialize Mobile Device Management datasource
|
|
||||||
// MobileDeviceConfigurationManager.getInstance().initConfig();
|
|
||||||
// MobileDeviceManagementConfig config = MobileDeviceConfigurationManager.getInstance()
|
|
||||||
// .getMobileDeviceManagementConfig();
|
|
||||||
// MobileDataSourceConfig
|
|
||||||
// dsConfig = config.getMobileDeviceMgtRepository().getMobileDataSourceConfig();
|
|
||||||
// MobileDeviceManagementDAOFactory.init(dsConfig);
|
|
||||||
|
|
||||||
/* If -Dsetup option enabled then create device management database schema */
|
|
||||||
String setupOption = System.getProperty("setup");
|
|
||||||
if (setupOption != null) {
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug(
|
|
||||||
"-Dsetup is enabled. Mobile Device management repository schema initialization is about " +
|
|
||||||
"to begin");
|
|
||||||
}
|
|
||||||
setupMobileDeviceManagementSchema(null);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("Activating Mobile Device Management Service bundle");
|
|
||||||
}
|
|
||||||
androidServiceRegRef =
|
|
||||||
bundleContext.registerService(DeviceManagerService.class.getName(),
|
|
||||||
new AndroidDeviceManagerService(), null);
|
|
||||||
iOSServiceRegRef =
|
|
||||||
bundleContext.registerService(DeviceManagerService.class.getName(),
|
|
||||||
new IOSDeviceManagerService(), null);
|
|
||||||
windowsServiceRegRef =
|
|
||||||
bundleContext.registerService(DeviceManagerService.class.getName(),
|
|
||||||
new WindowsDeviceManagerService(), null);
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("Mobile Device Management Service bundle is activated");
|
|
||||||
}
|
|
||||||
} catch (Throwable e) {
|
|
||||||
log.error("Error occurred while activating Mobile Device Management Service Component",
|
|
||||||
e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private void setupMobileDeviceManagementSchema(MobileDataSourceConfig config) throws
|
private void setupMobileDeviceManagementSchema(MobileDataSourceConfig config) throws
|
||||||
DeviceManagementException {
|
DeviceManagementException {
|
||||||
@ -163,7 +118,7 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator, B
|
|||||||
new MobileDeviceManagementSchemaInitializer(config);
|
new MobileDeviceManagementSchemaInitializer(config);
|
||||||
log.info("Initializing mobile device management repository database schema");
|
log.info("Initializing mobile device management repository database schema");
|
||||||
try {
|
try {
|
||||||
initializer.createRegistryDatabase();
|
//initializer.createRegistryDatabase();
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new DeviceManagementException(
|
throw new DeviceManagementException(
|
||||||
"Error occurred while initializing Mobile Device Management " +
|
"Error occurred while initializing Mobile Device Management " +
|
||||||
@ -171,15 +126,5 @@ public class MobileDeviceManagementBundleActivator implements BundleActivator, B
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public void stop(BundleContext bundleContext) throws Exception {
|
|
||||||
if (log.isDebugEnabled()) {
|
|
||||||
log.debug("Deactivating Mobile Device Management Service");
|
|
||||||
}
|
|
||||||
androidServiceRegRef.unregister();
|
|
||||||
iOSServiceRegRef.unregister();
|
|
||||||
windowsServiceRegRef.unregister();
|
|
||||||
}
|
|
||||||
>>>>>>> 95f72f77f1a86f8f7e92b8cceafd63b40374dcbb
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user