Adding fix for startup error when MB features are not yet up

merge-requests/1/head
Ace 9 years ago
parent 1aef1d10c3
commit 279c4a1c7a

@ -36,6 +36,7 @@ import org.wso2.carbon.device.mgt.iot.exception.DeviceControllerException;
import org.wso2.carbon.device.mgt.iot.sensormgt.SensorDataManager; import org.wso2.carbon.device.mgt.iot.sensormgt.SensorDataManager;
import org.wso2.carbon.device.mgt.iot.sensormgt.SensorRecord; import org.wso2.carbon.device.mgt.iot.sensormgt.SensorRecord;
import org.wso2.carbon.device.mgt.iot.transport.TransportHandlerException; import org.wso2.carbon.device.mgt.iot.transport.TransportHandlerException;
import org.wso2.carbon.device.mgt.iot.DeviceManagement;
import javax.servlet.http.HttpServletResponse; import javax.servlet.http.HttpServletResponse;
import javax.ws.rs.Consumes; import javax.ws.rs.Consumes;
@ -64,14 +65,37 @@ public class ConnectedCupControllerService {
} }
public void setconnectedCupMQTTConnector( public void setconnectedCupMQTTConnector(
ConnectedCupMQTTConnector connectedCupMQTTConnector) { final ConnectedCupMQTTConnector connectedCupMQTTConnector) {
ConnectedCupControllerService.connectedCupMQTTConnector = connectedCupMQTTConnector;
if (MqttConfig.getInstance().isEnabled()) { Runnable connector = new Runnable() {
connectedCupMQTTConnector.connect(); public void run() {
} else { if (waitForServerStartup()) {
log.warn("MQTT disabled in 'devicemgt-config.xml'. " + return;
"Hence, DigitalDisplayMqttCommunicationHandler not started."); }
ConnectedCupControllerService.connectedCupMQTTConnector = connectedCupMQTTConnector;
if (MqttConfig.getInstance().isEnabled()) {
connectedCupMQTTConnector.connect();
} else {
log.warn("MQTT disabled in 'devicemgt-config.xml'. " +
"Hence, ConnectedCupMQTTConnector not started.");
}
}
};
Thread connectorThread = new Thread(connector);
connectorThread.setDaemon(true);
connectorThread.start();
}
private boolean waitForServerStartup() {
while (!DeviceManagement.isServerReady()) {
try {
Thread.sleep(1000);
} catch (InterruptedException e) {
return true;
}
} }
return false;
} }
/** /**

Loading…
Cancel
Save