Mercurial Hosting > luan
annotate src/org/eclipse/jetty/server/AsyncContinuation.java @ 932:947df3056ddb
remove AsyncEventState
| author | Franklin Schmidt <fschmidt@gmail.com> |
|---|---|
| date | Sun, 09 Oct 2016 20:20:13 -0600 |
| parents | 6f7e2ff51879 |
| children | c9513d80f305 |
| 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 javax.servlet.AsyncContext; |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
22 import javax.servlet.AsyncEvent; |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
23 import javax.servlet.AsyncListener; |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
24 import javax.servlet.RequestDispatcher; |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
25 import javax.servlet.ServletException; |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
26 |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
27 import java.util.ArrayList; |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
28 import java.util.List; |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
29 |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
30 import javax.servlet.ServletContext; |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
31 import javax.servlet.ServletRequest; |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
32 import javax.servlet.ServletResponse; |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
33 import javax.servlet.http.HttpServletRequest; |
|
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.continuation.Continuation; |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
36 import org.eclipse.jetty.continuation.ContinuationListener; |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
37 import org.eclipse.jetty.io.AsyncEndPoint; |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
38 import org.eclipse.jetty.io.EndPoint; |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
39 import org.eclipse.jetty.server.handler.ContextHandler; |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
40 import org.eclipse.jetty.server.handler.ContextHandler.Context; |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
41 import org.eclipse.jetty.util.URIUtil; |
|
820
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
42 import org.slf4j.Logger; |
|
8e9db0bbf4f9
remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents:
802
diff
changeset
|
43 import org.slf4j.LoggerFactory; |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
44 import org.eclipse.jetty.util.thread.Timeout; |
|
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 /** Implementation of Continuation and AsyncContext interfaces |
|
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 public class AsyncContinuation implements AsyncContext, Continuation |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
51 { |
| 865 | 52 private static final Logger LOG = LoggerFactory.getLogger(AsyncContinuation.class); |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
53 |
| 865 | 54 private final static long DEFAULT_TIMEOUT=30000L; |
|
931
6f7e2ff51879
remove ContinuationThrowable
Franklin Schmidt <fschmidt@gmail.com>
parents:
930
diff
changeset
|
55 |
| 865 | 56 // STATES: |
| 57 // handling() suspend() unhandle() resume() complete() doComplete() | |
| 58 // startAsync() dispatch() | |
| 59 // IDLE DISPATCHED | |
| 60 // DISPATCHED ASYNCSTARTED UNCOMPLETED | |
| 61 // ASYNCSTARTED ASYNCWAIT REDISPATCHING COMPLETING | |
| 62 // REDISPATCHING REDISPATCHED | |
| 63 // ASYNCWAIT REDISPATCH COMPLETING | |
| 64 // REDISPATCH REDISPATCHED | |
| 65 // REDISPATCHED ASYNCSTARTED UNCOMPLETED | |
| 66 // COMPLETING UNCOMPLETED UNCOMPLETED | |
| 67 // UNCOMPLETED COMPLETED | |
| 68 // COMPLETED | |
| 69 private static final int __IDLE=0; // Idle request | |
| 70 private static final int __DISPATCHED=1; // Request dispatched to filter/servlet | |
| 71 private static final int __UNCOMPLETED=8; // Request is completable | |
| 72 private static final int __COMPLETED=9; // Request is complete | |
| 73 | |
| 74 /* ------------------------------------------------------------ */ | |
| 75 protected AbstractHttpConnection _connection; | |
| 76 private List<AsyncListener> _asyncListeners; | |
| 77 private List<ContinuationListener> _continuationListeners; | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
78 |
| 865 | 79 /* ------------------------------------------------------------ */ |
| 80 private int _state; | |
| 81 private volatile boolean _responseWrapped; | |
| 82 private long _timeoutMs=DEFAULT_TIMEOUT; | |
| 83 private volatile long _expireAt; | |
| 84 | |
| 85 /* ------------------------------------------------------------ */ | |
| 86 protected AsyncContinuation() | |
| 87 { | |
| 88 _state=__IDLE; | |
| 89 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
90 |
| 865 | 91 /* ------------------------------------------------------------ */ |
| 92 protected void setConnection(final AbstractHttpConnection connection) | |
| 93 { | |
| 94 synchronized(this) | |
| 95 { | |
| 96 _connection=connection; | |
| 97 } | |
| 98 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
99 |
| 865 | 100 /* ------------------------------------------------------------ */ |
| 101 public void addListener(AsyncListener listener) | |
| 102 { | |
| 103 synchronized(this) | |
| 104 { | |
| 105 if (_asyncListeners==null) | |
| 106 _asyncListeners=new ArrayList<AsyncListener>(); | |
| 107 _asyncListeners.add(listener); | |
| 108 } | |
| 109 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
110 |
| 865 | 111 /* ------------------------------------------------------------ */ |
| 112 public void addListener(AsyncListener listener,ServletRequest request, ServletResponse response) | |
| 113 { | |
| 114 synchronized(this) | |
| 115 { | |
| 116 // TODO handle the request/response ??? | |
| 117 if (_asyncListeners==null) | |
| 118 _asyncListeners=new ArrayList<AsyncListener>(); | |
| 119 _asyncListeners.add(listener); | |
| 120 } | |
| 121 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
122 |
| 865 | 123 /* ------------------------------------------------------------ */ |
| 124 public void addContinuationListener(ContinuationListener listener) | |
| 125 { | |
| 126 synchronized(this) | |
| 127 { | |
| 128 if (_continuationListeners==null) | |
| 129 _continuationListeners=new ArrayList<ContinuationListener>(); | |
| 130 _continuationListeners.add(listener); | |
| 131 } | |
| 132 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
133 |
| 865 | 134 /* ------------------------------------------------------------ */ |
| 135 public void setTimeout(long ms) | |
| 136 { | |
| 137 synchronized(this) | |
| 138 { | |
| 139 _timeoutMs=ms; | |
| 140 } | |
| 141 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
142 |
| 865 | 143 /* ------------------------------------------------------------ */ |
| 144 public long getTimeout() | |
| 145 { | |
| 146 synchronized(this) | |
| 147 { | |
| 148 return _timeoutMs; | |
| 149 } | |
| 150 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
151 |
| 865 | 152 /* ------------------------------------------------------------ */ |
| 153 /** | |
| 154 * @see org.eclipse.jetty.continuation.Continuation#keepWrappers() | |
| 155 */ | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
156 |
| 865 | 157 /* ------------------------------------------------------------ */ |
| 158 /** | |
| 159 * @see org.eclipse.jetty.continuation.Continuation#isResponseWrapped() | |
| 160 */ | |
| 161 public boolean isResponseWrapped() | |
| 162 { | |
| 163 return _responseWrapped; | |
| 164 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
165 |
| 865 | 166 /* ------------------------------------------------------------ */ |
| 167 /* (non-Javadoc) | |
| 168 * @see javax.servlet.ServletRequest#isSuspended() | |
| 169 */ | |
| 170 public boolean isSuspended() | |
| 171 { | |
| 172 synchronized(this) | |
| 173 { | |
| 174 switch(_state) | |
| 175 { | |
| 176 default: | |
| 177 return false; | |
| 178 } | |
| 179 } | |
| 180 } | |
| 181 | |
| 182 /* ------------------------------------------------------------ */ | |
| 183 public boolean isSuspending() | |
| 184 { | |
| 185 synchronized(this) | |
| 186 { | |
| 187 switch(_state) | |
| 188 { | |
| 189 default: | |
| 190 return false; | |
| 191 } | |
| 192 } | |
| 193 } | |
| 194 | |
| 195 /* ------------------------------------------------------------ */ | |
| 196 public boolean isDispatchable() | |
| 197 { | |
| 198 synchronized(this) | |
| 199 { | |
| 200 switch(_state) | |
| 201 { | |
| 202 default: | |
| 203 return false; | |
| 204 } | |
| 205 } | |
| 206 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
207 |
| 865 | 208 /* ------------------------------------------------------------ */ |
| 209 @Override | |
| 210 public String toString() | |
| 211 { | |
| 212 synchronized (this) | |
| 213 { | |
| 214 return super.toString()+"@"+getStatusString(); | |
| 215 } | |
| 216 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
217 |
| 865 | 218 /* ------------------------------------------------------------ */ |
| 219 public String getStatusString() | |
| 220 { | |
| 221 synchronized (this) | |
| 222 { | |
| 223 return | |
| 224 ((_state==__IDLE)?"IDLE": | |
| 225 (_state==__DISPATCHED)?"DISPATCHED": | |
| 226 (_state==__UNCOMPLETED)?"UNCOMPLETED": | |
| 227 (_state==__COMPLETED)?"COMPLETE": | |
| 929 | 228 ("UNKNOWN?"+_state)); |
| 865 | 229 } |
| 230 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
231 |
| 929 | 232 protected synchronized void handling() |
| 865 | 233 { |
| 929 | 234 switch(_state) |
| 865 | 235 { |
| 929 | 236 case __IDLE: |
| 237 _state=__DISPATCHED; | |
| 238 if (_asyncListeners!=null) | |
| 239 _asyncListeners.clear(); | |
| 240 return; | |
| 241 | |
| 242 default: | |
| 243 throw new IllegalStateException(this.getStatusString()); | |
| 865 | 244 } |
| 245 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
246 |
| 865 | 247 /* ------------------------------------------------------------ */ |
| 248 /** | |
| 249 * Signal that the HttpConnection has finished handling the request. | |
| 250 * For blocking connectors, this call may block if the request has | |
| 251 * been suspended (startAsync called). | |
| 252 * @return true if handling is complete, false if the request should | |
| 253 * be handled again (eg because of a resume that happened before unhandle was called) | |
| 254 */ | |
| 928 | 255 protected synchronized void unhandle() |
| 865 | 256 { |
| 928 | 257 switch(_state) |
| 865 | 258 { |
| 928 | 259 case __DISPATCHED: |
| 260 _state = __UNCOMPLETED; | |
| 261 return; | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
262 |
| 928 | 263 default: |
| 264 throw new IllegalStateException(this.getStatusString()); | |
| 865 | 265 } |
| 266 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
267 |
| 865 | 268 public void dispatch() |
| 269 { | |
| 929 | 270 throw new UnsupportedOperationException(); |
| 865 | 271 } |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
272 |
| 865 | 273 /* ------------------------------------------------------------ */ |
| 274 protected void expired() | |
| 275 { | |
| 276 } | |
| 277 | |
| 278 /* ------------------------------------------------------------ */ | |
| 279 /* (non-Javadoc) | |
| 280 * @see javax.servlet.ServletRequest#complete() | |
| 281 */ | |
| 282 public void complete() | |
| 283 { | |
| 284 // just like resume, except don't set _resumed=true; | |
| 285 boolean dispatch=false; | |
| 286 synchronized (this) | |
| 287 { | |
| 288 switch(_state) | |
| 289 { | |
| 290 case __DISPATCHED: | |
| 291 throw new IllegalStateException(this.getStatusString()); | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
292 |
| 865 | 293 default: |
| 294 throw new IllegalStateException(this.getStatusString()); | |
| 295 } | |
| 296 } | |
| 297 } | |
| 298 | |
| 299 /* ------------------------------------------------------------ */ | |
| 300 /* (non-Javadoc) | |
| 301 * @see javax.servlet.ServletRequest#complete() | |
| 302 */ | |
| 303 public void errorComplete() | |
| 304 { | |
| 305 // just like complete except can overrule a prior dispatch call; | |
| 306 synchronized (this) | |
| 307 { | |
| 308 switch(_state) | |
| 309 { | |
| 310 default: | |
| 311 throw new IllegalStateException(this.getStatusString()); | |
| 312 } | |
| 313 } | |
| 314 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
315 |
| 865 | 316 /* ------------------------------------------------------------ */ |
| 317 @Override | |
| 318 public <T extends AsyncListener> T createListener(Class<T> clazz) throws ServletException | |
| 319 { | |
| 320 try | |
| 321 { | |
| 322 // TODO inject | |
| 323 return clazz.newInstance(); | |
| 324 } | |
| 325 catch(Exception e) | |
| 326 { | |
| 327 throw new ServletException(e); | |
| 328 } | |
| 329 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
330 |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
331 |
| 865 | 332 /* ------------------------------------------------------------ */ |
| 333 /* (non-Javadoc) | |
| 334 * @see javax.servlet.ServletRequest#complete() | |
| 335 */ | |
| 336 protected void doComplete(Throwable ex) | |
| 337 { | |
| 338 final List<ContinuationListener> cListeners; | |
| 339 final List<AsyncListener> aListeners; | |
| 340 synchronized (this) | |
| 341 { | |
| 342 switch(_state) | |
| 343 { | |
| 344 case __UNCOMPLETED: | |
|
918
7b62446899c6
remove unused states in AsyncContinuation
Franklin Schmidt <fschmidt@gmail.com>
parents:
917
diff
changeset
|
345 _state = __COMPLETED; |
| 865 | 346 cListeners=_continuationListeners; |
| 347 aListeners=_asyncListeners; | |
| 348 break; | |
| 349 | |
| 350 default: | |
| 351 cListeners=null; | |
| 352 aListeners=null; | |
| 353 throw new IllegalStateException(this.getStatusString()); | |
| 354 } | |
| 355 } | |
| 356 | |
| 357 if (aListeners!=null) | |
| 358 { | |
| 359 for (AsyncListener listener : aListeners) | |
| 360 { | |
| 361 try | |
| 362 { | |
| 363 if (ex!=null) | |
| 364 { | |
|
932
947df3056ddb
remove AsyncEventState
Franklin Schmidt <fschmidt@gmail.com>
parents:
931
diff
changeset
|
365 throw new UnsupportedOperationException(); |
| 865 | 366 } |
| 367 else | |
|
932
947df3056ddb
remove AsyncEventState
Franklin Schmidt <fschmidt@gmail.com>
parents:
931
diff
changeset
|
368 listener.onComplete(null); |
| 865 | 369 } |
| 370 catch(Exception e) | |
| 371 { | |
| 372 LOG.warn("",e); | |
| 373 } | |
| 374 } | |
| 375 } | |
| 376 if (cListeners!=null) | |
| 377 { | |
| 378 for (ContinuationListener listener : cListeners) | |
| 379 { | |
| 380 try | |
| 381 { | |
| 382 listener.onComplete(this); | |
| 383 } | |
| 384 catch(Exception e) | |
| 385 { | |
| 386 LOG.warn("",e); | |
| 387 } | |
| 388 } | |
| 389 } | |
| 390 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
391 |
| 865 | 392 /* ------------------------------------------------------------ */ |
| 393 protected void recycle() | |
| 394 { | |
| 395 synchronized (this) | |
| 396 { | |
| 397 switch(_state) | |
| 398 { | |
| 399 case __DISPATCHED: | |
| 400 throw new IllegalStateException(getStatusString()); | |
| 401 default: | |
| 402 _state=__IDLE; | |
| 403 } | |
| 404 _responseWrapped=false; | |
| 405 cancelTimeout(); | |
| 406 _timeoutMs=DEFAULT_TIMEOUT; | |
| 407 _continuationListeners=null; | |
| 408 } | |
| 409 } | |
| 410 | |
| 411 /* ------------------------------------------------------------ */ | |
| 412 protected void cancelTimeout() | |
| 413 { | |
| 414 EndPoint endp=_connection.getEndPoint(); | |
| 415 if (endp.isBlocking()) | |
| 416 { | |
| 417 synchronized(this) | |
| 418 { | |
| 419 _expireAt=0; | |
| 420 this.notifyAll(); | |
| 421 } | |
| 422 } | |
| 423 else | |
| 424 { | |
| 425 } | |
| 426 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
427 |
| 865 | 428 boolean isUncompleted() |
| 429 { | |
| 430 synchronized (this) | |
| 431 { | |
| 432 return _state==__UNCOMPLETED; | |
| 433 } | |
| 434 } | |
| 435 | |
| 436 public boolean isComplete() | |
| 437 { | |
| 438 synchronized (this) | |
| 439 { | |
| 440 return _state==__COMPLETED; | |
| 441 } | |
| 442 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
443 |
| 865 | 444 public void dispatch(ServletContext context, String path) |
| 445 { | |
| 929 | 446 throw new UnsupportedOperationException(); |
| 865 | 447 } |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
448 |
| 865 | 449 public void dispatch(String path) |
| 450 { | |
| 929 | 451 throw new UnsupportedOperationException(); |
| 865 | 452 } |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
453 |
| 865 | 454 /* ------------------------------------------------------------ */ |
| 455 public Request getBaseRequest() | |
| 456 { | |
| 457 return _connection.getRequest(); | |
| 458 } | |
| 459 | |
| 460 /* ------------------------------------------------------------ */ | |
| 461 public ServletRequest getRequest() | |
| 462 { | |
| 463 return _connection.getRequest(); | |
| 464 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
465 |
| 865 | 466 /* ------------------------------------------------------------ */ |
| 467 public ServletResponse getResponse() | |
| 468 { | |
| 469 return _connection.getResponse(); | |
| 470 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
471 |
| 865 | 472 /* ------------------------------------------------------------ */ |
| 473 public void start(final Runnable run) | |
| 474 { | |
| 475 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
476 |
| 865 | 477 /* ------------------------------------------------------------ */ |
| 478 public boolean hasOriginalRequestAndResponse() | |
| 479 { | |
| 480 synchronized (this) | |
| 481 { | |
|
932
947df3056ddb
remove AsyncEventState
Franklin Schmidt <fschmidt@gmail.com>
parents:
931
diff
changeset
|
482 return false; |
| 865 | 483 } |
| 484 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
485 |
| 865 | 486 /* ------------------------------------------------------------ */ |
| 487 public ContextHandler getContextHandler() | |
| 488 { | |
| 489 return null; | |
| 490 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
491 |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
492 |
| 865 | 493 /* ------------------------------------------------------------ */ |
| 494 /** | |
| 495 * @see org.eclipse.jetty.continuation.Continuation#getServletResponse() | |
| 496 */ | |
| 497 public ServletResponse getServletResponse() | |
| 498 { | |
| 499 return _connection.getResponse(); | |
| 500 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
501 |
| 865 | 502 /* ------------------------------------------------------------ */ |
| 503 /** | |
| 504 * @see org.eclipse.jetty.continuation.Continuation#getAttribute(java.lang.String) | |
| 505 */ | |
| 506 public Object getAttribute(String name) | |
| 507 { | |
| 508 return _connection.getRequest().getAttribute(name); | |
| 509 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
510 |
| 865 | 511 /* ------------------------------------------------------------ */ |
| 512 /** | |
| 513 * @see org.eclipse.jetty.continuation.Continuation#removeAttribute(java.lang.String) | |
| 514 */ | |
| 515 public void removeAttribute(String name) | |
| 516 { | |
| 517 _connection.getRequest().removeAttribute(name); | |
| 518 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
519 |
| 865 | 520 /* ------------------------------------------------------------ */ |
| 521 /** | |
| 522 * @see org.eclipse.jetty.continuation.Continuation#setAttribute(java.lang.String, java.lang.Object) | |
| 523 */ | |
| 524 public void setAttribute(String name, Object attribute) | |
| 525 { | |
| 526 _connection.getRequest().setAttribute(name,attribute); | |
| 527 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
528 |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
529 |
| 865 | 530 /* ------------------------------------------------------------ */ |
| 531 /* ------------------------------------------------------------ */ | |
| 532 public class AsyncTimeout extends Timeout.Task implements Runnable | |
| 533 { | |
| 534 @Override | |
| 535 public void expired() | |
| 536 { | |
| 537 AsyncContinuation.this.expired(); | |
| 538 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
539 |
| 865 | 540 @Override |
| 541 public void run() | |
| 542 { | |
| 543 AsyncContinuation.this.expired(); | |
| 544 } | |
| 545 } | |
|
802
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
546 |
|
3428c60d7cfc
replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff
changeset
|
547 } |
