1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16 package io.netty.channel.socket.oio;
17
18 import io.netty.buffer.ByteBufAllocator;
19 import io.netty.channel.ChannelException;
20 import io.netty.channel.ChannelOption;
21 import io.netty.channel.MessageSizeEstimator;
22 import io.netty.channel.PreferHeapByteBufAllocator;
23 import io.netty.channel.RecvByteBufAllocator;
24 import io.netty.channel.WriteBufferWaterMark;
25 import io.netty.channel.socket.DefaultSocketChannelConfig;
26 import io.netty.channel.socket.SocketChannel;
27
28 import java.io.IOException;
29 import java.net.Socket;
30 import java.util.Map;
31
32 import static io.netty.channel.ChannelOption.*;
33
34
35
36
37
38
39 @Deprecated
40 public class DefaultOioSocketChannelConfig extends DefaultSocketChannelConfig implements OioSocketChannelConfig {
41 @Deprecated
42 public DefaultOioSocketChannelConfig(SocketChannel channel, Socket javaSocket) {
43 super(channel, javaSocket);
44 setAllocator(new PreferHeapByteBufAllocator(getAllocator()));
45 }
46
47 DefaultOioSocketChannelConfig(OioSocketChannel channel, Socket javaSocket) {
48 super(channel, javaSocket);
49 setAllocator(new PreferHeapByteBufAllocator(getAllocator()));
50 }
51
52 @Override
53 public Map<ChannelOption<?>, Object> getOptions() {
54 return getOptions(
55 super.getOptions(), SO_TIMEOUT);
56 }
57
58 @SuppressWarnings("unchecked")
59 @Override
60 public <T> T getOption(ChannelOption<T> option) {
61 if (option == SO_TIMEOUT) {
62 return (T) Integer.valueOf(getSoTimeout());
63 }
64 return super.getOption(option);
65 }
66
67 @Override
68 public <T> boolean setOption(ChannelOption<T> option, T value) {
69 validate(option, value);
70
71 if (option == SO_TIMEOUT) {
72 setSoTimeout((Integer) value);
73 } else {
74 return super.setOption(option, value);
75 }
76 return true;
77 }
78
79 @Override
80 public OioSocketChannelConfig setSoTimeout(int timeout) {
81 try {
82 javaSocket.setSoTimeout(timeout);
83 } catch (IOException e) {
84 throw new ChannelException(e);
85 }
86 return this;
87 }
88
89 @Override
90 public int getSoTimeout() {
91 try {
92 return javaSocket.getSoTimeout();
93 } catch (IOException e) {
94 throw new ChannelException(e);
95 }
96 }
97
98 @Override
99 public OioSocketChannelConfig setTcpNoDelay(boolean tcpNoDelay) {
100 super.setTcpNoDelay(tcpNoDelay);
101 return this;
102 }
103
104 @Override
105 public OioSocketChannelConfig setSoLinger(int soLinger) {
106 super.setSoLinger(soLinger);
107 return this;
108 }
109
110 @Override
111 public OioSocketChannelConfig setSendBufferSize(int sendBufferSize) {
112 super.setSendBufferSize(sendBufferSize);
113 return this;
114 }
115
116 @Override
117 public OioSocketChannelConfig setReceiveBufferSize(int receiveBufferSize) {
118 super.setReceiveBufferSize(receiveBufferSize);
119 return this;
120 }
121
122 @Override
123 public OioSocketChannelConfig setKeepAlive(boolean keepAlive) {
124 super.setKeepAlive(keepAlive);
125 return this;
126 }
127
128 @Override
129 public OioSocketChannelConfig setTrafficClass(int trafficClass) {
130 super.setTrafficClass(trafficClass);
131 return this;
132 }
133
134 @Override
135 public OioSocketChannelConfig setReuseAddress(boolean reuseAddress) {
136 super.setReuseAddress(reuseAddress);
137 return this;
138 }
139
140 @Override
141 public OioSocketChannelConfig setPerformancePreferences(int connectionTime, int latency, int bandwidth) {
142 super.setPerformancePreferences(connectionTime, latency, bandwidth);
143 return this;
144 }
145
146 @Override
147 public OioSocketChannelConfig setAllowHalfClosure(boolean allowHalfClosure) {
148 super.setAllowHalfClosure(allowHalfClosure);
149 return this;
150 }
151
152 @Override
153 public OioSocketChannelConfig setConnectTimeoutMillis(int connectTimeoutMillis) {
154 super.setConnectTimeoutMillis(connectTimeoutMillis);
155 return this;
156 }
157
158 @Override
159 @Deprecated
160 public OioSocketChannelConfig setMaxMessagesPerRead(int maxMessagesPerRead) {
161 super.setMaxMessagesPerRead(maxMessagesPerRead);
162 return this;
163 }
164
165 @Override
166 public OioSocketChannelConfig setWriteSpinCount(int writeSpinCount) {
167 super.setWriteSpinCount(writeSpinCount);
168 return this;
169 }
170
171 @Override
172 public OioSocketChannelConfig setAllocator(ByteBufAllocator allocator) {
173 super.setAllocator(allocator);
174 return this;
175 }
176
177 @Override
178 public OioSocketChannelConfig setRecvByteBufAllocator(RecvByteBufAllocator allocator) {
179 super.setRecvByteBufAllocator(allocator);
180 return this;
181 }
182
183 @Override
184 public OioSocketChannelConfig setAutoRead(boolean autoRead) {
185 super.setAutoRead(autoRead);
186 return this;
187 }
188
189 @Override
190 protected void autoReadCleared() {
191 if (channel instanceof OioSocketChannel) {
192 ((OioSocketChannel) channel).clearReadPending0();
193 }
194 }
195
196 @Override
197 public OioSocketChannelConfig setAutoClose(boolean autoClose) {
198 super.setAutoClose(autoClose);
199 return this;
200 }
201
202 @Override
203 public OioSocketChannelConfig setWriteBufferHighWaterMark(int writeBufferHighWaterMark) {
204 super.setWriteBufferHighWaterMark(writeBufferHighWaterMark);
205 return this;
206 }
207
208 @Override
209 public OioSocketChannelConfig setWriteBufferLowWaterMark(int writeBufferLowWaterMark) {
210 super.setWriteBufferLowWaterMark(writeBufferLowWaterMark);
211 return this;
212 }
213
214 @Override
215 public OioSocketChannelConfig setWriteBufferWaterMark(WriteBufferWaterMark writeBufferWaterMark) {
216 super.setWriteBufferWaterMark(writeBufferWaterMark);
217 return this;
218 }
219
220 @Override
221 public OioSocketChannelConfig setMessageSizeEstimator(MessageSizeEstimator estimator) {
222 super.setMessageSizeEstimator(estimator);
223 return this;
224 }
225 }