Home / Function/ main() — netty Function Reference

main() — netty Function Reference

Architecture documentation for the main() function in ObjectEchoServer.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  41983198_1520_a420_39ea_e1f1082bb29b["main()"]
  02da72f5_a9ac_943b_1882_efc91026f606["ObjectEchoServer"]
  41983198_1520_a420_39ea_e1f1082bb29b -->|defined in| 02da72f5_a9ac_943b_1882_efc91026f606
  style 41983198_1520_a420_39ea_e1f1082bb29b fill:#6366f1,stroke:#818cf8,color:#fff

Relationship Graph

Source Code

example/src/main/java/io/netty/example/objectecho/ObjectEchoServer.java lines 43–72

    public static void main(String[] args) throws Exception {
        // Configure SSL.
        final SslContext sslCtx = ServerUtil.buildSslContext();

        EventLoopGroup group = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());
        try {
            ServerBootstrap b = new ServerBootstrap();
            b.group(group)
             .channel(NioServerSocketChannel.class)
             .handler(new LoggingHandler(LogLevel.INFO))
             .childHandler(new ChannelInitializer<SocketChannel>() {
                @Override
                public void initChannel(SocketChannel ch) throws Exception {
                    ChannelPipeline p = ch.pipeline();
                    if (sslCtx != null) {
                        p.addLast(sslCtx.newHandler(ch.alloc()));
                    }
                    p.addLast(
                            new ObjectEncoder(),
                            new ObjectDecoder(ClassResolvers.cacheDisabled(null)),
                            new ObjectEchoServerHandler());
                }
             });

            // Bind and start to accept incoming connections.
            b.bind(PORT).sync().channel().closeFuture().sync();
        } finally {
            group.shutdownGracefully();
        }
    }

Domain

Subdomains

Frequently Asked Questions

What does main() do?
main() is a function in the netty codebase, defined in example/src/main/java/io/netty/example/objectecho/ObjectEchoServer.java.
Where is main() defined?
main() is defined in example/src/main/java/io/netty/example/objectecho/ObjectEchoServer.java at line 43.

Analyze Your Own Codebase

Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.

Try Supermodel Free