Home / Class/ Http2StaticFileServer Class — netty Architecture

Http2StaticFileServer Class — netty Architecture

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

Entity Profile

Dependency Diagram

graph TD
  89c46614_0cc8_c5f4_216b_ecdf8653e636["Http2StaticFileServer"]
  4330c16e_2930_3bbb_132c_c95ed86f7c09["Http2StaticFileServer.java"]
  89c46614_0cc8_c5f4_216b_ecdf8653e636 -->|defined in| 4330c16e_2930_3bbb_132c_c95ed86f7c09
  8acefdad_8fa6_0373_cf11_bea0061b04eb["main()"]
  89c46614_0cc8_c5f4_216b_ecdf8653e636 -->|method| 8acefdad_8fa6_0373_cf11_bea0061b04eb

Relationship Graph

Source Code

example/src/main/java/io/netty/example/http2/file/Http2StaticFileServer.java lines 36–76

public final class Http2StaticFileServer {

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

    public static void main(String[] args) throws Exception {
        X509Bundle ssc = new CertificateBuilder()
                .subject("cn=localhost")
                .setIsCertificateAuthority(true)
                .buildSelfSigned();

        SslContext sslCtx = SslContextBuilder.forServer(ssc.toKeyManagerFactory())
                .sslProvider(SslProvider.JDK)
                .ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
                .applicationProtocolConfig(new ApplicationProtocolConfig(
                        ApplicationProtocolConfig.Protocol.ALPN,
                        // NO_ADVERTISE is currently the only mode supported by both OpenSsl and JDK providers.
                        ApplicationProtocolConfig.SelectorFailureBehavior.NO_ADVERTISE,
                        // ACCEPT is currently the only mode supported by both OpenSsl and JDK providers.
                        ApplicationProtocolConfig.SelectedListenerFailureBehavior.ACCEPT,
                        ApplicationProtocolNames.HTTP_2,
                        ApplicationProtocolNames.HTTP_1_1))
                .build();

        EventLoopGroup group = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());
        try {
            ServerBootstrap b = new ServerBootstrap();
            b.group(group)
                    .channel(NioServerSocketChannel.class)
                    .handler(new LoggingHandler(LogLevel.INFO))
                    .childHandler(new Http2StaticFileServerInitializer(sslCtx));

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

            System.out.println("Open your web browser and navigate to https://127.0.0.1:" + PORT + '/');

            ch.closeFuture().sync();
        } finally {
            group.shutdownGracefully();
        }
    }
}

Frequently Asked Questions

What is the Http2StaticFileServer class?
Http2StaticFileServer is a class in the netty codebase, defined in example/src/main/java/io/netty/example/http2/file/Http2StaticFileServer.java.
Where is Http2StaticFileServer defined?
Http2StaticFileServer is defined in example/src/main/java/io/netty/example/http2/file/Http2StaticFileServer.java at line 36.

Analyze Your Own Codebase

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

Try Supermodel Free