优化日志以及属性设置代码
This commit is contained in:
@@ -11,8 +11,7 @@ import io.netty.buffer.CompositeByteBuf;
|
||||
import io.netty.buffer.UnpooledByteBufAllocator;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.ByteToMessageDecoder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
@@ -22,8 +21,8 @@ import java.util.List;
|
||||
* @date 2023/4/27 18:10
|
||||
* @email qingtaij@163.com
|
||||
*/
|
||||
@Slf4j
|
||||
public class Jt808Decoder extends ByteToMessageDecoder {
|
||||
private final static Logger logger = LoggerFactory.getLogger(Jt808Decoder.class);
|
||||
|
||||
@Override
|
||||
protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
|
||||
|
||||
@@ -7,16 +7,15 @@ import io.netty.buffer.ByteBuf;
|
||||
import io.netty.buffer.ByteBufUtil;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @author QingtaiJiang
|
||||
* @date 2023/4/27 18:10
|
||||
* @email qingtaij@163.com
|
||||
*/
|
||||
@Slf4j
|
||||
public class Jt808Encoder extends MessageToByteEncoder<Rs> {
|
||||
private final static Logger logger = LoggerFactory.getLogger(Jt808Encoder.class);
|
||||
|
||||
@Override
|
||||
protected void encode(ChannelHandlerContext ctx, Rs msg, ByteBuf out) throws Exception {
|
||||
|
||||
@@ -13,8 +13,7 @@ import io.netty.buffer.Unpooled;
|
||||
import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.handler.codec.MessageToByteEncoder;
|
||||
import io.netty.util.ByteProcessor;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
import java.util.LinkedList;
|
||||
@@ -24,8 +23,8 @@ import java.util.LinkedList;
|
||||
* @date 2023/4/27 18:25
|
||||
* @email qingtaij@163.com
|
||||
*/
|
||||
@Slf4j
|
||||
public class Jt808EncoderCmd extends MessageToByteEncoder<Cmd> {
|
||||
private final static Logger logger = LoggerFactory.getLogger(Jt808EncoderCmd.class);
|
||||
|
||||
@Override
|
||||
protected void encode(ChannelHandlerContext ctx, Cmd cmd, ByteBuf out) throws Exception {
|
||||
|
||||
@@ -8,18 +8,16 @@ import io.netty.channel.ChannelHandlerContext;
|
||||
import io.netty.channel.ChannelInboundHandlerAdapter;
|
||||
import io.netty.handler.timeout.IdleState;
|
||||
import io.netty.handler.timeout.IdleStateEvent;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
/**
|
||||
* @author QingtaiJiang
|
||||
* @date 2023/4/27 18:14
|
||||
* @email qingtaij@163.com
|
||||
*/
|
||||
@Slf4j
|
||||
public class Jt808Handler extends ChannelInboundHandlerAdapter {
|
||||
|
||||
private final static Logger logger = LoggerFactory.getLogger(Jt808Handler.class);
|
||||
|
||||
@Override
|
||||
public void channelRead(ChannelHandlerContext ctx, Object msg) throws Exception {
|
||||
if (msg instanceof Rs) {
|
||||
|
||||
@@ -17,8 +17,7 @@ import io.netty.channel.socket.nio.NioSocketChannel;
|
||||
import io.netty.handler.codec.DelimiterBasedFrameDecoder;
|
||||
import io.netty.handler.timeout.IdleStateHandler;
|
||||
import io.netty.util.concurrent.Future;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
@@ -28,8 +27,8 @@ import java.util.concurrent.TimeUnit;
|
||||
* @email qingtaij@163.com
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
public class TcpServer {
|
||||
private final static Logger logger = LoggerFactory.getLogger(TcpServer.class);
|
||||
|
||||
private final Integer port;
|
||||
private boolean isRunning = false;
|
||||
|
||||
@@ -3,8 +3,7 @@ package com.genersoft.iot.vmp.jt1078.proc.factory;
|
||||
import com.genersoft.iot.vmp.jt1078.annotation.MsgId;
|
||||
import com.genersoft.iot.vmp.jt1078.proc.request.Re;
|
||||
import com.genersoft.iot.vmp.jt1078.util.ClassUtil;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@@ -15,9 +14,8 @@ import java.util.Map;
|
||||
* @date 2023/4/27 18:29
|
||||
* @email qingtaij@163.com
|
||||
*/
|
||||
|
||||
@Slf4j
|
||||
public class CodecFactory {
|
||||
private final static Logger logger = LoggerFactory.getLogger(CodecFactory.class);
|
||||
|
||||
private static Map<String, Class<?>> protocolHash;
|
||||
|
||||
|
||||
@@ -4,8 +4,7 @@ import com.genersoft.iot.vmp.jt1078.proc.Header;
|
||||
import com.genersoft.iot.vmp.jt1078.proc.response.Rs;
|
||||
import com.genersoft.iot.vmp.jt1078.session.Session;
|
||||
import io.netty.buffer.ByteBuf;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
import org.springframework.util.StringUtils;
|
||||
|
||||
/**
|
||||
@@ -13,8 +12,8 @@ import org.springframework.util.StringUtils;
|
||||
* @date 2023/4/27 18:50
|
||||
* @email qingtaij@163.com
|
||||
*/
|
||||
@Slf4j
|
||||
public abstract class Re {
|
||||
private final static Logger logger = LoggerFactory.getLogger(Re.class);
|
||||
|
||||
protected abstract Rs decode0(ByteBuf buf, Header header, Session session);
|
||||
|
||||
|
||||
@@ -3,8 +3,7 @@ package com.genersoft.iot.vmp.jt1078.session;
|
||||
import com.genersoft.iot.vmp.jt1078.proc.Header;
|
||||
import io.netty.channel.Channel;
|
||||
import io.netty.util.AttributeKey;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
|
||||
@@ -13,8 +12,8 @@ import java.util.concurrent.atomic.AtomicInteger;
|
||||
* @date 2023/4/27 18:54
|
||||
* @email qingtaij@163.com
|
||||
*/
|
||||
@Slf4j
|
||||
public class Session {
|
||||
private final static Logger logger = LoggerFactory.getLogger(Session.class);
|
||||
|
||||
public static final AttributeKey<Session> KEY = AttributeKey.newInstance(Session.class.getName());
|
||||
|
||||
|
||||
@@ -2,8 +2,7 @@ package com.genersoft.iot.vmp.jt1078.session;
|
||||
|
||||
import com.genersoft.iot.vmp.jt1078.proc.entity.Cmd;
|
||||
import io.netty.channel.Channel;
|
||||
import org.slf4j.Logger;
|
||||
import org.slf4j.LoggerFactory;
|
||||
import lombok.extern.slf4j.Slf4j;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -16,9 +15,9 @@ import java.util.concurrent.TimeUnit;
|
||||
* @date 2023/4/27 19:54
|
||||
* @email qingtaij@163.com
|
||||
*/
|
||||
@Slf4j
|
||||
public enum SessionManager {
|
||||
INSTANCE;
|
||||
private final static Logger logger = LoggerFactory.getLogger(SessionManager.class);
|
||||
|
||||
// 用与消息的缓存
|
||||
private final Map<String, SynchronousQueue<String>> topicSubscribers = new ConcurrentHashMap<>();
|
||||
|
||||
Reference in New Issue
Block a user