comparison src/org/eclipse/jetty/server/Connector.java @ 996:d9cfec64899c

simplify Connector
author Franklin Schmidt <fschmidt@gmail.com>
date Tue, 18 Oct 2016 21:22:53 -0600
parents 5ee36654b383
children 39154cfa58e4
comparison
equal deleted inserted replaced
995:0eba8f555c19 996:d9cfec64899c
69 protected final HttpBuffersImpl _buffers = new HttpBuffersImpl(); 69 protected final HttpBuffersImpl _buffers = new HttpBuffersImpl();
70 70
71 // from child classes 71 // from child classes
72 protected transient ServerSocketChannel _acceptChannel; 72 protected transient ServerSocketChannel _acceptChannel;
73 73
74 public Connector(Server server,int port) { 74 protected Connector(Server server,int port) {
75 this.server = server; 75 this.server = server;
76 this.port = port; 76 this.port = port;
77 server.connectors.add(this); 77 server.connectors.add(this);
78 addBean(_buffers); 78 addBean(_buffers);
79 _buffers.setRequestBufferType(Type.DIRECT); 79 _buffers.setRequestBufferType(Type.DIRECT);
80 _buffers.setRequestHeaderType(Type.INDIRECT); 80 _buffers.setRequestHeaderType(Type.INDIRECT);
81 _buffers.setResponseBufferType(Type.DIRECT); 81 _buffers.setResponseBufferType(Type.DIRECT);
82 _buffers.setResponseHeaderType(Type.INDIRECT); 82 _buffers.setResponseHeaderType(Type.INDIRECT);
83 } 83 }
84 84
85 public void setHost(String host) 85 public final void setHost(String host)
86 { 86 {
87 _host = host; 87 _host = host;
88 } 88 }
89 89
90 public String getHost() 90 public final String getHost()
91 { 91 {
92 return _host; 92 return _host;
93 } 93 }
94 94
95 public int getMaxIdleTime() 95 public final int getMaxIdleTime()
96 { 96 {
97 return _maxIdleTime; 97 return _maxIdleTime;
98 } 98 }
99 99
100 /* ------------------------------------------------------------ */ 100 /* ------------------------------------------------------------ */
122 { 122 {
123 _maxIdleTime = maxIdleTime; 123 _maxIdleTime = maxIdleTime;
124 } 124 }
125 */ 125 */
126 126
127 /* ------------------------------------------------------------ */ 127 public final int getSoLingerTime()
128 /**
129 * @return Returns the soLingerTime.
130 */
131 public int getSoLingerTime()
132 { 128 {
133 return _soLingerTime; 129 return _soLingerTime;
134 } 130 }
135 131
136 /* ------------------------------------------------------------ */ 132 /* ------------------------------------------------------------ */
137 /** 133 /**
138 * @param soLingerTime 134 * @param soLingerTime
139 * The soLingerTime to set or -1 to disable. 135 * The soLingerTime to set or -1 to disable.
140 */ 136 */
141 public void setSoLingerTime(int soLingerTime) 137 public final void setSoLingerTime(int soLingerTime)
142 { 138 {
143 _soLingerTime = soLingerTime; 139 _soLingerTime = soLingerTime;
144 } 140 }
145 141
146 @Override 142 @Override
182 socket.setSoLinger(true,_soLingerTime / 1000); 178 socket.setSoLinger(true,_soLingerTime / 1000);
183 else 179 else
184 socket.setSoLinger(false,0); 180 socket.setSoLinger(false,0);
185 } 181 }
186 182
187 public void customize(EndPoint endpoint, Request request) throws IOException 183 public abstract void customize(EndPoint endpoint, Request request) throws IOException;
188 {
189 }
190 184
191 public boolean isConfidential() 185 public boolean isConfidential()
192 { 186 {
193 return false; 187 return false;
194 } 188 }
195 189
196 protected abstract void accept() throws IOException, InterruptedException; 190 protected abstract void accept() throws IOException, InterruptedException;
197 191
198 public void stopAccept(int acceptorID) throws Exception 192 @Override
199 { 193 public final int getRequestBufferSize()
200 }
201
202 public int getRequestBufferSize()
203 { 194 {
204 return _buffers.getRequestBufferSize(); 195 return _buffers.getRequestBufferSize();
205 } 196 }
206 197
207 public void setRequestBufferSize(int requestBufferSize) 198 @Override
199 public final void setRequestBufferSize(int requestBufferSize)
208 { 200 {
209 _buffers.setRequestBufferSize(requestBufferSize); 201 _buffers.setRequestBufferSize(requestBufferSize);
210 } 202 }
211 203
212 public int getRequestHeaderSize() 204 @Override
205 public final int getRequestHeaderSize()
213 { 206 {
214 return _buffers.getRequestHeaderSize(); 207 return _buffers.getRequestHeaderSize();
215 } 208 }
216 209
217 public void setRequestHeaderSize(int requestHeaderSize) 210 @Override
211 public final void setRequestHeaderSize(int requestHeaderSize)
218 { 212 {
219 _buffers.setRequestHeaderSize(requestHeaderSize); 213 _buffers.setRequestHeaderSize(requestHeaderSize);
220 } 214 }
221 215
222 public int getResponseBufferSize() 216 @Override
217 public final int getResponseBufferSize()
223 { 218 {
224 return _buffers.getResponseBufferSize(); 219 return _buffers.getResponseBufferSize();
225 } 220 }
226 221
227 public void setResponseBufferSize(int responseBufferSize) 222 @Override
223 public final void setResponseBufferSize(int responseBufferSize)
228 { 224 {
229 _buffers.setResponseBufferSize(responseBufferSize); 225 _buffers.setResponseBufferSize(responseBufferSize);
230 } 226 }
231 227
232 public int getResponseHeaderSize() 228 @Override
229 public final int getResponseHeaderSize()
233 { 230 {
234 return _buffers.getResponseHeaderSize(); 231 return _buffers.getResponseHeaderSize();
235 } 232 }
236 233
237 public void setResponseHeaderSize(int responseHeaderSize) 234 @Override
235 public final void setResponseHeaderSize(int responseHeaderSize)
238 { 236 {
239 _buffers.setResponseHeaderSize(responseHeaderSize); 237 _buffers.setResponseHeaderSize(responseHeaderSize);
240 } 238 }
241 239
242 public Type getRequestBufferType() 240 @Override
241 public final Type getRequestBufferType()
243 { 242 {
244 return _buffers.getRequestBufferType(); 243 return _buffers.getRequestBufferType();
245 } 244 }
246 245
247 public Type getRequestHeaderType() 246 @Override
247 public final Type getRequestHeaderType()
248 { 248 {
249 return _buffers.getRequestHeaderType(); 249 return _buffers.getRequestHeaderType();
250 } 250 }
251 251
252 public Type getResponseBufferType() 252 @Override
253 public final Type getResponseBufferType()
253 { 254 {
254 return _buffers.getResponseBufferType(); 255 return _buffers.getResponseBufferType();
255 } 256 }
256 257
257 public Type getResponseHeaderType() 258 @Override
259 public final Type getResponseHeaderType()
258 { 260 {
259 return _buffers.getResponseHeaderType(); 261 return _buffers.getResponseHeaderType();
260 } 262 }
261 263
262 public void setRequestBuffers(Buffers requestBuffers) 264 @Override
265 public final void setRequestBuffers(Buffers requestBuffers)
263 { 266 {
264 _buffers.setRequestBuffers(requestBuffers); 267 _buffers.setRequestBuffers(requestBuffers);
265 } 268 }
266 269
267 public void setResponseBuffers(Buffers responseBuffers) 270 @Override
271 public final void setResponseBuffers(Buffers responseBuffers)
268 { 272 {
269 _buffers.setResponseBuffers(responseBuffers); 273 _buffers.setResponseBuffers(responseBuffers);
270 } 274 }
271 275
272 public Buffers getRequestBuffers() 276 @Override
277 public final Buffers getRequestBuffers()
273 { 278 {
274 return _buffers.getRequestBuffers(); 279 return _buffers.getRequestBuffers();
275 } 280 }
276 281
277 public Buffers getResponseBuffers() 282 @Override
283 public final Buffers getResponseBuffers()
278 { 284 {
279 return _buffers.getResponseBuffers(); 285 return _buffers.getResponseBuffers();
280 } 286 }
281 287
282 public int getMaxBuffers() 288 @Override
289 public final int getMaxBuffers()
283 { 290 {
284 return _buffers.getMaxBuffers(); 291 return _buffers.getMaxBuffers();
285 } 292 }
286 293
287 @Override 294 @Override
292 getHost()==null?"0.0.0.0":getHost(), 299 getHost()==null?"0.0.0.0":getHost(),
293 port); 300 port);
294 } 301 }
295 302
296 303
304 @Override
297 public void run() 305 public void run()
298 { 306 {
299 Thread current = Thread.currentThread(); 307 Thread current = Thread.currentThread();
300 String name = current.getName(); 308 String name = current.getName();
301 current.setName(name + " Acceptor" + " " + Connector.this); 309 current.setName(name + " Acceptor" + " " + Connector.this);
331 { 339 {
332 current.setName(name); 340 current.setName(name);
333 } 341 }
334 } 342 }
335 343
336 public String getName() 344 public final String getName()
337 { 345 {
338 if (_name == null) 346 if (_name == null)
339 _name = (getHost() == null?"0.0.0.0":getHost()) + ":" + port; 347 _name = (getHost() == null?"0.0.0.0":getHost()) + ":" + port;
340 return _name; 348 return _name;
341 } 349 }
342 350
343 public final boolean isLowResources()
344 {
345 return server.isLowOnThreads();
346 }
347
348 351
349 // from AbstractNIOConnector 352 // from AbstractNIOConnector
350 353
351 /* ------------------------------------------------------------------------------- */ 354 public final boolean getUseDirectBuffers()
352 public boolean getUseDirectBuffers()
353 { 355 {
354 return getRequestBufferType()==Type.DIRECT; 356 return getRequestBufferType()==Type.DIRECT;
355 } 357 }
356 358
357 /* ------------------------------------------------------------------------------- */ 359 /* ------------------------------------------------------------------------------- */
358 /** 360 /**
359 * @param direct If True (the default), the connector can use NIO direct buffers. 361 * @param direct If True (the default), the connector can use NIO direct buffers.
360 * Some JVMs have memory management issues (bugs) with direct buffers. 362 * Some JVMs have memory management issues (bugs) with direct buffers.
361 */ 363 */
362 public void setUseDirectBuffers(boolean direct) 364 public final void setUseDirectBuffers(boolean direct)
363 { 365 {
364 _buffers.setRequestBufferType(direct?Type.DIRECT:Type.INDIRECT); 366 _buffers.setRequestBufferType(direct?Type.DIRECT:Type.INDIRECT);
365 _buffers.setResponseBufferType(direct?Type.DIRECT:Type.INDIRECT); 367 _buffers.setResponseBufferType(direct?Type.DIRECT:Type.INDIRECT);
366 } 368 }
367 369
368
369 // from child classes
370
371 } 370 }