package lc.esp.engine;

import lc.esp.engine.broker.EnhancedBrokerPlugin;
import lc.mecha.log.MechaLogger;
import lc.mecha.log.MechaLoggerFactory;
import lc.mecha.util.BasicallyDangerous;
import lc.mecha.util.UniversalJob;
import org.apache.activemq.broker.BrokerPlugin;
import org.apache.activemq.broker.BrokerService;

public class Engine extends BasicallyDangerous {
    private static final MechaLogger logger = MechaLoggerFactory.getLogger(Engine.class);
    public static void main(String args[]) throws InterruptedException {
        UniversalJob.banner(logger, "Enhanced Services Platform mk18/ENGINE (GIPSY DANGER)");

        Engine eng = new Engine();
        eng.run();

        while (true) {
            Thread.sleep(1000);
        }
    }

    @Override
    public void runDangerously() throws Exception {
        BrokerService broker = new BrokerService();
        broker.addConnector("tcp://0.0.0.0:52018");
        broker.addConnector("mqtt://0.0.0.0:52019");
        broker.addConnector("stomp://0.0.0.0:52020");
        broker.addConnector("ws://0.0.0.0:52021");
        broker.setPersistent(false);
        broker.setPlugins(new BrokerPlugin[]{new EnhancedBrokerPlugin()});
        new EnhancedBrokerPlugin().installPlugin(broker.getBroker());
        broker.start();
    }
}
