Mercurial Hosting > luan
annotate src/org/eclipse/jetty/server/nio/SelectChannelConnector.java @ 918:7b62446899c6
remove unused states in AsyncContinuation
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Sun, 09 Oct 2016 03:37:53 -0600 |
parents | 54308d65265a |
children | 0541b6034003 |
rev | line source |
---|---|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
1 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
2 // ======================================================================== |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
3 // Copyright (c) 1995-2014 Mort Bay Consulting Pty. Ltd. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
4 // ------------------------------------------------------------------------ |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
5 // All rights reserved. This program and the accompanying materials |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
6 // are made available under the terms of the Eclipse Public License v1.0 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
7 // and Apache License v2.0 which accompanies this distribution. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
8 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
9 // The Eclipse Public License is available at |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
10 // http://www.eclipse.org/legal/epl-v10.html |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
11 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
12 // The Apache License v2.0 is available at |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
13 // http://www.opensource.org/licenses/apache2.0.php |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
14 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
15 // You may elect to redistribute this code under either of these licenses. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
16 // ======================================================================== |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
17 // |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
18 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
19 package org.eclipse.jetty.server.nio; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
20 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
21 import java.io.IOException; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
22 import java.net.InetSocketAddress; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
23 import java.net.Socket; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
24 import java.nio.channels.SelectionKey; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
25 import java.nio.channels.ServerSocketChannel; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
26 import java.nio.channels.SocketChannel; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
27 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
28 import org.eclipse.jetty.continuation.Continuation; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
29 import org.eclipse.jetty.io.AsyncEndPoint; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
30 import org.eclipse.jetty.io.ConnectedEndPoint; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
31 import org.eclipse.jetty.io.Connection; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
32 import org.eclipse.jetty.io.EndPoint; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
33 import org.eclipse.jetty.io.nio.AsyncConnection; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
34 import org.eclipse.jetty.io.nio.SelectChannelEndPoint; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
35 import org.eclipse.jetty.io.nio.SelectorManager; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
36 import org.eclipse.jetty.io.nio.SelectorManager.SelectSet; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
37 import org.eclipse.jetty.server.AsyncHttpConnection; |
907
bc4e299de953
remove AbstractNIOConnector
Franklin Schmidt <fschmidt@gmail.com>
parents:
906
diff
changeset
|
38 import org.eclipse.jetty.server.Connector; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
39 import org.eclipse.jetty.server.Request; |
887
df84a1741687
make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents:
865
diff
changeset
|
40 import org.eclipse.jetty.server.Server; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
41 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
42 /* ------------------------------------------------------------------------------- */ |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
43 /** |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
44 * Selecting NIO connector. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
45 * <p> |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
46 * This connector uses efficient NIO buffers with a non blocking threading model. Direct NIO buffers |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
47 * are used and threads are only allocated to connections with requests. Synchronization is used to |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
48 * simulate blocking for the servlet API, and any unflushed content at the end of request handling |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
49 * is written asynchronously. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
50 * </p> |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
51 * <p> |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
52 * This connector is best used when there are a many connections that have idle periods. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
53 * </p> |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
54 * <p> |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
55 * When used with {@link org.eclipse.jetty.continuation.Continuation}, threadless waits are supported. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
56 * If a filter or servlet returns after calling {@link Continuation#suspend()} or when a |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
57 * runtime exception is thrown from a call to {@link Continuation#undispatch()}, Jetty will |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
58 * will not send a response to the client. Instead the thread is released and the Continuation is |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
59 * placed on the timer queue. If the Continuation timeout expires, or it's |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
60 * resume method is called, then the request is again allocated a thread and the request is retried. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
61 * The limitation of this approach is that request content is not available on the retried request, |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
62 * thus if possible it should be read after the continuation or saved as a request attribute or as the |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
63 * associated object of the Continuation instance. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
64 * </p> |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
65 * |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
66 * @org.apache.xbean.XBean element="nioConnector" description="Creates an NIO based socket connector" |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
67 */ |
907
bc4e299de953
remove AbstractNIOConnector
Franklin Schmidt <fschmidt@gmail.com>
parents:
906
diff
changeset
|
68 public class SelectChannelConnector extends Connector |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
69 { |
864
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
70 private final SelectorManager _manager = new ConnectorSelectorManager(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
71 |
887
df84a1741687
make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents:
865
diff
changeset
|
72 public SelectChannelConnector(Server server,int port) |
864
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
73 { |
887
df84a1741687
make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents:
865
diff
changeset
|
74 super(server,port); |
864
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
75 _manager.setMaxIdleTime(getMaxIdleTime()); |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
76 addBean(_manager,true); |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
77 setAcceptors(Math.max(1,(Runtime.getRuntime().availableProcessors()+3)/4)); |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
78 } |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
79 |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
80 @Override |
906 | 81 public final void accept() throws IOException |
864
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
82 { |
906 | 83 ServerSocketChannel server = _acceptChannel; |
864
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
84 |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
85 if (server!=null && server.isOpen() && _manager.isStarted()) |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
86 { |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
87 SocketChannel channel = server.accept(); |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
88 channel.configureBlocking(false); |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
89 Socket socket = channel.socket(); |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
90 configure(socket); |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
91 _manager.register(channel); |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
92 } |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
93 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
94 |
864
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
95 @Override |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
96 public void customize(EndPoint endpoint, Request request) throws IOException |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
97 { |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
98 request.setTimeStamp(System.currentTimeMillis()); |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
99 endpoint.setMaxIdleTime(_maxIdleTime); |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
100 super.customize(endpoint, request); |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
101 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
102 |
864
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
103 @Override |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
104 public void persist(EndPoint endpoint) throws IOException |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
105 { |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
106 AsyncEndPoint aEndp = ((AsyncEndPoint)endpoint); |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
107 aEndp.setCheckForIdle(true); |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
108 super.persist(endpoint); |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
109 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
110 |
864
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
111 @Override |
909 | 112 protected synchronized void doStart() throws Exception |
864
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
113 { |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
114 _manager.setSelectSets(getAcceptors()); |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
115 _manager.setMaxIdleTime(getMaxIdleTime()); |
913 | 116 _manager.setLowResourcesConnections(0); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
117 |
909 | 118 if (_acceptChannel == null) |
119 { | |
120 // Create a new server socket | |
121 _acceptChannel = ServerSocketChannel.open(); | |
122 // Set to blocking mode | |
123 _acceptChannel.configureBlocking(true); | |
124 | |
125 // Bind the server socket to the local host and port | |
126 _acceptChannel.socket().setReuseAddress(true); | |
127 InetSocketAddress addr = getHost()==null?new InetSocketAddress(port):new InetSocketAddress(getHost(),port); | |
128 _acceptChannel.bind(addr); | |
129 if( _acceptChannel.socket().getLocalPort() != port) | |
130 throw new IOException("Server channel not bound"); | |
131 } | |
132 | |
864
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
133 super.doStart(); |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
134 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
135 |
864
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
136 protected SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectSet selectSet, SelectionKey key) throws IOException |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
137 { |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
138 SelectChannelEndPoint endp= new SelectChannelEndPoint(channel,selectSet,key, SelectChannelConnector.this._maxIdleTime); |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
139 endp.setConnection(selectSet.getManager().newConnection(channel,endp, key.attachment())); |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
140 return endp; |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
141 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
142 |
864
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
143 protected void endPointClosed(SelectChannelEndPoint endpoint) |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
144 { |
903
94f5d8a62385
remove connectionClosed()
Franklin Schmidt <fschmidt@gmail.com>
parents:
902
diff
changeset
|
145 endpoint.getConnection().onClose(); |
864
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
146 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
147 |
864
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
148 protected AsyncConnection newConnection(SocketChannel channel,final AsyncEndPoint endpoint) |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
149 { |
887
df84a1741687
make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents:
865
diff
changeset
|
150 return new AsyncHttpConnection(SelectChannelConnector.this,endpoint,server); |
864
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
151 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
152 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
153 |
864
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
154 private final class ConnectorSelectorManager extends SelectorManager |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
155 { |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
156 @Override |
865 | 157 public void execute(Runnable task) |
864
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
158 { |
887
df84a1741687
make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents:
865
diff
changeset
|
159 server.threadPool.execute(task); |
864
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
160 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
161 |
864
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
162 @Override |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
163 protected void endPointClosed(final SelectChannelEndPoint endpoint) |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
164 { |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
165 SelectChannelConnector.this.endPointClosed(endpoint); |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
166 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
167 |
864
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
168 @Override |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
169 public AsyncConnection newConnection(SocketChannel channel,AsyncEndPoint endpoint, Object attachment) |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
170 { |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
171 return SelectChannelConnector.this.newConnection(channel,endpoint); |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
172 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
173 |
864
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
174 @Override |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
175 protected SelectChannelEndPoint newEndPoint(SocketChannel channel, SelectSet selectSet, SelectionKey sKey) throws IOException |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
176 { |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
177 return SelectChannelConnector.this.newEndPoint(channel,selectSet,sKey); |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
178 } |
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
179 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
180 } |