1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.channel;
17
18 import io.netty.buffer.ByteBufAllocator;
19 import io.netty.util.AbstractConstant;
20 import io.netty.util.ConstantPool;
21 import io.netty.util.internal.ObjectUtil;
22
23 import java.net.InetAddress;
24 import java.net.NetworkInterface;
25
26
27
28
29
30
31
32
33
34 public class ChannelOption<T> extends AbstractConstant<ChannelOption<T>> {
35
36 private static final ConstantPool<ChannelOption<Object>> pool = new ConstantPool<ChannelOption<Object>>() {
37 @Override
38 protected ChannelOption<Object> newConstant(int id, String name) {
39 return new ChannelOption<Object>(id, name);
40 }
41 };
42
43
44
45
46 @SuppressWarnings("unchecked")
47 public static <T> ChannelOption<T> valueOf(String name) {
48 return (ChannelOption<T>) pool.valueOf(name);
49 }
50
51
52
53
54 @SuppressWarnings("unchecked")
55 public static <T> ChannelOption<T> valueOf(Class<?> firstNameComponent, String secondNameComponent) {
56 return (ChannelOption<T>) pool.valueOf(firstNameComponent, secondNameComponent);
57 }
58
59
60
61
62 public static boolean exists(String name) {
63 return pool.exists(name);
64 }
65
66
67
68
69
70
71
72 @Deprecated
73 @SuppressWarnings("unchecked")
74 public static <T> ChannelOption<T> newInstance(String name) {
75 return (ChannelOption<T>) pool.newInstance(name);
76 }
77
78 public static final ChannelOption<ByteBufAllocator> ALLOCATOR = valueOf("ALLOCATOR");
79 public static final ChannelOption<RecvByteBufAllocator> RCVBUF_ALLOCATOR = valueOf("RCVBUF_ALLOCATOR");
80 public static final ChannelOption<MessageSizeEstimator> MESSAGE_SIZE_ESTIMATOR = valueOf("MESSAGE_SIZE_ESTIMATOR");
81
82 public static final ChannelOption<Integer> CONNECT_TIMEOUT_MILLIS = valueOf("CONNECT_TIMEOUT_MILLIS");
83
84
85
86
87 @Deprecated
88 public static final ChannelOption<Integer> MAX_MESSAGES_PER_READ = valueOf("MAX_MESSAGES_PER_READ");
89 public static final ChannelOption<Integer> MAX_MESSAGES_PER_WRITE = valueOf("MAX_MESSAGES_PER_WRITE");
90
91 public static final ChannelOption<Integer> WRITE_SPIN_COUNT = valueOf("WRITE_SPIN_COUNT");
92
93
94
95 @Deprecated
96 public static final ChannelOption<Integer> WRITE_BUFFER_HIGH_WATER_MARK = valueOf("WRITE_BUFFER_HIGH_WATER_MARK");
97
98
99
100 @Deprecated
101 public static final ChannelOption<Integer> WRITE_BUFFER_LOW_WATER_MARK = valueOf("WRITE_BUFFER_LOW_WATER_MARK");
102 public static final ChannelOption<WriteBufferWaterMark> WRITE_BUFFER_WATER_MARK =
103 valueOf("WRITE_BUFFER_WATER_MARK");
104
105 public static final ChannelOption<Boolean> ALLOW_HALF_CLOSURE = valueOf("ALLOW_HALF_CLOSURE");
106 public static final ChannelOption<Boolean> AUTO_READ = valueOf("AUTO_READ");
107
108
109
110
111
112 public static final ChannelOption<Boolean> AUTO_CLOSE = valueOf("AUTO_CLOSE");
113
114 public static final ChannelOption<Boolean> SO_BROADCAST = valueOf("SO_BROADCAST");
115 public static final ChannelOption<Boolean> SO_KEEPALIVE = valueOf("SO_KEEPALIVE");
116 public static final ChannelOption<Integer> SO_SNDBUF = valueOf("SO_SNDBUF");
117 public static final ChannelOption<Integer> SO_RCVBUF = valueOf("SO_RCVBUF");
118 public static final ChannelOption<Boolean> SO_REUSEADDR = valueOf("SO_REUSEADDR");
119 public static final ChannelOption<Integer> SO_LINGER = valueOf("SO_LINGER");
120 public static final ChannelOption<Integer> SO_BACKLOG = valueOf("SO_BACKLOG");
121 public static final ChannelOption<Integer> SO_TIMEOUT = valueOf("SO_TIMEOUT");
122
123 public static final ChannelOption<Integer> IP_TOS = valueOf("IP_TOS");
124 public static final ChannelOption<InetAddress> IP_MULTICAST_ADDR = valueOf("IP_MULTICAST_ADDR");
125 public static final ChannelOption<NetworkInterface> IP_MULTICAST_IF = valueOf("IP_MULTICAST_IF");
126 public static final ChannelOption<Integer> IP_MULTICAST_TTL = valueOf("IP_MULTICAST_TTL");
127 public static final ChannelOption<Boolean> IP_MULTICAST_LOOP_DISABLED = valueOf("IP_MULTICAST_LOOP_DISABLED");
128
129 public static final ChannelOption<Boolean> TCP_NODELAY = valueOf("TCP_NODELAY");
130
131
132
133 public static final ChannelOption<Boolean> TCP_FASTOPEN_CONNECT = valueOf("TCP_FASTOPEN_CONNECT");
134
135
136
137
138 public static final ChannelOption<Integer> TCP_FASTOPEN = valueOf(ChannelOption.class, "TCP_FASTOPEN");
139
140 @Deprecated
141 public static final ChannelOption<Boolean> DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION =
142 valueOf("DATAGRAM_CHANNEL_ACTIVE_ON_REGISTRATION");
143
144 public static final ChannelOption<Boolean> SINGLE_EVENTEXECUTOR_PER_GROUP =
145 valueOf("SINGLE_EVENTEXECUTOR_PER_GROUP");
146
147
148
149
150 private ChannelOption(int id, String name) {
151 super(id, name);
152 }
153
154 @Deprecated
155 protected ChannelOption(String name) {
156 this(pool.nextId(), name);
157 }
158
159
160
161
162
163 public void validate(T value) {
164 ObjectUtil.checkNotNull(value, "value");
165 }
166 }