Mercurial Hosting > luan
annotate src/org/eclipse/jetty/server/Server.java @ 1020:6be43ef1eb96
HttpHeaderValues uses StringCache
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Mon, 31 Oct 2016 22:24:41 -0600 |
parents | 3fa54d9d19cd |
children |
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; |
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; |
876
2efdb98f3543
use just one fixed Connector in Server
Franklin Schmidt <fschmidt@gmail.com>
parents:
875
diff
changeset
|
23 import java.util.Collections; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
24 import java.util.Enumeration; |
886
0d876a03ab0b
add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents:
884
diff
changeset
|
25 import java.util.List; |
0d876a03ab0b
add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents:
884
diff
changeset
|
26 import java.util.ArrayList; |
865 | 27 import java.util.concurrent.LinkedBlockingQueue; |
28 import java.util.concurrent.ThreadPoolExecutor; | |
29 import java.util.concurrent.TimeUnit; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
30 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
31 import javax.servlet.ServletException; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
32 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
33 import org.eclipse.jetty.http.HttpURI; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
34 import org.eclipse.jetty.server.handler.HandlerWrapper; |
975
53b3f7d9714c
simplify BlockingChannelConnector
Franklin Schmidt <fschmidt@gmail.com>
parents:
929
diff
changeset
|
35 import org.eclipse.jetty.server.nio.BlockingChannelConnector; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
36 import org.eclipse.jetty.server.nio.SelectChannelConnector; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
37 import org.eclipse.jetty.util.LazyList; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
38 import org.eclipse.jetty.util.MultiException; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
39 import org.eclipse.jetty.util.TypeUtil; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
40 import org.eclipse.jetty.util.URIUtil; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
41 import org.eclipse.jetty.util.component.Destroyable; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
42 import org.eclipse.jetty.util.component.LifeCycle; |
820
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
812
diff
changeset
|
43 import org.slf4j.Logger; |
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
812
diff
changeset
|
44 import org.slf4j.LoggerFactory; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
45 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
46 /* ------------------------------------------------------------ */ |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
47 /** Jetty HTTP Servlet Server. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
48 * This class is the main class for the Jetty HTTP Servlet server. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
49 * It aggregates Connectors (HTTP request receivers) and request Handlers. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
50 * The server is itself a handler and a ThreadPool. Connectors use the ThreadPool methods |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
51 * to run jobs that will eventually call the handle method. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
52 * |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
53 * @org.apache.xbean.XBean description="Creates an embedded Jetty web server" |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
54 */ |
987
af8742d31bca
remove Server._attributes
Franklin Schmidt <fschmidt@gmail.com>
parents:
975
diff
changeset
|
55 public final class Server extends HandlerWrapper |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
56 { |
820
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
812
diff
changeset
|
57 private static final Logger LOG = LoggerFactory.getLogger(Server.class); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
58 |
884
cb78ee27b0e0
remove Server.getVersion()
Franklin Schmidt <fschmidt@gmail.com>
parents:
883
diff
changeset
|
59 public static final String version = "8"; |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
60 |
887
df84a1741687
make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents:
886
diff
changeset
|
61 public final ThreadPoolExecutor threadPool = new ThreadPoolExecutor(256, 256, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()); |
df84a1741687
make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents:
886
diff
changeset
|
62 final List<Connector> connectors = new ArrayList<Connector>(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
63 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
64 |
887
df84a1741687
make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents:
886
diff
changeset
|
65 public Server() { |
df84a1741687
make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents:
886
diff
changeset
|
66 setServer(this); |
df84a1741687
make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents:
886
diff
changeset
|
67 } |
df84a1741687
make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents:
886
diff
changeset
|
68 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
69 public Server(int port) |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
70 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
71 setServer(this); |
1004
3fa54d9d19cd
better handling of BindException
Franklin Schmidt <fschmidt@gmail.com>
parents:
1001
diff
changeset
|
72 // new SelectChannelConnector(this,port); |
3fa54d9d19cd
better handling of BindException
Franklin Schmidt <fschmidt@gmail.com>
parents:
1001
diff
changeset
|
73 new BlockingChannelConnector(this,port); |
886
0d876a03ab0b
add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents:
884
diff
changeset
|
74 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
75 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
76 @Override |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
77 protected void doStart() throws Exception |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
78 { |
884
cb78ee27b0e0
remove Server.getVersion()
Franklin Schmidt <fschmidt@gmail.com>
parents:
883
diff
changeset
|
79 LOG.info("jetty-"+version); |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
80 |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
81 MultiException mex=new MultiException(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
82 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
83 try |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
84 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
85 super.doStart(); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
86 } |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
87 catch(Throwable e) |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
88 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
89 mex.add(e); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
90 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
91 |
886
0d876a03ab0b
add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents:
884
diff
changeset
|
92 if (mex.size()==0) { |
0d876a03ab0b
add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents:
884
diff
changeset
|
93 for( Connector connector : connectors ) { |
0d876a03ab0b
add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents:
884
diff
changeset
|
94 try{connector.start();} |
0d876a03ab0b
add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents:
884
diff
changeset
|
95 catch(Throwable e) |
0d876a03ab0b
add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents:
884
diff
changeset
|
96 { |
0d876a03ab0b
add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents:
884
diff
changeset
|
97 mex.add(e); |
0d876a03ab0b
add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents:
884
diff
changeset
|
98 } |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
99 } |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
100 } |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
101 mex.ifExceptionThrow(); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
102 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
103 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
104 @Override |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
105 protected void doStop() throws Exception |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
106 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
107 MultiException mex=new MultiException(); |
880
00b3bd6e0ada
remove Server._graceful
Franklin Schmidt <fschmidt@gmail.com>
parents:
879
diff
changeset
|
108 /* |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
109 if (_graceful>0) |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
110 { |
876
2efdb98f3543
use just one fixed Connector in Server
Franklin Schmidt <fschmidt@gmail.com>
parents:
875
diff
changeset
|
111 LOG.info("Graceful shutdown {}",connector); |
2efdb98f3543
use just one fixed Connector in Server
Franklin Schmidt <fschmidt@gmail.com>
parents:
875
diff
changeset
|
112 try{connector.close();}catch(Throwable e){mex.add(e);} |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
113 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
114 Handler[] contexts = getChildHandlersByClass(Graceful.class); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
115 for (int c=0;c<contexts.length;c++) |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
116 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
117 Graceful context=(Graceful)contexts[c]; |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
118 LOG.info("Graceful shutdown {}",context); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
119 context.setShutdown(true); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
120 } |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
121 Thread.sleep(_graceful); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
122 } |
880
00b3bd6e0ada
remove Server._graceful
Franklin Schmidt <fschmidt@gmail.com>
parents:
879
diff
changeset
|
123 */ |
886
0d876a03ab0b
add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents:
884
diff
changeset
|
124 for( Connector connector : connectors ) { |
0d876a03ab0b
add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents:
884
diff
changeset
|
125 try{connector.stop();}catch(Throwable e){mex.add(e);} |
0d876a03ab0b
add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents:
884
diff
changeset
|
126 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
127 |
875
b9aa175d9a29
remove Server.getThreadPool()
Franklin Schmidt <fschmidt@gmail.com>
parents:
867
diff
changeset
|
128 threadPool.shutdownNow(); |
867 | 129 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
130 try {super.doStop(); } catch(Throwable e) { mex.add(e);} |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
131 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
132 mex.ifExceptionThrow(); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
133 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
134 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
135 /* ------------------------------------------------------------ */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
136 /* Handle a request from a connection. |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
137 * Called to handle a request on the connection when either the header has been received, |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
138 * or after the entire request has been received (for short requests of known length), or |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
139 * on the dispatch of an async request. |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
140 */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
141 public void handle(AbstractHttpConnection connection) throws IOException, ServletException |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
142 { |
997 | 143 final String target = connection.getRequest().getPathInfo(); |
144 final Request request = connection.getRequest(); | |
145 final Response response = connection.getResponse(); | |
1000 | 146 handle(target, request, response); |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
147 } |
991
688c39c50ee3
simplify ContextHandler
Franklin Schmidt <fschmidt@gmail.com>
parents:
987
diff
changeset
|
148 /* |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
149 public void join() throws InterruptedException |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
150 { |
875
b9aa175d9a29
remove Server.getThreadPool()
Franklin Schmidt <fschmidt@gmail.com>
parents:
867
diff
changeset
|
151 threadPool.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS); |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
152 } |
991
688c39c50ee3
simplify ContextHandler
Franklin Schmidt <fschmidt@gmail.com>
parents:
987
diff
changeset
|
153 */ |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
154 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
155 @Override |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
156 public void dump(Appendable out,String indent) throws IOException |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
157 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
158 dumpThis(out); |
886
0d876a03ab0b
add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents:
884
diff
changeset
|
159 dump(out,indent,TypeUtil.asList(getHandlers()),getBeans(),connectors); |
812
700317ba03ad
remove SessionIdManager
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 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
162 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
163 /* ------------------------------------------------------------ */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
164 /* A handler that can be gracefully shutdown. |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
165 * Called by doStop if a {@link #setGracefulShutdown} period is set. |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
166 * TODO move this somewhere better |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
167 */ |
995
0eba8f555c19
remove Server.Graceful
Franklin Schmidt <fschmidt@gmail.com>
parents:
991
diff
changeset
|
168 /* |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
169 public interface Graceful extends Handler |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
170 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
171 public void setShutdown(boolean shutdown); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
172 } |
995
0eba8f555c19
remove Server.Graceful
Franklin Schmidt <fschmidt@gmail.com>
parents:
991
diff
changeset
|
173 */ |
865 | 174 |
175 public final boolean isLowOnThreads() | |
176 { | |
177 // getActiveCount() locks the thread pool, so execute it last | |
875
b9aa175d9a29
remove Server.getThreadPool()
Franklin Schmidt <fschmidt@gmail.com>
parents:
867
diff
changeset
|
178 return threadPool.getPoolSize() == threadPool.getMaximumPoolSize() && |
b9aa175d9a29
remove Server.getThreadPool()
Franklin Schmidt <fschmidt@gmail.com>
parents:
867
diff
changeset
|
179 threadPool.getQueue().size() >= threadPool.getPoolSize() - threadPool.getActiveCount(); |
865 | 180 } |
181 | |
182 | |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
183 public static void main(String...args) throws Exception |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
184 { |
884
cb78ee27b0e0
remove Server.getVersion()
Franklin Schmidt <fschmidt@gmail.com>
parents:
883
diff
changeset
|
185 System.err.println(version); |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
186 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
187 } |