业务核心部分都进行完毕了,就剩下 Netty 组件关系的配置 以及 NettyServer 的定义了。
package houlei.net.tcp.cfg;
import houlei.net.tcp.codec.GenericPackageClassifierCodec;
import houlei.net.tcp.codec.GenericPackageCodec;
import houlei.net.tcp.hdr.NettyServerHandler;
import io.netty.bootstrap.ServerBootstrap;
import io.netty.channel.ChannelInitializer;
import io.netty.channel.ChannelOption;
import io.netty.channel.ChannelPipeline;
import io.netty.channel.nio.NioEventLoopGroup;
import io.netty.channel.socket.SocketChannel;
import io.netty.channel.socket.nio.NioServerSocketChannel;
import io.netty.handler.logging.LogLevel;
import io.netty.handler.logging.LoggingHandler;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;
import javax.annotation.Resource;
import java.net.InetSocketAddress;
@Configuration
public class NettyConfigure {
@Value(