INNER CODE UNIT · Java

start

luxiaoxun/Code4Java · MapHttpService/src/main/java/com/luxx/map/MapHttpServer.java:36

    public void start(int port) throws Exception {
        bossGroup = new NioEventLoopGroup();
        workerGroup = new NioEventLoopGroup();
        eventExecutorGroup = new DefaultEventExecutorGroup(32);
        try {
            ServerBootstrap b = new ServerBootstrap();
            b.group(bossGroup, workerGroup).channel(NioServerSocketChannel.class)
                    .childHandler(new ChannelInitializer<SocketChannel>() {
                        @Override
                        public void initChannel(SocketChannel ch) throws Exception {
                            ch.pipeline().addLast(new HttpResponseEncoder());
                            ch.pipeline().addLast(new HttpRequestDecoder());
                            //aggregates an HttpMessage and its following HttpContents into a single FullHttpRequest or FullHttpResponse
                            //with no following HttpContents.
                            ch.pipeline().addLast(new HttpObjectAggregator(65536));
                            ch.pipeline().addLast(eventExecutorGroup, new HttpServerInboundHandler());
                        }
                    }).option(ChannelOption.SO_BACKLOG, 128)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…