Add Configuration service and removed url printer

charithag 9 years ago
parent 737b90ce40
commit f22b6251c1

@ -1,5 +1,5 @@
/*
* Copyright (c) 2015, WSO2 Inc. (http://www.wso2.org) All Rights Reserved.
* Copyright (c) 2016, 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
@ -22,7 +22,6 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.osgi.framework.BundleContext;
import org.osgi.service.component.ComponentContext;
import org.wso2.carbon.core.ServerStartupObserver;
import org.wso2.carbon.databridge.core.DataBridgeReceiverService;
import org.wso2.carbon.device.mgt.iot.UserManagement;
import org.wso2.carbon.device.mgt.iot.analytics.statistics.IoTEventsStatisticsClient;
@ -33,9 +32,10 @@ import org.wso2.carbon.device.mgt.iot.config.server.DeviceManagementConfiguratio
import org.wso2.carbon.device.mgt.iot.controlqueue.xmpp.XmppConfig;
import org.wso2.carbon.device.mgt.iot.controlqueue.xmpp.XmppServerClient;
import org.wso2.carbon.device.mgt.iot.exception.DeviceControllerException;
import org.wso2.carbon.device.mgt.iot.service.ConfigurationService;
import org.wso2.carbon.device.mgt.iot.service.ConfigurationServiceImpl;
import org.wso2.carbon.device.mgt.iot.service.DeviceTypeService;
import org.wso2.carbon.device.mgt.iot.service.DeviceTypeServiceImpl;
import org.wso2.carbon.device.mgt.iot.startup.StartupUrlPrinter;
import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.IotDeviceManagementDAOFactory;
import org.wso2.carbon.device.mgt.iot.util.iotdevice.dao.util.IotDeviceManagementDAOUtil;
import org.wso2.carbon.device.mgt.iot.util.iotdevice.exception.IotDeviceMgtPluginException;
@ -85,8 +85,8 @@ public class IotDeviceManagementServiceComponent {
try {
BundleContext bundleContext = ctx.getBundleContext(); /* Initialize the data source
configuration */
BundleContext bundleContext = ctx.getBundleContext();
/* Initialize the data source configuration */
DeviceManagementConfigurationManager.getInstance().initConfig();
IotDeviceTypeConfigurationManager.getInstance().initConfig();
Map<String, IotDeviceTypeConfig> dsConfigMap =
@ -127,11 +127,12 @@ public class IotDeviceManagementServiceComponent {
bundleContext.registerService(DeviceTypeService.class.getName(),
new DeviceTypeServiceImpl(), null);
bundleContext.registerService(ConfigurationService.class.getName(),
new ConfigurationServiceImpl(), null);
if (log.isDebugEnabled()) {
log.debug("Iot Device Management Service Component has been successfully activated");
}
bundleContext.registerService(ServerStartupObserver.class, new StartupUrlPrinter(), null);
} catch (Throwable e) {
log.error("Error occurred while activating Iot Device Management Service Component", e);
}

@ -0,0 +1,51 @@
/*
* Copyright (c) 2016, 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.iot.service;
import org.wso2.carbon.device.mgt.iot.config.server.datasource.ControlQueue;
import org.wso2.carbon.device.mgt.iot.config.server.datasource.DeviceManagementConfiguration;
import org.wso2.carbon.device.mgt.iot.config.server.datasource.DeviceMgtServerInfo;
public interface ConfigurationService {
/**
* Retrieve all configurations in devicemgt-config.xml
*
* @return Complete set of configurations
*/
DeviceManagementConfiguration getDeviceCloudMgtConfig();
/**
* Retrieve control queue configurations
*
* @param name of the control queue
* @return control queue configs
*/
ControlQueue getControlQueue(String name);
/**
* Retrieve device management server information
*
* @return device management server information
*/
DeviceMgtServerInfo getDeviceManagementServerInfo();
}

@ -0,0 +1,41 @@
/*
* Copyright (c) 2016, 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.iot.service;
import org.wso2.carbon.device.mgt.iot.config.server.datasource.ControlQueue;
import org.wso2.carbon.device.mgt.iot.config.server.datasource.DeviceManagementConfiguration;
import org.wso2.carbon.device.mgt.iot.config.server.datasource.DeviceMgtServerInfo;
public class ConfigurationServiceImpl implements ConfigurationService {
@Override
public DeviceManagementConfiguration getDeviceCloudMgtConfig() {
return null;
}
@Override
public ControlQueue getControlQueue(String name) {
return null;
}
@Override
public DeviceMgtServerInfo getDeviceManagementServerInfo() {
return null;
}
}

@ -1,60 +0,0 @@
/*
* 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.iot.startup;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.wso2.carbon.core.ServerStartupObserver;
import org.wso2.carbon.device.mgt.iot.internal.IotDeviceManagementServiceComponent;
import org.wso2.carbon.utils.CarbonUtils;
import org.wso2.carbon.utils.ConfigurationContextService;
import org.wso2.carbon.utils.NetworkUtils;
public class StartupUrlPrinter implements ServerStartupObserver {
private static final Log log = LogFactory.getLog(StartupUrlPrinter.class);
@Override
public void completingServerStartup() {
}
@Override
public void completedServerStartup() {
printUrl();
}
private void printUrl() {
// Hostname
String hostName = "localhost";
try {
hostName = NetworkUtils.getMgtHostName();
} catch (Exception ignored) {
}
// HTTPS port
String mgtConsoleTransport = CarbonUtils.getManagementTransport();
ConfigurationContextService configContextService = IotDeviceManagementServiceComponent.configurationContextService;
int httpsPort = CarbonUtils.getTransportPort(configContextService, mgtConsoleTransport);
log.info("Api Store: https://" + hostName + ":" + httpsPort + "/api-store");
log.info("IOT Server - Device Store: https://" + hostName + ":" + httpsPort + "/store");
log.info("IOT Server - Device Publisher: https://" + hostName + ":" + httpsPort + "/publisher");
}
}
Loading…
Cancel
Save