Mercurial Hosting > luan
annotate src/org/eclipse/jetty/server/Server.java @ 883:8c494fcd3d34
remove Server._dump*
author | Franklin Schmidt <fschmidt@gmail.com> |
---|---|
date | Tue, 04 Oct 2016 16:19:54 -0600 |
parents | d850a5e6ff15 |
children | cb78ee27b0e0 |
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; |
865 | 25 import java.util.concurrent.LinkedBlockingQueue; |
26 import java.util.concurrent.ThreadPoolExecutor; | |
27 import java.util.concurrent.TimeUnit; | |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
28 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
29 import javax.servlet.ServletException; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
30 import javax.servlet.http.HttpServletRequest; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
31 import javax.servlet.http.HttpServletResponse; |
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.HttpGenerator; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
34 import org.eclipse.jetty.http.HttpURI; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
35 import org.eclipse.jetty.server.handler.HandlerWrapper; |
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.Attributes; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
38 import org.eclipse.jetty.util.AttributesMap; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
39 import org.eclipse.jetty.util.LazyList; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
40 import org.eclipse.jetty.util.MultiException; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
41 import org.eclipse.jetty.util.TypeUtil; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
42 import org.eclipse.jetty.util.URIUtil; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
43 import org.eclipse.jetty.util.component.Destroyable; |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
44 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
|
45 import org.slf4j.Logger; |
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
812
diff
changeset
|
46 import org.slf4j.LoggerFactory; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
47 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
48 /* ------------------------------------------------------------ */ |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
49 /** Jetty HTTP Servlet Server. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
50 * 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
|
51 * It aggregates Connectors (HTTP request receivers) and request Handlers. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
52 * 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
|
53 * to run jobs that will eventually call the handle method. |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
54 * |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
55 * @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
|
56 */ |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
57 public class Server extends HandlerWrapper implements Attributes |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
58 { |
820
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
812
diff
changeset
|
59 private static final Logger LOG = LoggerFactory.getLogger(Server.class); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
60 |
864
e21ca9878a10
simplify ThreadPool use
Franklin Schmidt <fschmidt@gmail.com>
parents:
848
diff
changeset
|
61 private static final String __version = "8"; |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
62 |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
63 private final AttributesMap _attributes = new AttributesMap(); |
875
b9aa175d9a29
remove Server.getThreadPool()
Franklin Schmidt <fschmidt@gmail.com>
parents:
867
diff
changeset
|
64 public final ThreadPoolExecutor threadPool; |
876
2efdb98f3543
use just one fixed Connector in Server
Franklin Schmidt <fschmidt@gmail.com>
parents:
875
diff
changeset
|
65 public final Connector connector; |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
66 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
67 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
68 /* ------------------------------------------------------------ */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
69 /** Convenience constructor |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
70 * Creates server and a {@link SelectChannelConnector} at the passed port. |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
71 */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
72 public Server(int port) |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
73 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
74 setServer(this); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
75 |
876
2efdb98f3543
use just one fixed Connector in Server
Franklin Schmidt <fschmidt@gmail.com>
parents:
875
diff
changeset
|
76 connector = new SelectChannelConnector(); |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
77 connector.setPort(port); |
876
2efdb98f3543
use just one fixed Connector in Server
Franklin Schmidt <fschmidt@gmail.com>
parents:
875
diff
changeset
|
78 connector.setServer(this); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
79 |
875
b9aa175d9a29
remove Server.getThreadPool()
Franklin Schmidt <fschmidt@gmail.com>
parents:
867
diff
changeset
|
80 threadPool = new ThreadPoolExecutor(256, 256, 60, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>()); |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
81 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
82 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
83 |
812
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 public static String getVersion() |
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 return __version; |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
88 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
89 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
90 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
91 /* ------------------------------------------------------------ */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
92 @Override |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
93 protected void doStart() throws Exception |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
94 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
95 LOG.info("jetty-"+__version); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
96 HttpGenerator.setServerVersion(__version); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
97 |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
98 MultiException mex=new MultiException(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
99 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
100 try |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
101 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
102 super.doStart(); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
103 } |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
104 catch(Throwable e) |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
105 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
106 mex.add(e); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
107 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
108 |
876
2efdb98f3543
use just one fixed Connector in Server
Franklin Schmidt <fschmidt@gmail.com>
parents:
875
diff
changeset
|
109 if (mex.size()==0) |
812
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 try{connector.start();} |
2efdb98f3543
use just one fixed Connector in Server
Franklin Schmidt <fschmidt@gmail.com>
parents:
875
diff
changeset
|
112 catch(Throwable e) |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
113 { |
876
2efdb98f3543
use just one fixed Connector in Server
Franklin Schmidt <fschmidt@gmail.com>
parents:
875
diff
changeset
|
114 mex.add(e); |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
115 } |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
116 } |
883 | 117 /* |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
118 if (isDumpAfterStart()) |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
119 dumpStdErr(); |
883 | 120 */ |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
121 mex.ifExceptionThrow(); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
122 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
123 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
124 /* ------------------------------------------------------------ */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
125 @Override |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
126 protected void doStop() throws Exception |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
127 { |
883 | 128 /* |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
129 if (isDumpBeforeStop()) |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
130 dumpStdErr(); |
883 | 131 */ |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
132 MultiException mex=new MultiException(); |
880
00b3bd6e0ada
remove Server._graceful
Franklin Schmidt <fschmidt@gmail.com>
parents:
879
diff
changeset
|
133 /* |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
134 if (_graceful>0) |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
135 { |
876
2efdb98f3543
use just one fixed Connector in Server
Franklin Schmidt <fschmidt@gmail.com>
parents:
875
diff
changeset
|
136 LOG.info("Graceful shutdown {}",connector); |
2efdb98f3543
use just one fixed Connector in Server
Franklin Schmidt <fschmidt@gmail.com>
parents:
875
diff
changeset
|
137 try{connector.close();}catch(Throwable e){mex.add(e);} |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
138 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
139 Handler[] contexts = getChildHandlersByClass(Graceful.class); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
140 for (int c=0;c<contexts.length;c++) |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
141 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
142 Graceful context=(Graceful)contexts[c]; |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
143 LOG.info("Graceful shutdown {}",context); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
144 context.setShutdown(true); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
145 } |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
146 Thread.sleep(_graceful); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
147 } |
880
00b3bd6e0ada
remove Server._graceful
Franklin Schmidt <fschmidt@gmail.com>
parents:
879
diff
changeset
|
148 */ |
876
2efdb98f3543
use just one fixed Connector in Server
Franklin Schmidt <fschmidt@gmail.com>
parents:
875
diff
changeset
|
149 try{connector.stop();}catch(Throwable e){mex.add(e);} |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
150 |
875
b9aa175d9a29
remove Server.getThreadPool()
Franklin Schmidt <fschmidt@gmail.com>
parents:
867
diff
changeset
|
151 threadPool.shutdownNow(); |
867 | 152 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
153 try {super.doStop(); } catch(Throwable e) { mex.add(e);} |
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 mex.ifExceptionThrow(); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
156 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
157 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
158 /* ------------------------------------------------------------ */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
159 /* Handle a request from a connection. |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
160 * 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
|
161 * 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
|
162 * on the dispatch of an async request. |
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 public void handle(AbstractHttpConnection connection) throws IOException, ServletException |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
165 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
166 final String target=connection.getRequest().getPathInfo(); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
167 final Request request=connection.getRequest(); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
168 final Response response=connection.getResponse(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
169 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
170 if (LOG.isDebugEnabled()) |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
171 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
172 LOG.debug("REQUEST "+target+" on "+connection); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
173 handle(target, request, request, response); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
174 LOG.debug("RESPONSE "+target+" "+connection.getResponse().getStatus()+" handled="+request.isHandled()); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
175 } |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
176 else |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
177 handle(target, request, request, response); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
178 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
179 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
180 /* ------------------------------------------------------------ */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
181 /* Handle a request from a connection. |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
182 * 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
|
183 * 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
|
184 * on the dispatch of an async request. |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
185 */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
186 public void handleAsync(AbstractHttpConnection connection) throws IOException, ServletException |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
187 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
188 final AsyncContinuation async = connection.getRequest().getAsyncContinuation(); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
189 final AsyncContinuation.AsyncEventState state = async.getAsyncEventState(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
190 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
191 final Request baseRequest=connection.getRequest(); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
192 final String path=state.getPath(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
193 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
194 if (path!=null) |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
195 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
196 // this is a dispatch with a path |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
197 final String contextPath=state.getServletContext().getContextPath(); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
198 HttpURI uri = new HttpURI(URIUtil.addPaths(contextPath,path)); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
199 baseRequest.setUri(uri); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
200 baseRequest.setRequestURI(null); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
201 baseRequest.setPathInfo(baseRequest.getRequestURI()); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
202 if (uri.getQuery()!=null) |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
203 baseRequest.mergeQueryString(uri.getQuery()); //we have to assume dispatch path and query are UTF8 |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
204 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
205 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
206 final String target=baseRequest.getPathInfo(); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
207 final HttpServletRequest request=(HttpServletRequest)async.getRequest(); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
208 final HttpServletResponse response=(HttpServletResponse)async.getResponse(); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
209 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
210 if (LOG.isDebugEnabled()) |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
211 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
212 LOG.debug("REQUEST "+target+" on "+connection); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
213 handle(target, baseRequest, request, response); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
214 LOG.debug("RESPONSE "+target+" "+connection.getResponse().getStatus()); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
215 } |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
216 else |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
217 handle(target, baseRequest, request, response); |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
218 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
219 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
220 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
221 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
222 /* ------------------------------------------------------------ */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
223 public void join() throws InterruptedException |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
224 { |
875
b9aa175d9a29
remove Server.getThreadPool()
Franklin Schmidt <fschmidt@gmail.com>
parents:
867
diff
changeset
|
225 threadPool.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS); |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
226 } |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
227 |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
228 /* ------------------------------------------------------------ */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
229 /* |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
230 * @see org.eclipse.util.AttributesMap#clearAttributes() |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
231 */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
232 public void clearAttributes() |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
233 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
234 _attributes.clearAttributes(); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
235 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
236 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
237 /* ------------------------------------------------------------ */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
238 /* |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
239 * @see org.eclipse.util.AttributesMap#getAttribute(java.lang.String) |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
240 */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
241 public Object getAttribute(String name) |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
242 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
243 return _attributes.getAttribute(name); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
244 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
245 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
246 /* ------------------------------------------------------------ */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
247 /* |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
248 * @see org.eclipse.util.AttributesMap#getAttributeNames() |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
249 */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
250 public Enumeration getAttributeNames() |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
251 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
252 return AttributesMap.getAttributeNamesCopy(_attributes); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
253 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
254 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
255 /* ------------------------------------------------------------ */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
256 /* |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
257 * @see org.eclipse.util.AttributesMap#removeAttribute(java.lang.String) |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
258 */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
259 public void removeAttribute(String name) |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
260 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
261 _attributes.removeAttribute(name); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
262 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
263 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
264 /* ------------------------------------------------------------ */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
265 /* |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
266 * @see org.eclipse.util.AttributesMap#setAttribute(java.lang.String, java.lang.Object) |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
267 */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
268 public void setAttribute(String name, Object attribute) |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
269 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
270 _attributes.setAttribute(name, attribute); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
271 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
272 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
273 /* ------------------------------------------------------------ */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
274 @Override |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
275 public String toString() |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
276 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
277 return this.getClass().getName()+"@"+Integer.toHexString(hashCode()); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
278 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
279 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
280 /* ------------------------------------------------------------ */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
281 @Override |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
282 public void dump(Appendable out,String indent) throws IOException |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
283 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
284 dumpThis(out); |
876
2efdb98f3543
use just one fixed Connector in Server
Franklin Schmidt <fschmidt@gmail.com>
parents:
875
diff
changeset
|
285 dump(out,indent,TypeUtil.asList(getHandlers()),getBeans(),Collections.singletonList(connector)); |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
286 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
287 |
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
288 |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
289 /* ------------------------------------------------------------ */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
290 /* A handler that can be gracefully shutdown. |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
291 * Called by doStop if a {@link #setGracefulShutdown} period is set. |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
292 * TODO move this somewhere better |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
293 */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
294 public interface Graceful extends Handler |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
295 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
296 public void setShutdown(boolean shutdown); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
297 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
298 |
865 | 299 |
300 public final boolean isLowOnThreads() | |
301 { | |
302 // getActiveCount() locks the thread pool, so execute it last | |
875
b9aa175d9a29
remove Server.getThreadPool()
Franklin Schmidt <fschmidt@gmail.com>
parents:
867
diff
changeset
|
303 return threadPool.getPoolSize() == threadPool.getMaximumPoolSize() && |
b9aa175d9a29
remove Server.getThreadPool()
Franklin Schmidt <fschmidt@gmail.com>
parents:
867
diff
changeset
|
304 threadPool.getQueue().size() >= threadPool.getPoolSize() - threadPool.getActiveCount(); |
865 | 305 } |
306 | |
307 | |
812
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
308 /* ------------------------------------------------------------ */ |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
309 public static void main(String...args) throws Exception |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
310 { |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
311 System.err.println(getVersion()); |
700317ba03ad
remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
312 } |
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
313 } |