Class ObservableMqttConnection

java.lang.Object
net.solarnetwork.service.support.BasicIdentifiable
net.solarnetwork.common.mqtt.BaseMqttConnectionService
net.solarnetwork.central.support.ObservableMqttConnection
All Implemented Interfaces:
net.solarnetwork.common.mqtt.MqttConnectionObserver, net.solarnetwork.service.Identifiable, net.solarnetwork.service.PingTest, net.solarnetwork.service.ServiceLifecycleObserver

public class ObservableMqttConnection extends net.solarnetwork.common.mqtt.BaseMqttConnectionService implements net.solarnetwork.service.ServiceLifecycleObserver, net.solarnetwork.common.mqtt.MqttConnectionObserver
Basic MQTT connection service with a configurable list of observers.
  • Nested Class Summary

    Nested classes/interfaces inherited from interface net.solarnetwork.service.PingTest

    net.solarnetwork.service.PingTest.Result
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final String
    The default value for the mqttHost property.
    static final String
    The default value for the mqttUsername property.

    Fields inherited from class net.solarnetwork.common.mqtt.BaseMqttConnectionService

    DEFAULT_PUBLISH_QOS, DEFAULT_SUBSCRIBE_QOS, log

    Fields inherited from interface net.solarnetwork.service.Identifiable

    GROUP_UID_PROPERTY, UID_PROPERTY
  • Constructor Summary

    Constructors
    Constructor
    Description
    ObservableMqttConnection(net.solarnetwork.common.mqtt.MqttConnectionFactory connectionFactory, net.solarnetwork.util.StatTracker mqttStats, String name, List<net.solarnetwork.common.mqtt.MqttConnectionObserver> connectionObservers)
    Constructor.
  • Method Summary

    Modifier and Type
    Method
    Description
    List<net.solarnetwork.common.mqtt.MqttConnectionObserver>
    Get the connection observers.
     
     
    void
    onMqttServerConnectionEstablished(net.solarnetwork.common.mqtt.MqttConnection connection, boolean reconnected)
     
    void
    onMqttServerConnectionLost(net.solarnetwork.common.mqtt.MqttConnection connection, boolean willReconnect, Throwable cause)
     
    void
     
    void
     

    Methods inherited from class net.solarnetwork.common.mqtt.BaseMqttConnectionService

    connection, connectionCreated, getMqttConfig, getMqttStats, getPingTestMaximumExecutionMilliseconds, getPublishQos, getPublishQosValue, getSubscribeQos, getSubscribeQosValue, init, performPingTest, setPublishQos, setPublishQosValue, setSubscribeQos, setSubscribeQosValue, setUid, shutdown, startup

    Methods inherited from class net.solarnetwork.service.support.BasicIdentifiable

    basicIdentifiableMetadataSettings, basicIdentifiableSettings, basicIdentifiableSettings, basicIdentifiableSettings, doubleMetadataValue, getDisplayName, getGroupUid, getGroupUID, getMessageSource, getMetadata, getMetadataCount, getUid, getUID, integerMetadataValue, metadataValue, numberMetadataValue, saveMetadataValue, saveMetadataValue, setDisplayName, setGroupUid, setGroupUID, setMessageSource, setMetadata, setMetadataCount, setUID, smartMetadataValue

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Field Details

    • DEFAULT_MQTT_HOST

      public static final String DEFAULT_MQTT_HOST
      The default value for the mqttHost property.
      See Also:
    • DEFAULT_MQTT_USERNAME

      public static final String DEFAULT_MQTT_USERNAME
      The default value for the mqttUsername property.
      See Also:
  • Constructor Details

    • ObservableMqttConnection

      public ObservableMqttConnection(net.solarnetwork.common.mqtt.MqttConnectionFactory connectionFactory, net.solarnetwork.util.StatTracker mqttStats, String name, List<net.solarnetwork.common.mqtt.MqttConnectionObserver> connectionObservers)
      Constructor.
      Parameters:
      connectionFactory - the MQTT connection factory
      mqttStats - the MQTT stats
      name - the display name
      connectionObservers - the connection observers
  • Method Details

    • getPingTestName

      public String getPingTestName()
      Specified by:
      getPingTestName in interface net.solarnetwork.service.PingTest
    • getPingTestId

      public String getPingTestId()
      Specified by:
      getPingTestId in interface net.solarnetwork.service.PingTest
      Overrides:
      getPingTestId in class net.solarnetwork.common.mqtt.BaseMqttConnectionService
    • serviceDidStartup

      public void serviceDidStartup()
      Specified by:
      serviceDidStartup in interface net.solarnetwork.service.ServiceLifecycleObserver
    • serviceDidShutdown

      public void serviceDidShutdown()
      Specified by:
      serviceDidShutdown in interface net.solarnetwork.service.ServiceLifecycleObserver
    • onMqttServerConnectionEstablished

      public void onMqttServerConnectionEstablished(net.solarnetwork.common.mqtt.MqttConnection connection, boolean reconnected)
      Specified by:
      onMqttServerConnectionEstablished in interface net.solarnetwork.common.mqtt.MqttConnectionObserver
    • onMqttServerConnectionLost

      public void onMqttServerConnectionLost(net.solarnetwork.common.mqtt.MqttConnection connection, boolean willReconnect, Throwable cause)
      Specified by:
      onMqttServerConnectionLost in interface net.solarnetwork.common.mqtt.MqttConnectionObserver
    • getConnectionObservers

      public List<net.solarnetwork.common.mqtt.MqttConnectionObserver> getConnectionObservers()
      Get the connection observers.
      Returns:
      the connection observers