Home / Class/ Http2Server Class — netty Architecture

Http2Server Class — netty Architecture

Architecture documentation for the Http2Server class in Http2Server.java from the netty codebase.

Entity Profile

Dependency Diagram

graph TD
  a7fb0a0d_b65a_50b5_e087_0c2acc22c234["Http2Server"]
  e22b2a25_6727_9196_19bc_7fa370f06e75["Http2Server.java"]
  a7fb0a0d_b65a_50b5_e087_0c2acc22c234 -->|defined in| e22b2a25_6727_9196_19bc_7fa370f06e75
  da62ea67_565b_c1c3_05ae_2e2bf0ce68a9["Http2Server()"]
  a7fb0a0d_b65a_50b5_e087_0c2acc22c234 -->|method| da62ea67_565b_c1c3_05ae_2e2bf0ce68a9
  0f1e491b_e71b_48a5_f697_737a6404324e["ChannelFuture()"]
  a7fb0a0d_b65a_50b5_e087_0c2acc22c234 -->|method| 0f1e491b_e71b_48a5_f697_737a6404324e
  da2bfb93_b425_f186_fd97_8acade8487b0["SslContext()"]
  a7fb0a0d_b65a_50b5_e087_0c2acc22c234 -->|method| da2bfb93_b425_f186_fd97_8acade8487b0

Relationship Graph

Source Code

example/src/main/java/io/netty/example/http2/tiles/Http2Server.java lines 44–87

public class Http2Server {

    public static final int PORT = Integer.parseInt(System.getProperty("http2-port", "8443"));

    private final EventLoopGroup group;

    public Http2Server(EventLoopGroup eventLoopGroup) {
        group = eventLoopGroup;
    }

    public ChannelFuture start() throws Exception {
        final SslContext sslCtx = configureTLS();
        ServerBootstrap b = new ServerBootstrap();
        b.option(ChannelOption.SO_BACKLOG, 1024);
        b.group(group).channel(NioServerSocketChannel.class).childHandler(new ChannelInitializer<SocketChannel>() {
            @Override
            protected void initChannel(SocketChannel ch) throws Exception {
                ch.pipeline().addLast(sslCtx.newHandler(ch.alloc()), new Http2OrHttpHandler());
            }
        });

        Channel ch = b.bind(PORT).sync().channel();
        return ch.closeFuture();
    }

    private static SslContext configureTLS() throws Exception {
        X509Bundle ssc = new CertificateBuilder()
                .subject("cn=localhost")
                .setIsCertificateAuthority(true)
                .buildSelfSigned();
        ApplicationProtocolConfig apn = new ApplicationProtocolConfig(
                Protocol.ALPN,
                // NO_ADVERTISE is currently the only mode supported by both OpenSsl and JDK providers.
                SelectorFailureBehavior.NO_ADVERTISE,
                // ACCEPT is currently the only mode supported by both OpenSsl and JDK providers.
                SelectedListenerFailureBehavior.ACCEPT,
                ApplicationProtocolNames.HTTP_2,
                ApplicationProtocolNames.HTTP_1_1);

        return SslContextBuilder.forServer(ssc.toKeyManagerFactory())
                                .ciphers(CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
                                .applicationProtocolConfig(apn).build();
    }
}

Frequently Asked Questions

What is the Http2Server class?
Http2Server is a class in the netty codebase, defined in example/src/main/java/io/netty/example/http2/tiles/Http2Server.java.
Where is Http2Server defined?
Http2Server is defined in example/src/main/java/io/netty/example/http2/tiles/Http2Server.java at line 44.

Analyze Your Own Codebase

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

Try Supermodel Free