package no.ntnu.okse.protocol.mqtt;

import no.ntnu.okse.core.messaging.Message;
import no.ntnu.okse.protocol.AbstractProtocolServer;
import org.apache.log4j.Logger;

public class MQTTProtocolServer extends AbstractProtocolServer {
	protected static final String SERVERTYPE = "mqtt";

	private MQTTServer server;

	public MQTTProtocolServer(String host, Integer port) {
		this.host = host;
		this.port = port;
		log = Logger.getLogger(MQTTProtocolServer.class.getName());
	}

	@Override
	public void boot() {
		if(!_running) {
			server = new MQTTServer(this, host, port);
			_serverThread = new Thread(this::run);
			_serverThread.setName("MQTTProtocolServer");
			_serverThread.start();
			_running = true;
			log.info("MQTTProtocolServer booted successfully");
		}
	}

	@Override
	public void run() {
		server.start();
	}

	@Override
	public void stopServer() {
		log.info("Stopping MQTTProtocolServer");
		server.stopServer();
		_running = false;
		server = null;
		log.info("MQTTProtocolServer is stopped");
	}

	@Override
	public String getProtocolServerType() {
		return SERVERTYPE;
	}

	@Override
	public void sendMessage(Message message) {
		log.info("Received message on topic " + message.getMessage() );
		server.sendMessage( message );

	}

	public boolean isRunning() {
		return _running;
	}
}

@@ -278,16 +278,100 @@
 mqtt%22;%0A%0A
+%09private static Logger log = Logger.getLogger(MQTTProtocolServer.class.getName());%0A%0A
 %09private
@@ -491,70 +491,8 @@
 rt;%0A
-%09%09log = Logger.getLogger(MQTTProtocolServer.class.getName());%0A
 %09%7D%0A%0A

Move logger