Http2Server Class — netty Architecture
Architecture documentation for the Http2Server class in Http2Server.java from the netty codebase.
Entity Profile
Dependency Diagram
graph TD 8120f85e_97b2_77aa_825e_e08e73e13b40["Http2Server"] 9194a5f2_def7_c98d_c6e7_e86f4e486a3f["Http2Server.java"] 8120f85e_97b2_77aa_825e_e08e73e13b40 -->|defined in| 9194a5f2_def7_c98d_c6e7_e86f4e486a3f 39b8c0b1_4729_ccb8_a9b1_ef49667cd17b["main()"] 8120f85e_97b2_77aa_825e_e08e73e13b40 -->|method| 39b8c0b1_4729_ccb8_a9b1_ef49667cd17b
Relationship Graph
Source Code
example/src/main/java/io/netty/example/http2/helloworld/server/Http2Server.java lines 46–98
public final class Http2Server {
static final boolean SSL = System.getProperty("ssl") != null;
static final int PORT = Integer.parseInt(System.getProperty("port", SSL? "8443" : "8080"));
public static void main(String[] args) throws Exception {
// Configure SSL.
final SslContext sslCtx;
if (SSL) {
SslProvider provider = OpenSsl.isAlpnSupported() ? SslProvider.OPENSSL : SslProvider.JDK;
X509Bundle ssc = new CertificateBuilder()
.subject("cn=localhost")
.setIsCertificateAuthority(true)
.buildSelfSigned();
sslCtx = SslContextBuilder.forServer(ssc.toKeyManagerFactory())
.sslProvider(provider)
/* NOTE: the cipher filter may not include all ciphers required by the HTTP/2 specification.
* Please refer to the HTTP/2 specification for cipher requirements. */
.ciphers(Http2SecurityUtil.CIPHERS, SupportedCipherSuiteFilter.INSTANCE)
.applicationProtocolConfig(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))
.build();
} else {
sslCtx = null;
}
// Configure the server.
EventLoopGroup group = new MultiThreadIoEventLoopGroup(NioIoHandler.newFactory());
try {
ServerBootstrap b = new ServerBootstrap();
b.option(ChannelOption.SO_BACKLOG, 1024);
b.group(group)
.channel(NioServerSocketChannel.class)
.handler(new LoggingHandler(LogLevel.INFO))
.childHandler(new Http2ServerInitializer(sslCtx));
Channel ch = b.bind(PORT).sync().channel();
System.err.println("Open your HTTP/2-enabled web browser and navigate to " +
(SSL? "https" : "http") + "://127.0.0.1:" + PORT + '/');
ch.closeFuture().sync();
} finally {
group.shutdownGracefully();
}
}
}
Source
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/helloworld/server/Http2Server.java.
Where is Http2Server defined?
Http2Server is defined in example/src/main/java/io/netty/example/http2/helloworld/server/Http2Server.java at line 46.
Analyze Your Own Codebase
Get architecture documentation, dependency graphs, and domain analysis for your codebase in minutes.
Try Supermodel Free