Author: ningjiang
Date: Fri Feb 25 13:25:41 2011
New Revision: 1074516
URL: http://svn.apache.org/viewvc?rev=1074516&view=rev
Log:
Merged revisions 1074489 via svnmerge from
https://svn.apache.org/repos/asf/cxf/trunk
........
r1074489 | ningjiang | 2011-02-25 20:03:00 +0800 (Fri, 25 Feb 2011) | 1 line
CXF-3362 Updated the continuation wrapper to support servlet3 async API better
........
Modified:
cxf/branches/2.3.x-fixes/ (props changed)
cxf/branches/2.3.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationWrapper.java
cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java
cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
svn:mergeinfo = /cxf/trunk:1074489
Propchange: cxf/branches/2.3.x-fixes/
------------------------------------------------------------------------------
Binary property 'svnmerge-integrated' - no diff available.
Modified:
cxf/branches/2.3.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationWrapper.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationWrapper.java?rev=1074516&r1=1074515&r2=1074516&view=diff
==============================================================================
---
cxf/branches/2.3.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationWrapper.java
(original)
+++
cxf/branches/2.3.x-fixes/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationWrapper.java
Fri Feb 25 13:25:41 2011
@@ -44,14 +44,15 @@ public class JettyContinuationWrapper im
Message m) {
req = (Request)request;
message = m;
- isNew = !req.isAsyncStarted();
+ isNew =
req.getAttribute(AbstractHTTPDestination.CXF_CONTINUATION_MESSAGE) == null;
if (isNew) {
req.setAttribute(AbstractHTTPDestination.CXF_CONTINUATION_MESSAGE,
message.getExchange().getInMessage());
context = req.startAsync(req, resp);
context.addContinuationListener(this);
+ req.setAttribute(AbstractHTTPDestination.CXF_ASYNC_CONTEXT,
context);
} else {
- context = req.getAsyncContext();
+ context =
(AsyncContext)req.getAttribute(AbstractHTTPDestination.CXF_ASYNC_CONTEXT);
}
}
Modified:
cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?rev=1074516&r1=1074515&r2=1074516&view=diff
==============================================================================
---
cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
(original)
+++
cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
Fri Feb 25 13:25:41 2011
@@ -95,6 +95,7 @@ public abstract class AbstractHTTPDestin
public static final String RESPONSE_COMMITED = "http.response.done";
public static final String REQUEST_REDIRECTED = "http.request.redirected";
public static final String CXF_CONTINUATION_MESSAGE =
"cxf.continuation.message";
+ public static final String CXF_ASYNC_CONTEXT = "cxf.async.context";
private static final String HTTP_HEADERS_SETCOOKIE = "Set-Cookie";
@@ -375,11 +376,10 @@ public abstract class AbstractHTTPDestin
}
return retrieveFromServlet3Async(req);
}
+
protected Message retrieveFromServlet3Async(HttpServletRequest req) {
try {
- if (req.isAsyncStarted()) {
- return (Message)req.getAttribute(CXF_CONTINUATION_MESSAGE);
- }
+ return (Message)req.getAttribute(CXF_CONTINUATION_MESSAGE);
} catch (Throwable ex) {
// the request may not implement the Servlet3 API
}
Modified:
cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java?rev=1074516&r1=1074515&r2=1074516&view=diff
==============================================================================
---
cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java
(original)
+++
cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java
Fri Feb 25 13:25:41 2011
@@ -38,6 +38,7 @@ public class Servlet3ContinuationProvide
HttpServletRequest req;
HttpServletResponse resp;
Message inMessage;
+ Servlet3Continuation continuation;
public Servlet3ContinuationProvider(HttpServletRequest req,
@@ -54,7 +55,10 @@ public class Servlet3ContinuationProvide
return null;
}
- return new Servlet3Continuation();
+ if (continuation == null) {
+ continuation = new Servlet3Continuation();
+ }
+ return continuation;
}
public class Servlet3Continuation implements Continuation, AsyncListener {
@@ -72,10 +76,12 @@ public class Servlet3ContinuationProvide
req.setAttribute(AbstractHTTPDestination.CXF_CONTINUATION_MESSAGE,
inMessage.getExchange().getInMessage());
context = req.startAsync(req, resp);
+ req.setAttribute(AbstractHTTPDestination.CXF_ASYNC_CONTEXT,
context);
context.addListener(this);
} else {
- context = req.getAsyncContext();
+ context =
(AsyncContext)req.getAttribute(AbstractHTTPDestination.CXF_ASYNC_CONTEXT);
}
+
}
public boolean suspend(long timeout) {
Modified:
cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
URL:
http://svn.apache.org/viewvc/cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java?rev=1074516&r1=1074515&r2=1074516&view=diff
==============================================================================
---
cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
(original)
+++
cxf/branches/2.3.x-fixes/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
Fri Feb 25 13:25:41 2011
@@ -72,19 +72,6 @@ public class ServletDestination extends
protected Logger getLogger() {
return LOG;
}
-
- protected Message retrieveFromServlet3Async(HttpServletRequest req) {
- // It looks current Servlet3 implementation request doesn't pass the
isAsyncStart
- // status to the redispatched request
- try {
- if (req.isAsyncSupported()) {
- return (Message)req.getAttribute(CXF_CONTINUATION_MESSAGE);
- }
- } catch (Throwable ex) {
- // the request may not implement the Servlet3 API
- }
- return null;
- }
public void invoke(final ServletContext context,
final HttpServletRequest req,