Update Common class walkthrough authored by Daniel Kluge's avatar Daniel Kluge
...@@ -110,3 +110,20 @@ public static String getAASServerPath() { ...@@ -110,3 +110,20 @@ public static String getAASServerPath() {
} }
``` ```
This method returns the value of the environment variable `AASSERVERPATH` or a fallback, handling the acquisition of the value very similar to the method above. This method returns the value of the environment variable `AASSERVERPATH` or a fallback, handling the acquisition of the value very similar to the method above.
```java
public static String getMQTTBrokerHost() {
String uncheckedMQTTBrokerHost = System.getenv("MQTTBROKERHOST");
if (uncheckedMQTTBrokerHost == null || uncheckedMQTTBrokerHost.isEmpty()) {
logger.warn("No valid MQTTBROKERHOST set.");
logger.warn("You might want to explicitly set a MQTTBROKERHOST environment variable, eg:");
logger.warn("$ export MQTTBROKERHOST=\"tcp://esp-controller.local:1883\"");
logger.warn("An MQTT broker at tcp://esp-controller.local:1883 will be assumed going forward.");
return "tcp://esp-controller.local:1883";
} else {
return "tcp://" + uncheckedMQTTBrokerHost + ":1883";
}
}
```
This method returns the value of the environment variable `MQTTBROKERHOST` or a fallback, handling the acquisition of the value very similar to the method above.
\ No newline at end of file