annotate src/org/eclipse/jetty/server/AsyncContinuation.java @ 935:aa7dc1802d29

remove ContinuationListener
author Franklin Schmidt <fschmidt@gmail.com>
date Sun, 09 Oct 2016 21:15:24 -0600
parents fe461f7cfc8e
children 237ace6e8bc2
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 javax.servlet.RequestDispatcher;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
22 import javax.servlet.ServletException;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
23
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
24 import java.util.ArrayList;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
25 import java.util.List;
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 javax.servlet.ServletContext;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
28 import javax.servlet.ServletRequest;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
29 import javax.servlet.ServletResponse;
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
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
32 import org.eclipse.jetty.continuation.Continuation;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
33 import org.eclipse.jetty.io.AsyncEndPoint;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
34 import org.eclipse.jetty.io.EndPoint;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
35 import org.eclipse.jetty.server.handler.ContextHandler;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
36 import org.eclipse.jetty.server.handler.ContextHandler.Context;
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
37 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
38 import org.slf4j.Logger;
8e9db0bbf4f9 remove org.eclipse.jetty.util.log and upgrade slf4j
Franklin Schmidt <fschmidt@gmail.com>
parents: 802
diff changeset
39 import org.slf4j.LoggerFactory;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
40
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
41 /* ------------------------------------------------------------ */
933
c9513d80f305 remove AsyncContext support
Franklin Schmidt <fschmidt@gmail.com>
parents: 932
diff changeset
42 /** Implementation of Continuation interfaces
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
43 *
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
44 */
935
aa7dc1802d29 remove ContinuationListener
Franklin Schmidt <fschmidt@gmail.com>
parents: 934
diff changeset
45 public final class AsyncContinuation implements Continuation
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
46 {
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
47 private static final Logger LOG = LoggerFactory.getLogger(AsyncContinuation.class);
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
48
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
49 private final static long DEFAULT_TIMEOUT=30000L;
931
6f7e2ff51879 remove ContinuationThrowable
Franklin Schmidt <fschmidt@gmail.com>
parents: 930
diff changeset
50
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
51 // STATES:
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
52 // handling() suspend() unhandle() resume() complete() doComplete()
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
53 // startAsync() dispatch()
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
54 // IDLE DISPATCHED
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
55 // DISPATCHED ASYNCSTARTED UNCOMPLETED
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
56 // ASYNCSTARTED ASYNCWAIT REDISPATCHING COMPLETING
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
57 // REDISPATCHING REDISPATCHED
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
58 // ASYNCWAIT REDISPATCH COMPLETING
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
59 // REDISPATCH REDISPATCHED
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
60 // REDISPATCHED ASYNCSTARTED UNCOMPLETED
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
61 // COMPLETING UNCOMPLETED UNCOMPLETED
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
62 // UNCOMPLETED COMPLETED
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
63 // COMPLETED
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
64 private static final int __IDLE=0; // Idle request
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
65 private static final int __DISPATCHED=1; // Request dispatched to filter/servlet
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
66 private static final int __UNCOMPLETED=8; // Request is completable
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
67 private static final int __COMPLETED=9; // Request is complete
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
68
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
69 /* ------------------------------------------------------------ */
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
70 protected AbstractHttpConnection _connection;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
71
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
72 /* ------------------------------------------------------------ */
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
73 private int _state;
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
74 private volatile long _expireAt;
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
75
935
aa7dc1802d29 remove ContinuationListener
Franklin Schmidt <fschmidt@gmail.com>
parents: 934
diff changeset
76 AsyncContinuation()
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
77 {
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
78 _state=__IDLE;
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
79 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
80
934
fe461f7cfc8e simplify AsyncContinuation
Franklin Schmidt <fschmidt@gmail.com>
parents: 933
diff changeset
81 protected synchronized void setConnection(final AbstractHttpConnection connection)
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
82 {
934
fe461f7cfc8e simplify AsyncContinuation
Franklin Schmidt <fschmidt@gmail.com>
parents: 933
diff changeset
83 _connection=connection;
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
84 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
85
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
86
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
87 @Override
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
88 public String toString()
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
89 {
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
90 synchronized (this)
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
91 {
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
92 return super.toString()+"@"+getStatusString();
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
93 }
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
94 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
95
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
96 public String getStatusString()
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
97 {
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
98 synchronized (this)
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
99 {
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
100 return
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
101 ((_state==__IDLE)?"IDLE":
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
102 (_state==__DISPATCHED)?"DISPATCHED":
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
103 (_state==__UNCOMPLETED)?"UNCOMPLETED":
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
104 (_state==__COMPLETED)?"COMPLETE":
929
3191abe890ef remove isInitial()
Franklin Schmidt <fschmidt@gmail.com>
parents: 928
diff changeset
105 ("UNKNOWN?"+_state));
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
106 }
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
107 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
108
929
3191abe890ef remove isInitial()
Franklin Schmidt <fschmidt@gmail.com>
parents: 928
diff changeset
109 protected synchronized void handling()
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
110 {
929
3191abe890ef remove isInitial()
Franklin Schmidt <fschmidt@gmail.com>
parents: 928
diff changeset
111 switch(_state)
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
112 {
929
3191abe890ef remove isInitial()
Franklin Schmidt <fschmidt@gmail.com>
parents: 928
diff changeset
113 case __IDLE:
3191abe890ef remove isInitial()
Franklin Schmidt <fschmidt@gmail.com>
parents: 928
diff changeset
114 _state=__DISPATCHED;
3191abe890ef remove isInitial()
Franklin Schmidt <fschmidt@gmail.com>
parents: 928
diff changeset
115 return;
3191abe890ef remove isInitial()
Franklin Schmidt <fschmidt@gmail.com>
parents: 928
diff changeset
116
3191abe890ef remove isInitial()
Franklin Schmidt <fschmidt@gmail.com>
parents: 928
diff changeset
117 default:
3191abe890ef remove isInitial()
Franklin Schmidt <fschmidt@gmail.com>
parents: 928
diff changeset
118 throw new IllegalStateException(this.getStatusString());
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
119 }
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
120 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
121
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
122 /* ------------------------------------------------------------ */
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
123 /**
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
124 * Signal that the HttpConnection has finished handling the request.
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
125 * For blocking connectors, this call may block if the request has
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
126 * been suspended (startAsync called).
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
127 * @return true if handling is complete, false if the request should
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
128 * be handled again (eg because of a resume that happened before unhandle was called)
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
129 */
928
23a57aad34c0 remove isAsync()
Franklin Schmidt <fschmidt@gmail.com>
parents: 927
diff changeset
130 protected synchronized void unhandle()
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
131 {
928
23a57aad34c0 remove isAsync()
Franklin Schmidt <fschmidt@gmail.com>
parents: 927
diff changeset
132 switch(_state)
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
133 {
928
23a57aad34c0 remove isAsync()
Franklin Schmidt <fschmidt@gmail.com>
parents: 927
diff changeset
134 case __DISPATCHED:
23a57aad34c0 remove isAsync()
Franklin Schmidt <fschmidt@gmail.com>
parents: 927
diff changeset
135 _state = __UNCOMPLETED;
23a57aad34c0 remove isAsync()
Franklin Schmidt <fschmidt@gmail.com>
parents: 927
diff changeset
136 return;
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
137
928
23a57aad34c0 remove isAsync()
Franklin Schmidt <fschmidt@gmail.com>
parents: 927
diff changeset
138 default:
23a57aad34c0 remove isAsync()
Franklin Schmidt <fschmidt@gmail.com>
parents: 927
diff changeset
139 throw new IllegalStateException(this.getStatusString());
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
140 }
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
141 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
142
934
fe461f7cfc8e simplify AsyncContinuation
Franklin Schmidt <fschmidt@gmail.com>
parents: 933
diff changeset
143
935
aa7dc1802d29 remove ContinuationListener
Franklin Schmidt <fschmidt@gmail.com>
parents: 934
diff changeset
144 protected synchronized void doComplete(Throwable ex)
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
145 {
935
aa7dc1802d29 remove ContinuationListener
Franklin Schmidt <fschmidt@gmail.com>
parents: 934
diff changeset
146 switch(_state)
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
147 {
935
aa7dc1802d29 remove ContinuationListener
Franklin Schmidt <fschmidt@gmail.com>
parents: 934
diff changeset
148 case __UNCOMPLETED:
aa7dc1802d29 remove ContinuationListener
Franklin Schmidt <fschmidt@gmail.com>
parents: 934
diff changeset
149 _state = __COMPLETED;
aa7dc1802d29 remove ContinuationListener
Franklin Schmidt <fschmidt@gmail.com>
parents: 934
diff changeset
150 break;
aa7dc1802d29 remove ContinuationListener
Franklin Schmidt <fschmidt@gmail.com>
parents: 934
diff changeset
151
aa7dc1802d29 remove ContinuationListener
Franklin Schmidt <fschmidt@gmail.com>
parents: 934
diff changeset
152 default:
aa7dc1802d29 remove ContinuationListener
Franklin Schmidt <fschmidt@gmail.com>
parents: 934
diff changeset
153 throw new IllegalStateException(this.getStatusString());
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
154 }
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
155 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
156
935
aa7dc1802d29 remove ContinuationListener
Franklin Schmidt <fschmidt@gmail.com>
parents: 934
diff changeset
157 protected synchronized void recycle()
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
158 {
935
aa7dc1802d29 remove ContinuationListener
Franklin Schmidt <fschmidt@gmail.com>
parents: 934
diff changeset
159 switch(_state)
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
160 {
935
aa7dc1802d29 remove ContinuationListener
Franklin Schmidt <fschmidt@gmail.com>
parents: 934
diff changeset
161 case __DISPATCHED:
aa7dc1802d29 remove ContinuationListener
Franklin Schmidt <fschmidt@gmail.com>
parents: 934
diff changeset
162 throw new IllegalStateException(getStatusString());
aa7dc1802d29 remove ContinuationListener
Franklin Schmidt <fschmidt@gmail.com>
parents: 934
diff changeset
163 default:
aa7dc1802d29 remove ContinuationListener
Franklin Schmidt <fschmidt@gmail.com>
parents: 934
diff changeset
164 _state=__IDLE;
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
165 }
935
aa7dc1802d29 remove ContinuationListener
Franklin Schmidt <fschmidt@gmail.com>
parents: 934
diff changeset
166 cancelTimeout();
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
167 }
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
168
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
169 /* ------------------------------------------------------------ */
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
170 protected void cancelTimeout()
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
171 {
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
172 EndPoint endp=_connection.getEndPoint();
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
173 if (endp.isBlocking())
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
174 {
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
175 synchronized(this)
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
176 {
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
177 _expireAt=0;
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
178 this.notifyAll();
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
179 }
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
180 }
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
181 else
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
182 {
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
183 }
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
184 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
185
934
fe461f7cfc8e simplify AsyncContinuation
Franklin Schmidt <fschmidt@gmail.com>
parents: 933
diff changeset
186 synchronized boolean isUncompleted()
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
187 {
934
fe461f7cfc8e simplify AsyncContinuation
Franklin Schmidt <fschmidt@gmail.com>
parents: 933
diff changeset
188 return _state==__UNCOMPLETED;
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
189 }
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
190
934
fe461f7cfc8e simplify AsyncContinuation
Franklin Schmidt <fschmidt@gmail.com>
parents: 933
diff changeset
191 public synchronized boolean isComplete()
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
192 {
934
fe461f7cfc8e simplify AsyncContinuation
Franklin Schmidt <fschmidt@gmail.com>
parents: 933
diff changeset
193 return _state==__COMPLETED;
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
194 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
195
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
196 /* ------------------------------------------------------------ */
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
197 public Request getBaseRequest()
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
198 {
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
199 return _connection.getRequest();
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
200 }
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
201
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
202 /* ------------------------------------------------------------ */
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
203 public ServletRequest getRequest()
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
204 {
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
205 return _connection.getRequest();
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
206 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
207
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
208 /* ------------------------------------------------------------ */
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
209 public ServletResponse getResponse()
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
210 {
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
211 return _connection.getResponse();
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
212 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
213
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
214
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
215 /* ------------------------------------------------------------ */
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
216 /**
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
217 * @see org.eclipse.jetty.continuation.Continuation#getServletResponse()
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
218 */
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
219 public ServletResponse getServletResponse()
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
220 {
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
221 return _connection.getResponse();
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
222 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
223
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
224 /* ------------------------------------------------------------ */
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
225 /**
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
226 * @see org.eclipse.jetty.continuation.Continuation#getAttribute(java.lang.String)
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
227 */
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
228 public Object getAttribute(String name)
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
229 {
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
230 return _connection.getRequest().getAttribute(name);
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
231 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
232
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
233 /* ------------------------------------------------------------ */
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
234 /**
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
235 * @see org.eclipse.jetty.continuation.Continuation#removeAttribute(java.lang.String)
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
236 */
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
237 public void removeAttribute(String name)
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
238 {
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
239 _connection.getRequest().removeAttribute(name);
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
240 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
241
865
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
242 /* ------------------------------------------------------------ */
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
243 /**
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
244 * @see org.eclipse.jetty.continuation.Continuation#setAttribute(java.lang.String, java.lang.Object)
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
245 */
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
246 public void setAttribute(String name, Object attribute)
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
247 {
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
248 _connection.getRequest().setAttribute(name,attribute);
6b210bb66c63 remove ThreadPool
Franklin Schmidt <fschmidt@gmail.com>
parents: 820
diff changeset
249 }
802
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
250
3428c60d7cfc replace jetty jars with source
Franklin Schmidt <fschmidt@gmail.com>
parents:
diff changeset
251 }