Switched to slf4j backing on log4j configuration
This commit is contained in:
+8
-1
@@ -25,10 +25,17 @@
|
||||
<version>2.0.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
<!-- <dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-jdk14</artifactId>
|
||||
<version>1.6.4</version>
|
||||
</dependency>-->
|
||||
|
||||
|
||||
<dependency>
|
||||
<groupId>org.slf4j</groupId>
|
||||
<artifactId>slf4j-log4j12</artifactId>
|
||||
<version>1.6.4</version>
|
||||
</dependency>
|
||||
|
||||
<dependency>
|
||||
|
||||
@@ -5,8 +5,6 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.CountDownLatch;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.apache.mina.core.RuntimeIoException;
|
||||
import org.apache.mina.core.future.ConnectFuture;
|
||||
import org.apache.mina.core.future.WriteFuture;
|
||||
@@ -35,6 +33,8 @@ import org.dna.mqtt.moquette.proto.messages.DisconnectMessage;
|
||||
import org.dna.mqtt.moquette.proto.messages.PublishMessage;
|
||||
import org.dna.mqtt.moquette.proto.messages.SubscribeMessage;
|
||||
import org.dna.mqtt.moquette.server.Server;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* The API to connect to a MQTT server.
|
||||
@@ -47,7 +47,7 @@ import org.dna.mqtt.moquette.server.Server;
|
||||
*/
|
||||
public final class Client {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(Client.class.getName());
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Client.class);
|
||||
// private static final String HOSTNAME = /*"localhost"*/ "127.0.0.1";
|
||||
// private static final int PORT = Server.PORT;
|
||||
private static final long CONNECT_TIMEOUT = 3 * 1000L; // 3 seconds
|
||||
@@ -102,11 +102,11 @@ public final class Client {
|
||||
|
||||
try {
|
||||
ConnectFuture future = m_connector.connect(new InetSocketAddress(m_hostname, m_port));
|
||||
LOG.fine("Client waiting to connect to server");
|
||||
LOG.debug("Client waiting to connect to server");
|
||||
future.awaitUninterruptibly();
|
||||
m_session = future.getSession();
|
||||
} catch (RuntimeIoException e) {
|
||||
LOG.log(Level.FINE, "Failed to connect, retry " + retries + " of ("+m_connectRetries+")", e);
|
||||
LOG.debug("Failed to connect, retry " + retries + " of ("+m_connectRetries+")", e);
|
||||
}
|
||||
|
||||
if (retries == m_connectRetries) {
|
||||
@@ -176,7 +176,7 @@ public final class Client {
|
||||
try {
|
||||
wf.await();
|
||||
} catch (InterruptedException ex) {
|
||||
LOG.log(Level.SEVERE, null, ex);
|
||||
LOG.debug(null, ex);
|
||||
throw new PublishException(ex);
|
||||
}
|
||||
|
||||
@@ -196,7 +196,7 @@ public final class Client {
|
||||
try {
|
||||
wf.await();
|
||||
} catch (InterruptedException ex) {
|
||||
LOG.log(Level.SEVERE, null, ex);
|
||||
LOG.error(null, ex);
|
||||
throw new SubscribeException(ex);
|
||||
}
|
||||
LOG.info("subscribe message sent");
|
||||
|
||||
@@ -1,6 +1,5 @@
|
||||
package org.dna.mqtt.moquette.client;
|
||||
|
||||
import java.util.logging.Logger;
|
||||
import org.apache.mina.core.service.IoHandlerAdapter;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
import org.dna.mqtt.moquette.proto.messages.AbstractMessage;
|
||||
@@ -8,6 +7,8 @@ import static org.dna.mqtt.moquette.proto.messages.AbstractMessage.*;
|
||||
import org.dna.mqtt.moquette.proto.messages.ConnAckMessage;
|
||||
import org.dna.mqtt.moquette.proto.messages.PublishMessage;
|
||||
import org.dna.mqtt.moquette.proto.messages.SubAckMessage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -15,7 +16,7 @@ import org.dna.mqtt.moquette.proto.messages.SubAckMessage;
|
||||
*/
|
||||
public class ClientMQTTHandler extends IoHandlerAdapter {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(ClientMQTTHandler.class.getName());
|
||||
private static final Logger LOG = LoggerFactory.getLogger(ClientMQTTHandler.class);
|
||||
|
||||
Client m_callback;
|
||||
|
||||
@@ -26,7 +27,7 @@ public class ClientMQTTHandler extends IoHandlerAdapter {
|
||||
@Override
|
||||
public void messageReceived(IoSession session, Object message) throws Exception {
|
||||
AbstractMessage msg = (AbstractMessage) message;
|
||||
LOG.fine("Received a message of type " + msg.getMessageType());
|
||||
LOG.debug("Received a message of type " + msg.getMessageType());
|
||||
switch (msg.getMessageType()) {
|
||||
case CONNACK:
|
||||
handleConnectAck(session, (ConnAckMessage) msg);
|
||||
|
||||
@@ -1,15 +1,16 @@
|
||||
package org.dna.mqtt.moquette.client;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.logging.Logger;
|
||||
import org.dna.mqtt.moquette.server.Server;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author andrea
|
||||
*/
|
||||
public class Main {
|
||||
private static final Logger LOG = Logger.getLogger(Main.class.getName());
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Main.class);
|
||||
|
||||
static boolean received;
|
||||
|
||||
|
||||
@@ -1,11 +1,10 @@
|
||||
package org.dna.mqtt.moquette.proto;
|
||||
|
||||
import java.io.UnsupportedEncodingException;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.apache.mina.core.buffer.IoBuffer;
|
||||
import org.apache.mina.filter.codec.demux.MessageDecoderResult;
|
||||
import org.dna.mqtt.moquette.proto.messages.AbstractMessage;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
* Common utils methodd used in codecs.
|
||||
@@ -103,7 +102,7 @@ public class Utils {
|
||||
//NB every Java platform has got UTF-8 encoding by default, so this
|
||||
//exception are never raised.
|
||||
} catch (UnsupportedEncodingException ex) {
|
||||
Logger.getLogger(ConnectEncoder.class.getName()).log(Level.SEVERE, null, ex);
|
||||
LoggerFactory.getLogger(ConnectEncoder.class).error(null, ex);
|
||||
return null;
|
||||
}
|
||||
Utils.writeWord(out, raw.length);
|
||||
|
||||
@@ -2,13 +2,9 @@ package org.dna.mqtt.moquette.server;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import org.apache.mina.core.future.WriteFuture;
|
||||
import org.apache.mina.core.service.IoHandlerAdapter;
|
||||
import org.apache.mina.core.session.IdleStatus;
|
||||
import org.apache.mina.core.session.IoSession;
|
||||
import org.dna.mqtt.moquette.SubscribeException;
|
||||
import org.dna.mqtt.moquette.messaging.spi.IMessaging;
|
||||
import org.dna.mqtt.moquette.messaging.spi.INotifier;
|
||||
import org.dna.mqtt.moquette.proto.messages.AbstractMessage;
|
||||
@@ -19,6 +15,8 @@ import org.dna.mqtt.moquette.proto.messages.ConnectMessage;
|
||||
import org.dna.mqtt.moquette.proto.messages.PublishMessage;
|
||||
import org.dna.mqtt.moquette.proto.messages.SubAckMessage;
|
||||
import org.dna.mqtt.moquette.proto.messages.SubscribeMessage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
|
||||
/**
|
||||
*
|
||||
@@ -27,7 +25,7 @@ import org.dna.mqtt.moquette.proto.messages.SubscribeMessage;
|
||||
public class MQTTHandler extends IoHandlerAdapter implements INotifier {
|
||||
protected static final String ATTR_CLIENTID = "ClientID";
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(MQTTHandler.class.getName());
|
||||
private static final Logger LOG = LoggerFactory.getLogger(MQTTHandler.class);
|
||||
|
||||
/** Maps CLIENT_ID to the IoSession that represents the connection*/
|
||||
Map<String, ConnectionDescriptor> m_clientIDs = new HashMap<String, ConnectionDescriptor>();
|
||||
@@ -37,7 +35,7 @@ public class MQTTHandler extends IoHandlerAdapter implements INotifier {
|
||||
@Override
|
||||
public void messageReceived(IoSession session, Object message) throws Exception {
|
||||
AbstractMessage msg = (AbstractMessage) message;
|
||||
LOG.log(Level.INFO, "Received a message of type {0}", msg.getMessageType());
|
||||
LOG.info("Received a message of type {0}", msg.getMessageType());
|
||||
try {
|
||||
switch (msg.getMessageType()) {
|
||||
case CONNECT:
|
||||
@@ -51,7 +49,7 @@ public class MQTTHandler extends IoHandlerAdapter implements INotifier {
|
||||
break;
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
LOG.log(Level.SEVERE, "Bad error in processing the message", ex);
|
||||
LOG.error("Bad error in processing the message", ex);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +129,7 @@ public class MQTTHandler extends IoHandlerAdapter implements INotifier {
|
||||
for (int i=0; i < msg.subscriptions().size(); i++) {
|
||||
ackMessage.addType(QOSType.MOST_ONE);
|
||||
}
|
||||
LOG.log(Level.INFO, "replying with SubAct to MSG ID {0}", msg.getMessageID());
|
||||
LOG.info("replying with SubAct to MSG ID {0}", msg.getMessageID());
|
||||
session.write(ackMessage);
|
||||
}
|
||||
|
||||
|
||||
@@ -2,7 +2,6 @@ package org.dna.mqtt.moquette.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.util.logging.Logger;
|
||||
import org.apache.mina.core.service.IoAcceptor;
|
||||
import org.apache.mina.core.session.IdleStatus;
|
||||
import org.apache.mina.filter.codec.ProtocolCodecFilter;
|
||||
@@ -21,13 +20,15 @@ import org.dna.mqtt.moquette.proto.SubscribeDecoder;
|
||||
import org.dna.mqtt.moquette.proto.messages.ConnAckMessage;
|
||||
import org.dna.mqtt.moquette.proto.messages.PublishMessage;
|
||||
import org.dna.mqtt.moquette.proto.messages.SubAckMessage;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
/**
|
||||
* Launch a configured version of the server.
|
||||
* @author andrea
|
||||
*/
|
||||
public class Server {
|
||||
|
||||
private static final Logger LOG = Logger.getLogger(Server.class.getName());
|
||||
private static final Logger LOG = LoggerFactory.getLogger(Server.class);
|
||||
|
||||
public static final int PORT = 9191;
|
||||
public static final int DEFAULT_CONNECT_TIMEOUT = 10;
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package org.dna.mqtt.moquette.server;
|
||||
|
||||
import java.io.IOException;
|
||||
import org.apache.mina.core.service.IoConnector;
|
||||
import org.dna.mqtt.moquette.client.Client;
|
||||
import org.dna.mqtt.moquette.client.IPublishCallback;
|
||||
import org.junit.After;
|
||||
|
||||
Reference in New Issue
Block a user