// Path: distribution/src/main/java/nl/crowndov/displaydirect/distribution/Configuration.java
// public class Configuration {
// 
//     private static final Logger LOGGER = LoggerFactory.getLogger(Configuration.class);
// 
//     private static AbstractConfiguration config = ConfigurationManager.getConfigInstance();
// 
//     public static List<String> getKvEndpoints() {
//         return Arrays.asList(config.getStringArray("distribution.kv78turbo.endpoints"));
//     }
// 
//     public static String[] getKvPublishers() {
//         return config.getStringArray("distribution.kv78turbo.publishers");
//     }
// 
//     public static ZoneId getZoneId() {
//         return ZoneId.of(config.getString("distribution.timezone.default"));
//     }
// 
//     public static String getOutputTransport() {
//         return config.getString("distribution.transport", "mqtt");
//     }
// 
//     public static String getMqttBrokerHost() {
//         return config.getString("distribution.mqtt.host", "localhost:1883");
//     }
// 
//     public static int getZmqInternalPort() {
//         return 9800;
//     }
// 
//     public static String getMqttClientId() {
//         return config.getString("distribution.mqtt.client_id", "distribution");
//     }
// 
//     public static int getAuthorizationTokenMaxAge() {
//         return config.getInt("distribution.authorization.max_age_hours");
//     }
// 
//     public static List<String> getAuthorizationWhitelist() {
//         return Arrays.asList(config.getStringArray("distribution.authorization.whitelist_prefix"));
//     }
// 
//     public static String getBaseUrl() {
//         return config.getString("distribution.install.base_url", "http://localhost:8080");
//     }
// 
//     public static String getSmtpUsername() {
//         return config.getString("distribution.smtp.username", null);
//     }
// 
//     public static String getSmtpPassword() {
//         return config.getString("distribution.smtp.password", null);
//     }
// 
//     public static String getSmtpFrom() {
//         return config.getString("distribution.smtp.from");
//     }
// 
//     public static String getSmtpHostname() {
//         return config.getString("distribution.smtp.hostname");
//     }
// 
//     public static String getSmtpReplyTo() {
//         return config.getString("distribution.smtp.reply_to");
//     }
// 
//     public static boolean getSmtpSsl() { return config.getBoolean("distribution.smtp.ssl", false); }
// 
//     public static int getSmtpPort() {
//         return config.getInt("distribution.smtp.port", 25);
//     }
// 
//     public static int getSmtpConnectTimeout() {
//         return  config.getInt("distribution.smtp.connect_timeout", 10*1000);
//     }
// 
//     public static String getFileBasePath() {
//         return config.getString("distribution.backup.path", System.getProperty("java.io.tmpdir"));
//     }
// 
//     public static String getKv7PlanningPath() {
//         return config.getString("distribution.kv78turbo.path.planning");
//     }
// 
//     public static String getKv7CalendarPath() {
//         return config.getString("distribution.kv78turbo.path.calendar");
//     }
// 
//     public static String getChbPath() {
//         return config.getString("distribution.chb.path");
//     }
// 
// 
//     public static String getPlanningLoaderTime() {
//         return config.getString("distribution.planning.loadTime", "03:30");
//     }
// 
//     public static String getPlanningCleanupTime() {
//         return config.getString("distribution.planning.cleanupTime", "04:00");
//     }
// 
// }
// 
// Path: distribution/src/main/java/nl/crowndov/displaydirect/distribution/transport/mqtt/MqttTransport.java
// public class MqttTransport implements Transport {
// 
//     private static final Logger LOGGER = LoggerFactory.getLogger(MqttTransport.class);
// 
//     private OnMessageReceivedListener listener = null;
// 
//     private final MqttClient.OnMessageListener PUBLISH_LISTENER = (topic, data, ack) -> {
//         LOGGER.trace("Got incoming message on topic {}", topic);
//         boolean result = false;
//         if (listener != null) {
//              result = listener.onMessageReceived(topic, data);
//         }
//         if (result) { // If not we'll retry this message
//             ack.run();
//         }
//     };
// 
//     private MqttClient c = new MqttClient(PUBLISH_LISTENER);
// 
//     @Override
//     public boolean sendMessage(String topic, byte[] data) {
//         return sendMessage(topic, data, QoS.AT_LEAST_ONCE);
//     }
// 
//     @Override
//     public boolean sendMessage(String topic, byte[] data, QoS quality) {
//         return data != null && c.send(topic, data, quality);
//     }
// 
//     @Override
//     public void registerListener(OnMessageReceivedListener listener) {
//         this.listener = listener;
//     }
// 
//     @Override
//     public void stop() {
//         c.stop();
//     }
// 
// }


import nl.crowndov.displaydirect.distribution.Configuration;
import nl.crowndov.displaydirect.distribution.transport.mqtt.MqttTransport;
package nl.crowndov.displaydirect.distribution.transport;


/**
 * Copyright 2017 CROW-NDOV
 *
 * This file is subject to the terms and conditions defined in file 'LICENSE.txt', which is part of this source code package.
 */
public class TransportFactory {

    public static Transport instance = null;

    public static synchronized Transport get() {
// Path: distribution/src/main/java/nl/crowndov/displaydirect/distribution/Configuration.java
// public class Configuration {
// 
//     private static final Logger LOGGER = LoggerFactory.getLogger(Configuration.class);
// 
//     private static AbstractConfiguration config = ConfigurationManager.getConfigInstance();
// 
//     public static List<String> getKvEndpoints() {
//         return Arrays.asList(config.getStringArray("distribution.kv78turbo.endpoints"));
//     }
// 
//     public static String[] getKvPublishers() {
//         return config.getStringArray("distribution.kv78turbo.publishers");
//     }
// 
//     public static ZoneId getZoneId() {
//         return ZoneId.of(config.getString("distribution.timezone.default"));
//     }
// 
//     public static String getOutputTransport() {
//         return config.getString("distribution.transport", "mqtt");
//     }
// 
//     public static String getMqttBrokerHost() {
//         return config.getString("distribution.mqtt.host", "localhost:1883");
//     }
// 
//     public static int getZmqInternalPort() {
//         return 9800;
//     }
// 
//     public static String getMqttClientId() {
//         return config.getString("distribution.mqtt.client_id", "distribution");
//     }
// 
//     public static int getAuthorizationTokenMaxAge() {
//         return config.getInt("distribution.authorization.max_age_hours");
//     }
// 
//     public static List<String> getAuthorizationWhitelist() {
//         return Arrays.asList(config.getStringArray("distribution.authorization.whitelist_prefix"));
//     }
// 
//     public static String getBaseUrl() {
//         return config.getString("distribution.install.base_url", "http://localhost:8080");
//     }
// 
//     public static String getSmtpUsername() {
//         return config.getString("distribution.smtp.username", null);
//     }
// 
//     public static String getSmtpPassword() {
//         return config.getString("distribution.smtp.password", null);
//     }
// 
//     public static String getSmtpFrom() {
//         return config.getString("distribution.smtp.from");
//     }
// 
//     public static String getSmtpHostname() {
//         return config.getString("distribution.smtp.hostname");
//     }
// 
//     public static String getSmtpReplyTo() {
//         return config.getString("distribution.smtp.reply_to");
//     }
// 
//     public static boolean getSmtpSsl() { return config.getBoolean("distribution.smtp.ssl", false); }
// 
//     public static int getSmtpPort() {
//         return config.getInt("distribution.smtp.port", 25);
//     }
// 
//     public static int getSmtpConnectTimeout() {
//         return  config.getInt("distribution.smtp.connect_timeout", 10*1000);
//     }
// 
//     public static String getFileBasePath() {
//         return config.getString("distribution.backup.path", System.getProperty("java.io.tmpdir"));
//     }
// 
//     public static String getKv7PlanningPath() {
//         return config.getString("distribution.kv78turbo.path.planning");
//     }
// 
//     public static String getKv7CalendarPath() {
//         return config.getString("distribution.kv78turbo.path.calendar");
//     }
// 
//     public static String getChbPath() {
//         return config.getString("distribution.chb.path");
//     }
// 
// 
//     public static String getPlanningLoaderTime() {
//         return config.getString("distribution.planning.loadTime", "03:30");
//     }
// 
//     public static String getPlanningCleanupTime() {
//         return config.getString("distribution.planning.cleanupTime", "04:00");
//     }
// 
// }
// 
// Path: distribution/src/main/java/nl/crowndov/displaydirect/distribution/transport/mqtt/MqttTransport.java
// public class MqttTransport implements Transport {
// 
//     private static final Logger LOGGER = LoggerFactory.getLogger(MqttTransport.class);
// 
//     private OnMessageReceivedListener listener = null;
// 
//     private final MqttClient.OnMessageListener PUBLISH_LISTENER = (topic, data, ack) -> {
//         LOGGER.trace("Got incoming message on topic {}", topic);
//         boolean result = false;
//         if (listener != null) {
//              result = listener.onMessageReceived(topic, data);
//         }
//         if (result) { // If not we'll retry this message
//             ack.run();
//         }
//     };
// 
//     private MqttClient c = new MqttClient(PUBLISH_LISTENER);
// 
//     @Override
//     public boolean sendMessage(String topic, byte[] data) {
//         return sendMessage(topic, data, QoS.AT_LEAST_ONCE);
//     }
// 
//     @Override
//     public boolean sendMessage(String topic, byte[] data, QoS quality) {
//         return data != null && c.send(topic, data, quality);
//     }
// 
//     @Override
//     public void registerListener(OnMessageReceivedListener listener) {
//         this.listener = listener;
//     }
// 
//     @Override
//     public void stop() {
//         c.stop();
//     }
// 
// }


// Path: distribution/src/main/java/nl/crowndov/displaydirect/distribution/transport/TransportFactory.java
import nl.crowndov.displaydirect.distribution.Configuration;
import nl.crowndov.displaydirect.distribution.transport.mqtt.MqttTransport;

package nl.crowndov.displaydirect.distribution.transport;


/**
 * Copyright 2017 CROW-NDOV
 *
 * This file is subject to the terms and conditions defined in file 'LICENSE.txt', which is part of this source code package.
 */
public class TransportFactory {

    public static Transport instance = null;

    public static synchronized Transport get() {
        if (Configuration.getOutputTransport().equalsIgnoreCase("mqtt")) {