Package net.solarnetwork.central.support
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
FieldsModifier and TypeFieldDescriptionstatic final StringThe default value for themqttHostproperty.static final StringThe default value for themqttUsernameproperty.Fields inherited from class net.solarnetwork.common.mqtt.BaseMqttConnectionService
DEFAULT_PUBLISH_QOS, DEFAULT_SUBSCRIBE_QOS, logFields inherited from interface net.solarnetwork.service.Identifiable
GROUP_UID_PROPERTY, UID_PROPERTY -
Constructor Summary
ConstructorsConstructorDescriptionObservableMqttConnection(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 TypeMethodDescriptionList<net.solarnetwork.common.mqtt.MqttConnectionObserver> Get the connection observers.voidonMqttServerConnectionEstablished(net.solarnetwork.common.mqtt.MqttConnection connection, boolean reconnected) voidonMqttServerConnectionLost(net.solarnetwork.common.mqtt.MqttConnection connection, boolean willReconnect, Throwable cause) voidvoidMethods 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, startupMethods 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
-
Field Details
-
DEFAULT_MQTT_HOST
The default value for themqttHostproperty.- See Also:
-
DEFAULT_MQTT_USERNAME
The default value for themqttUsernameproperty.- 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 factorymqttStats- the MQTT statsname- the display nameconnectionObservers- the connection observers
-
-
Method Details
-
getPingTestName
- Specified by:
getPingTestNamein interfacenet.solarnetwork.service.PingTest
-
getPingTestId
- Specified by:
getPingTestIdin interfacenet.solarnetwork.service.PingTest- Overrides:
getPingTestIdin classnet.solarnetwork.common.mqtt.BaseMqttConnectionService
-
serviceDidStartup
public void serviceDidStartup()- Specified by:
serviceDidStartupin interfacenet.solarnetwork.service.ServiceLifecycleObserver
-
serviceDidShutdown
public void serviceDidShutdown()- Specified by:
serviceDidShutdownin interfacenet.solarnetwork.service.ServiceLifecycleObserver
-
onMqttServerConnectionEstablished
public void onMqttServerConnectionEstablished(net.solarnetwork.common.mqtt.MqttConnection connection, boolean reconnected) - Specified by:
onMqttServerConnectionEstablishedin interfacenet.solarnetwork.common.mqtt.MqttConnectionObserver
-
onMqttServerConnectionLost
public void onMqttServerConnectionLost(net.solarnetwork.common.mqtt.MqttConnection connection, boolean willReconnect, Throwable cause) - Specified by:
onMqttServerConnectionLostin interfacenet.solarnetwork.common.mqtt.MqttConnectionObserver
-
getConnectionObservers
Get the connection observers.- Returns:
- the connection observers
-