-
Notifications
You must be signed in to change notification settings - Fork 0
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
custom services samples #1
base: master
Are you sure you want to change the base?
Conversation
@@ -0,0 +1,233 @@ | |||
/* * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * * | |||
* Copyright (c) 2019 SAP SE or an affiliate company. All rights reserved. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The date is invalid (2019).
By the way, should we add the copyright to all files?
|
||
public class ConfigurationHandler { | ||
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationHandler.class); // logger | ||
private static final String BASE_PATH = "./../edgeservices/"; // base path for custom configuration, same of other |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
"same of other" is unclear to me what you mean.
private static final Logger LOGGER = LoggerFactory.getLogger(ConfigurationHandler.class); // logger | ||
private static final String BASE_PATH = "./../edgeservices/"; // base path for custom configuration, same of other | ||
// services | ||
private static final String UNIFORM_PATH_SEPARATOR = "/"; // linux/windows valid file separator |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why not using the already generic File.separator
constant?
https://docs.oracle.com/javase/7/docs/api/java/io/File.html#separator
defaultConfiguration = loadDefaultConfiguration(); | ||
} | ||
// existing file paths | ||
String jsonFile = BASE_PATH + serviceName + "/" + serviceName + ".json"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use File.separator, or reuse the constant you have defined at the top of the file.
} | ||
// existing file paths | ||
String jsonFile = BASE_PATH + serviceName + "/" + serviceName + ".json"; | ||
String fingerprintFile = BASE_PATH + serviceName + "/" + serviceName + "_fingerprint.txt"; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
use File.separator, or reuse the constant you have defined at the top of the file.
Float variance; | ||
Float pressureScale; | ||
Boolean ingestionEnabled; | ||
Boolean filterMeasurements; | ||
Boolean filterCalculation; | ||
List<MessageFilter> filteredObjects; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better use private access
String externalConfigurationTopic; | ||
String configurationFile; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better use private access
String capabilityAlternateId; | ||
String sensorAlternateId; | ||
String sensorTypeAlternateId; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
better use private access
TypeReference<HashMap<String, Object>> typeRef = new TypeReference<HashMap<String, Object>>() { | ||
}; | ||
Map<String, Object> originalMassageMap = mapper.readValue(mqttMessage.toString(), typeRef); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Better:
Map<String, Object > originalMassageMap = mapper.readValue(
mqttMessage.toString(), TypeFactory.mapType(HashMap.class, String.class, Object.class));
} | ||
|
||
public static void sendMessage(String topic, String content) { | ||
MqttMessage message = null; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
= null is redundant here, you can remove it.
Signed-off-by: Marco Porru <[email protected]>
No description provided.