// Path: mithqtt-api/src/main/java/com/github/longkerdandy/mithqtt/api/cluster/Cluster.java
// public interface Cluster {
// 
//     /**
//      * Init the cluster
//      *
//      * @param config  Configuration
//      * @param factory Cluster Listener Factory
//      * @throws ClusterException if there is a exception when trying to init cluster.
//      */
//     void init(AbstractConfiguration config, ClusterListenerFactory factory) throws ClusterException;
// 
//     /**
//      * Destroy the cluster
//      */
//     void destroy();
// 
//     /**
//      * Send message to broker
//      *
//      * @param brokerId Broker Id
//      * @param message  Message
//      */
//     void sendToBroker(String brokerId, Message message);
// 
//     /**
//      * Send message to outside
//      * Other application can pick up the message from there
//      *
//      * @param message Message
//      */
//     void sendToApplication(Message message);
// }
// 
// Path: mithqtt-application-sample/src/main/java/com/github/longkerdandy/mithqtt/application/sample/cluster/ApplicationClusterListenerFactoryImpl.java
// public class ApplicationClusterListenerFactoryImpl implements ClusterListenerFactory {
// 
//     @Override
//     public ClusterListener newListener() {
//         return new ApplicationClusterListenerImpl();
//     }
// }


import com.github.longkerdandy.mithqtt.api.cluster.Cluster;
import com.github.longkerdandy.mithqtt.application.sample.cluster.ApplicationClusterListenerFactoryImpl;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
package com.github.longkerdandy.mithqtt.application.sample;


/**
 * Sample Application
 */
public class SampleApp {

    private static final Logger logger = LoggerFactory.getLogger(SampleApp.class);

    public static void main(String[] args) throws Exception {

        logger.debug("Starting Sample Application ...");

        // load config
        logger.debug("Loading Sample Application config files ...");
        PropertiesConfiguration clusterConfig;
        if (args.length >= 1 ) {
            clusterConfig = new PropertiesConfiguration(args[0]);
        } else {
            clusterConfig = new PropertiesConfiguration("config/cluster.properties");
        }

        // cluster
        logger.debug("Initializing cluster ...");
// Path: mithqtt-api/src/main/java/com/github/longkerdandy/mithqtt/api/cluster/Cluster.java
// public interface Cluster {
// 
//     /**
//      * Init the cluster
//      *
//      * @param config  Configuration
//      * @param factory Cluster Listener Factory
//      * @throws ClusterException if there is a exception when trying to init cluster.
//      */
//     void init(AbstractConfiguration config, ClusterListenerFactory factory) throws ClusterException;
// 
//     /**
//      * Destroy the cluster
//      */
//     void destroy();
// 
//     /**
//      * Send message to broker
//      *
//      * @param brokerId Broker Id
//      * @param message  Message
//      */
//     void sendToBroker(String brokerId, Message message);
// 
//     /**
//      * Send message to outside
//      * Other application can pick up the message from there
//      *
//      * @param message Message
//      */
//     void sendToApplication(Message message);
// }
// 
// Path: mithqtt-application-sample/src/main/java/com/github/longkerdandy/mithqtt/application/sample/cluster/ApplicationClusterListenerFactoryImpl.java
// public class ApplicationClusterListenerFactoryImpl implements ClusterListenerFactory {
// 
//     @Override
//     public ClusterListener newListener() {
//         return new ApplicationClusterListenerImpl();
//     }
// }


// Path: mithqtt-application-sample/src/main/java/com/github/longkerdandy/mithqtt/application/sample/SampleApp.java
import com.github.longkerdandy.mithqtt.api.cluster.Cluster;
import com.github.longkerdandy.mithqtt.application.sample.cluster.ApplicationClusterListenerFactoryImpl;
import org.apache.commons.configuration.PropertiesConfiguration;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;

package com.github.longkerdandy.mithqtt.application.sample;


/**
 * Sample Application
 */
public class SampleApp {

    private static final Logger logger = LoggerFactory.getLogger(SampleApp.class);

    public static void main(String[] args) throws Exception {

        logger.debug("Starting Sample Application ...");

        // load config
        logger.debug("Loading Sample Application config files ...");
        PropertiesConfiguration clusterConfig;
        if (args.length >= 1 ) {
            clusterConfig = new PropertiesConfiguration(args[0]);
        } else {
            clusterConfig = new PropertiesConfiguration("config/cluster.properties");
        }

        // cluster
        logger.debug("Initializing cluster ...");
        Cluster cluster = (Cluster) Class.forName(clusterConfig.getString("cluster.class")).newInstance();