annotate src/org/eclipse/jetty/server/Server.java @ 930:cd080b7bcf49

remove AsyncContinuation.undispatch()
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 09 Oct 2016 19:20:52 -0600
parents 3191abe890ef
children 53b3f7d9714c
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
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
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 864
diff changeset
27 import java.util.concurrent.LinkedBlockingQueue;
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 864
diff changeset
28 import java.util.concurrent.ThreadPoolExecutor;
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 864
diff changeset
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 import javax.servlet.http.HttpServletRequest;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 import javax.servlet.http.HttpServletResponse;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 import org.eclipse.jetty.http.HttpURI;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 import org.eclipse.jetty.server.handler.HandlerWrapper;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 import org.eclipse.jetty.server.nio.SelectChannelConnector;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
38 import org.eclipse.jetty.util.Attributes;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
39 import org.eclipse.jetty.util.AttributesMap;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40 import org.eclipse.jetty.util.LazyList;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41 import org.eclipse.jetty.util.MultiException;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
42 import org.eclipse.jetty.util.TypeUtil;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43 import org.eclipse.jetty.util.URIUtil;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44 import org.eclipse.jetty.util.component.Destroyable;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
45 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
46 import org.slf4j.Logger;
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 812
diff changeset
47 import org.slf4j.LoggerFactory;
802
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 /* ------------------------------------------------------------ */
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
50 /** Jetty HTTP Servlet Server.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
51 * 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
52 * It aggregates Connectors (HTTP request receivers) and request Handlers.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
53 * 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
54 * to run jobs that will eventually call the handle method.
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
55 *
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
56 * @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
57 */
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
58 public class Server extends HandlerWrapper implements Attributes
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
59 {
820
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 812
diff changeset
60 private static final Logger LOG = LoggerFactory.getLogger(Server.class);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
61
884
cb78ee27b0e0 remove Server.getVersion()
Franklin Schmidt <fschmidt@gmail.com>
parents: 883
diff changeset
62 public static final String version = "8";
812
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
63
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
64 private final AttributesMap _attributes = new AttributesMap();
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 886
diff changeset
65 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
66 final List<Connector> connectors = new ArrayList<Connector>();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
67
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
68
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 886
diff changeset
69 public Server() {
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 886
diff changeset
70 setServer(this);
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 886
diff changeset
71 }
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 886
diff changeset
72
812
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
73 public Server(int port)
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
74 {
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
75 setServer(this);
887
df84a1741687 make Connector reference to server explicit
Franklin Schmidt <fschmidt@gmail.com>
parents: 886
diff changeset
76 new SelectChannelConnector(this,port);
886
0d876a03ab0b add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 884
diff changeset
77 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
78
812
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
79 @Override
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
80 protected void doStart() throws Exception
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
81 {
884
cb78ee27b0e0 remove Server.getVersion()
Franklin Schmidt <fschmidt@gmail.com>
parents: 883
diff changeset
82 LOG.info("jetty-"+version);
812
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
83
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
84 MultiException mex=new MultiException();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
85
812
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
86 try
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
87 {
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
88 super.doStart();
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
89 }
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
90 catch(Throwable e)
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 mex.add(e);
700317ba03ad remove SessionIdManager
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
886
0d876a03ab0b add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 884
diff changeset
95 if (mex.size()==0) {
0d876a03ab0b add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 884
diff changeset
96 for( Connector connector : connectors ) {
0d876a03ab0b add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 884
diff changeset
97 try{connector.start();}
0d876a03ab0b add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 884
diff changeset
98 catch(Throwable e)
0d876a03ab0b add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 884
diff changeset
99 {
0d876a03ab0b add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 884
diff changeset
100 mex.add(e);
0d876a03ab0b add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 884
diff changeset
101 }
812
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
102 }
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 mex.ifExceptionThrow();
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
105 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
106
812
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
107 @Override
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
108 protected void doStop() throws Exception
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
109 {
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
110 MultiException mex=new MultiException();
880
00b3bd6e0ada remove Server._graceful
Franklin Schmidt <fschmidt@gmail.com>
parents: 879
diff changeset
111 /*
812
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
112 if (_graceful>0)
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 LOG.info("Graceful shutdown {}",connector);
2efdb98f3543 use just one fixed Connector in Server
Franklin Schmidt <fschmidt@gmail.com>
parents: 875
diff changeset
115 try{connector.close();}catch(Throwable e){mex.add(e);}
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
116
812
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
117 Handler[] contexts = getChildHandlersByClass(Graceful.class);
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
118 for (int c=0;c<contexts.length;c++)
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
119 {
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
120 Graceful context=(Graceful)contexts[c];
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
121 LOG.info("Graceful shutdown {}",context);
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
122 context.setShutdown(true);
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
123 }
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
124 Thread.sleep(_graceful);
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
125 }
880
00b3bd6e0ada remove Server._graceful
Franklin Schmidt <fschmidt@gmail.com>
parents: 879
diff changeset
126 */
886
0d876a03ab0b add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 884
diff changeset
127 for( Connector connector : connectors ) {
0d876a03ab0b add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 884
diff changeset
128 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
129 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
130
875
b9aa175d9a29 remove Server.getThreadPool()
Franklin Schmidt <fschmidt@gmail.com>
parents: 867
diff changeset
131 threadPool.shutdownNow();
867
Franklin Schmidt <fschmidt@gmail.com>
parents: 865
diff changeset
132
812
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
133 try {super.doStop(); } catch(Throwable e) { mex.add(e);}
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 mex.ifExceptionThrow();
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
136 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
137
812
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
138 /* ------------------------------------------------------------ */
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
139 /* Handle a request from a connection.
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
140 * 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
141 * 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
142 * on the dispatch of an async request.
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
143 */
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
144 public void handle(AbstractHttpConnection connection) throws IOException, ServletException
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 final String target=connection.getRequest().getPathInfo();
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
147 final Request request=connection.getRequest();
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
148 final Response response=connection.getResponse();
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
149
812
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
150 if (LOG.isDebugEnabled())
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
151 {
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
152 LOG.debug("REQUEST "+target+" on "+connection);
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
153 handle(target, request, request, response);
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
154 LOG.debug("RESPONSE "+target+" "+connection.getResponse().getStatus()+" handled="+request.isHandled());
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
155 }
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
156 else
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
157 handle(target, request, request, response);
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
158 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
159
812
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
160 public void join() throws InterruptedException
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
161 {
875
b9aa175d9a29 remove Server.getThreadPool()
Franklin Schmidt <fschmidt@gmail.com>
parents: 867
diff changeset
162 threadPool.awaitTermination(Long.MAX_VALUE, TimeUnit.MILLISECONDS);
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
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 /*
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
167 * @see org.eclipse.util.AttributesMap#clearAttributes()
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
168 */
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
169 public void clearAttributes()
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 _attributes.clearAttributes();
700317ba03ad remove SessionIdManager
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
812
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
174 /* ------------------------------------------------------------ */
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 * @see org.eclipse.util.AttributesMap#getAttribute(java.lang.String)
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
177 */
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
178 public Object getAttribute(String name)
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
179 {
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
180 return _attributes.getAttribute(name);
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
181 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
182
812
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
183 /* ------------------------------------------------------------ */
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
184 /*
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
185 * @see org.eclipse.util.AttributesMap#getAttributeNames()
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
186 */
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
187 public Enumeration getAttributeNames()
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
188 {
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
189 return AttributesMap.getAttributeNamesCopy(_attributes);
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
190 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
191
812
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
192 /* ------------------------------------------------------------ */
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
193 /*
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
194 * @see org.eclipse.util.AttributesMap#removeAttribute(java.lang.String)
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 public void removeAttribute(String name)
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
197 {
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
198 _attributes.removeAttribute(name);
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
199 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
200
812
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
201 /* ------------------------------------------------------------ */
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
202 /*
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
203 * @see org.eclipse.util.AttributesMap#setAttribute(java.lang.String, java.lang.Object)
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
204 */
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
205 public void setAttribute(String name, Object attribute)
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
206 {
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
207 _attributes.setAttribute(name, attribute);
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
208 }
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 /* ------------------------------------------------------------ */
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
211 @Override
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
212 public String toString()
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
213 {
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
214 return this.getClass().getName()+"@"+Integer.toHexString(hashCode());
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
215 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
216
812
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
217 @Override
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
218 public void dump(Appendable out,String indent) throws IOException
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
219 {
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
220 dumpThis(out);
886
0d876a03ab0b add back Server.addConnector() - needed for ssl
Franklin Schmidt <fschmidt@gmail.com>
parents: 884
diff changeset
221 dump(out,indent,TypeUtil.asList(getHandlers()),getBeans(),connectors);
812
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
222 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
223
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
224
812
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
225 /* ------------------------------------------------------------ */
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
226 /* A handler that can be gracefully shutdown.
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
227 * Called by doStop if a {@link #setGracefulShutdown} period is set.
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
228 * TODO move this somewhere better
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 public interface Graceful extends Handler
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 setShutdown(boolean shutdown);
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
233 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
234
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 864
diff changeset
235
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 864
diff changeset
236 public final boolean isLowOnThreads()
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 864
diff changeset
237 {
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 864
diff changeset
238 // getActiveCount() locks the thread pool, so execute it last
875
b9aa175d9a29 remove Server.getThreadPool()
Franklin Schmidt <fschmidt@gmail.com>
parents: 867
diff changeset
239 return threadPool.getPoolSize() == threadPool.getMaximumPoolSize() &&
b9aa175d9a29 remove Server.getThreadPool()
Franklin Schmidt <fschmidt@gmail.com>
parents: 867
diff changeset
240 threadPool.getQueue().size() >= threadPool.getPoolSize() - threadPool.getActiveCount();
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 864
diff changeset
241 }
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 864
diff changeset
242
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 864
diff changeset
243
812
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
244 public static void main(String...args) throws Exception
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
245 {
884
cb78ee27b0e0 remove Server.getVersion()
Franklin Schmidt <fschmidt@gmail.com>
parents: 883
diff changeset
246 System.err.println(version);
812
700317ba03ad remove SessionIdManager
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
247 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
248 }