1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.handler.ssl.ocsp;
17
18 import io.netty.channel.ChannelFactory;
19 import io.netty.channel.EventLoop;
20 import io.netty.channel.MultiThreadIoEventLoopGroup;
21 import io.netty.channel.nio.NioIoHandler;
22 import io.netty.channel.socket.DatagramChannel;
23 import io.netty.channel.socket.SocketChannel;
24 import io.netty.channel.socket.nio.NioDatagramChannel;
25 import io.netty.channel.socket.nio.NioSocketChannel;
26
27 import static io.netty.util.internal.ObjectUtil.checkNotNull;
28
29
30
31
32
33 public final class IoTransport {
34 private final EventLoop eventLoop;
35 private final ChannelFactory<SocketChannel> socketChannel;
36 private final ChannelFactory<DatagramChannel> datagramChannel;
37
38
39
40
41
42 public static final IoTransport DEFAULT = new IoTransport(
43 new MultiThreadIoEventLoopGroup(1, NioIoHandler.newFactory()).next(),
44 new ChannelFactory<SocketChannel>() {
45 @Override
46 public SocketChannel newChannel() {
47 return new NioSocketChannel();
48 }
49 },
50 new ChannelFactory<DatagramChannel>() {
51 @Override
52 public DatagramChannel newChannel() {
53 return new NioDatagramChannel();
54 }
55 });
56
57
58
59
60
61
62
63
64
65 public static IoTransport create(EventLoop eventLoop, ChannelFactory<SocketChannel> socketChannel,
66 ChannelFactory<DatagramChannel> datagramChannel) {
67 return new IoTransport(eventLoop, socketChannel, datagramChannel);
68 }
69
70 private IoTransport(EventLoop eventLoop, ChannelFactory<SocketChannel> socketChannel,
71 ChannelFactory<DatagramChannel> datagramChannel) {
72 this.eventLoop = checkNotNull(eventLoop, "EventLoop");
73 this.socketChannel = checkNotNull(socketChannel, "SocketChannel");
74 this.datagramChannel = checkNotNull(datagramChannel, "DatagramChannel");
75 }
76
77 public EventLoop eventLoop() {
78 return eventLoop;
79 }
80
81 public ChannelFactory<SocketChannel> socketChannel() {
82 return socketChannel;
83 }
84
85 public ChannelFactory<DatagramChannel> datagramChannel() {
86 return datagramChannel;
87 }
88 }