1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.example.factorial;
17
18 import io.netty.bootstrap.ServerBootstrap;
19 import io.netty.channel.EventLoopGroup;
20 import io.netty.channel.nio.NioEventLoopGroup;
21 import io.netty.channel.socket.nio.NioServerSocketChannel;
22 import io.netty.example.util.ServerUtil;
23 import io.netty.handler.logging.LogLevel;
24 import io.netty.handler.logging.LoggingHandler;
25 import io.netty.handler.ssl.SslContext;
26
27
28
29
30
31 public final class FactorialServer {
32
33 static final int PORT = Integer.parseInt(System.getProperty("port", "8322"));
34
35 public static void main(String[] args) throws Exception {
36
37 final SslContext sslCtx = ServerUtil.buildSslContext();
38
39 EventLoopGroup group = new NioEventLoopGroup();
40 try {
41 ServerBootstrap b = new ServerBootstrap();
42 b.group(group)
43 .channel(NioServerSocketChannel.class)
44 .handler(new LoggingHandler(LogLevel.INFO))
45 .childHandler(new FactorialServerInitializer(sslCtx));
46
47 b.bind(PORT).sync().channel().closeFuture().sync();
48 } finally {
49 group.shutdownGracefully();
50 }
51 }
52 }