mirror of
https://repository.entgra.net/community/device-mgt-plugins.git
synced 2025-09-16 23:42:15 +00:00
Merge pull request #304 from ayyoob/transport
few changes added to transport adapters after testing with the cluster
This commit is contained in:
commit
8b6fe27cab
@ -96,9 +96,12 @@ public class MQTTEventAdapter implements InputEventAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connect() {
|
public void connect() {
|
||||||
|
if (!mqttAdapterListener.isConnectionInitialized()) {
|
||||||
mqttAdapterListener.createConnection();
|
mqttAdapterListener.createConnection();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnect() {
|
public void disconnect() {
|
||||||
//when mqtt and this feature both together then this method becomes a blocking method, Therefore
|
//when mqtt and this feature both together then this method becomes a blocking method, Therefore
|
||||||
@ -147,7 +150,7 @@ public class MQTTEventAdapter implements InputEventAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPolling() {
|
public boolean isPolling() {
|
||||||
return true;
|
return mqttAdapterListener.isConnectionInitialized();
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@ -58,6 +58,7 @@ public class MQTTAdapterListener implements MqttCallback, Runnable {
|
|||||||
private MqttClient mqttClient;
|
private MqttClient mqttClient;
|
||||||
private MqttConnectOptions connectionOptions;
|
private MqttConnectOptions connectionOptions;
|
||||||
private boolean cleanSession;
|
private boolean cleanSession;
|
||||||
|
private boolean connectionInitialized;
|
||||||
|
|
||||||
private MQTTBrokerConnectionConfiguration mqttBrokerConnectionConfiguration;
|
private MQTTBrokerConnectionConfiguration mqttBrokerConnectionConfiguration;
|
||||||
private String topic;
|
private String topic;
|
||||||
@ -279,6 +280,11 @@ public class MQTTAdapterListener implements MqttCallback, Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void createConnection() {
|
public void createConnection() {
|
||||||
|
connectionInitialized = true;
|
||||||
new Thread(this).start();
|
new Thread(this).start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isConnectionInitialized() {
|
||||||
|
return connectionInitialized;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@ -103,8 +103,10 @@ public class XMPPEventAdapter implements InputEventAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void connect() {
|
public void connect() {
|
||||||
|
if (xmppAdapterListener.isConnectionInitialized()) {
|
||||||
xmppAdapterListener.createConnection();
|
xmppAdapterListener.createConnection();
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void disconnect() {
|
public void disconnect() {
|
||||||
@ -142,7 +144,7 @@ public class XMPPEventAdapter implements InputEventAdapter {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean isPolling() {
|
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.apache.commons.logging.LogFactory;
|
||||||
import org.jivesoftware.smack.ConnectionConfiguration;
|
import org.jivesoftware.smack.ConnectionConfiguration;
|
||||||
import org.jivesoftware.smack.PacketListener;
|
import org.jivesoftware.smack.PacketListener;
|
||||||
|
import org.jivesoftware.smack.ReconnectionManager;
|
||||||
import org.jivesoftware.smack.SmackConfiguration;
|
import org.jivesoftware.smack.SmackConfiguration;
|
||||||
import org.jivesoftware.smack.XMPPConnection;
|
import org.jivesoftware.smack.XMPPConnection;
|
||||||
import org.jivesoftware.smack.XMPPException;
|
import org.jivesoftware.smack.XMPPException;
|
||||||
@ -53,6 +54,7 @@ public class XMPPAdapterListener implements Runnable {
|
|||||||
private ContentValidator contentValidator;
|
private ContentValidator contentValidator;
|
||||||
private ContentTransformer contentTransformer;
|
private ContentTransformer contentTransformer;
|
||||||
private PacketListener packetListener;
|
private PacketListener packetListener;
|
||||||
|
private boolean connectionInitialized;
|
||||||
|
|
||||||
private InputEventAdapterListener eventAdapterListener = null;
|
private InputEventAdapterListener eventAdapterListener = null;
|
||||||
|
|
||||||
@ -217,6 +219,11 @@ public class XMPPAdapterListener implements Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void createConnection() {
|
public void createConnection() {
|
||||||
|
connectionInitialized = true;
|
||||||
new Thread(this).start();
|
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.Log;
|
||||||
import org.apache.commons.logging.LogFactory;
|
import org.apache.commons.logging.LogFactory;
|
||||||
import org.wso2.carbon.core.ServerStartupObserver;
|
import org.wso2.carbon.core.ServerStartupObserver;
|
||||||
|
import org.wso2.carbon.device.mgt.iot.virtualfirealarm.plugin.internal.VirtualFirealarmManagementDataHolder;
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@ -36,7 +37,7 @@ public class VirtualFirealarmStartupListener implements ServerStartupObserver {
|
|||||||
try {
|
try {
|
||||||
VirtualFireAlarmUtils.setupMqttInputAdapter();
|
VirtualFireAlarmUtils.setupMqttInputAdapter();
|
||||||
VirtualFireAlarmUtils.setupXmppInputAdapter();
|
VirtualFireAlarmUtils.setupXmppInputAdapter();
|
||||||
|
VirtualFirealarmManagementDataHolder.getInstance().getInputEventAdapterService().start();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
log.error("Failed to intilaize the virtual firealarm input adapter", e);
|
log.error("Failed to intilaize the virtual firealarm input adapter", e);
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user