cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1074489 - in /cxf/trunk/rt/transports: http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/ http/src/main/java/org/apache/cxf/transport/http/ http/src/main/java/org/apache/cxf/transport/servlet/
Date Fri, 25 Feb 2011 12:03:01 GMT
Author: ningjiang
Date: Fri Feb 25 12:03:00 2011
New Revision: 1074489

URL: http://svn.apache.org/viewvc?rev=1074489&view=rev
Log:
CXF-3362 Updated the continuation wrapper to support servlet3 async API better

Modified:
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationWrapper.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java

Modified: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationWrapper.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationWrapper.java?rev=1074489&r1=1074488&r2=1074489&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationWrapper.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/continuations/JettyContinuationWrapper.java
Fri Feb 25 12:03:00 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/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java?rev=1074489&r1=1074488&r2=1074489&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
(original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java
Fri Feb 25 12:03:00 2011
@@ -93,6 +93,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";
 
     public static final String SERVICE_REDIRECTION = "http.service.redirection";
     
@@ -330,11 +331,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/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java?rev=1074489&r1=1074488&r2=1074489&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java
(original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/Servlet3ContinuationProvider.java
Fri Feb 25 12:03:00 2011
@@ -38,6 +38,7 @@ public class Servlet3ContinuationProvide
     HttpServletRequest req;
     HttpServletResponse resp; 
     Message inMessage;
+    Servlet3Continuation continuation;
     
     public Servlet3ContinuationProvider(HttpServletRequest req,
                                         HttpServletResponse resp, 
@@ -53,7 +54,10 @@ public class Servlet3ContinuationProvide
             return null;
         }
 
-        return new Servlet3Continuation();
+        if (continuation == null) {
+            continuation = new Servlet3Continuation();
+        }
+        return continuation;
     }
     
     public class Servlet3Continuation implements Continuation, AsyncListener {
@@ -71,10 +75,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/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java?rev=1074489&r1=1074488&r2=1074489&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
(original)
+++ cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/servlet/ServletDestination.java
Fri Feb 25 12:03:00 2011
@@ -23,11 +23,8 @@ import java.io.IOException;
 import java.net.URI;
 import java.util.logging.Logger;
 
-import javax.servlet.http.HttpServletRequest;
-
 import org.apache.cxf.Bus;
 import org.apache.cxf.common.logging.LogUtils;
-import org.apache.cxf.message.Message;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
 import org.apache.cxf.transport.http.DestinationRegistry;
@@ -62,21 +59,6 @@ public class ServletDestination extends 
         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;
-    }
-         
-
-
     protected String getBasePath(String contextPath) throws IOException {
         
         String address = getAddress().getAddress().getValue();



Mime
View raw message