Merge pull request #304 from ayyoob/transport

few changes added to transport adapters after testing with the cluster
revert-dabc3590
Ruwan 9 years ago committed by GitHub
commit 8b6fe27cab

@ -96,7 +96,10 @@ public class MQTTEventAdapter implements InputEventAdapter {
@Override
public void connect() {
mqttAdapterListener.createConnection();
if (!mqttAdapterListener.isConnectionInitialized()) {
mqttAdapterListener.createConnection();
}
}
@Override
@ -147,7 +150,7 @@ public class MQTTEventAdapter implements InputEventAdapter {
@Override
public boolean isPolling() {
return true;
return mqttAdapterListener.isConnectionInitialized();
}
}

@ -58,6 +58,7 @@ public class MQTTAdapterListener implements MqttCallback, Runnable {
private MqttClient mqttClient;
private MqttConnectOptions connectionOptions;
private boolean cleanSession;
private boolean connectionInitialized;
private MQTTBrokerConnectionConfiguration mqttBrokerConnectionConfiguration;
private String topic;
@ -279,6 +280,11 @@ public class MQTTAdapterListener implements MqttCallback, Runnable {
}
public void createConnection() {
connectionInitialized = true;
new Thread(this).start();
}
public boolean isConnectionInitialized() {
return connectionInitialized;
}
}

@ -103,7 +103,9 @@ public class XMPPEventAdapter implements InputEventAdapter {
@Override
public void connect() {
xmppAdapterListener.createConnection();
if (xmppAdapterListener.isConnectionInitialized()) {
xmppAdapterListener.createConnection();
}
}
@Override
@ -142,7 +144,7 @@ public class XMPPEventAdapter implements InputEventAdapter {
@Override
public boolean isPolling() {
return true;
return xmppAdapterListener.isConnectionInitialized();
}
}

@ -21,6 +21,7 @@ import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import org.jivesoftware.smack.ConnectionConfiguration;
import org.jivesoftware.smack.PacketListener;
import org.jivesoftware.smack.ReconnectionManager;
import org.jivesoftware.smack.SmackConfiguration;
import org.jivesoftware.smack.XMPPConnection;
import org.jivesoftware.smack.XMPPException;
@ -53,6 +54,7 @@ public class XMPPAdapterListener implements Runnable {
private ContentValidator contentValidator;
private ContentTransformer contentTransformer;
private PacketListener packetListener;
private boolean connectionInitialized;
private InputEventAdapterListener eventAdapterListener = null;
@ -217,6 +219,11 @@ public class XMPPAdapterListener implements Runnable {
}
public void createConnection() {
connectionInitialized = true;
new Thread(this).start();
}
public boolean isConnectionInitialized() {
return connectionInitialized;
}
}

@ -21,6 +21,7 @@ package org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.impl.util;
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.virtualfirealarm.plugin.internal.VirtualFirealarmManagementDataHolder;
import java.io.IOException;
@ -36,7 +37,7 @@ public class VirtualFirealarmStartupListener implements ServerStartupObserver {
try {
VirtualFireAlarmUtils.setupMqttInputAdapter();
VirtualFireAlarmUtils.setupXmppInputAdapter();
VirtualFirealarmManagementDataHolder.getInstance().getInputEventAdapterService().start();
} catch (IOException e) {
log.error("Failed to intilaize the virtual firealarm input adapter", e);
}

Loading…
Cancel
Save