Return-Path: Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: (qmail 54251 invoked from network); 24 Feb 2011 14:13:35 -0000 Received: from hermes.apache.org (HELO mail.apache.org) (140.211.11.3) by minotaur.apache.org with SMTP; 24 Feb 2011 14:13:35 -0000 Received: (qmail 63499 invoked by uid 500); 24 Feb 2011 14:13:35 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 63230 invoked by uid 500); 24 Feb 2011 14:13:32 -0000 Mailing-List: contact commits-help@cxf.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@cxf.apache.org Delivered-To: mailing list commits@cxf.apache.org Received: (qmail 63220 invoked by uid 99); 24 Feb 2011 14:13:31 -0000 Received: from nike.apache.org (HELO nike.apache.org) (192.87.106.230) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Feb 2011 14:13:31 +0000 X-ASF-Spam-Status: No, hits=-2000.0 required=5.0 tests=ALL_TRUSTED X-Spam-Check-By: apache.org Received: from [140.211.11.4] (HELO eris.apache.org) (140.211.11.4) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 24 Feb 2011 14:13:29 +0000 Received: by eris.apache.org (Postfix, from userid 65534) id C789A2388A36; Thu, 24 Feb 2011 14:13:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit Subject: svn commit: r1074157 - in /cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport: http/AbstractHTTPDestination.java http/Servlet3ContinuationProvider.java servlet/ServletDestination.java Date: Thu, 24 Feb 2011 14:13:07 -0000 To: commits@cxf.apache.org From: ningjiang@apache.org X-Mailer: svnmailer-1.0.8 Message-Id: <20110224141307.C789A2388A36@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org Author: ningjiang Date: Thu Feb 24 14:13:07 2011 New Revision: 1074157 URL: http://svn.apache.org/viewvc?rev=1074157&view=rev Log: CXF-3362 Fix the issue of CXF Servlet deploying into Servlet3 container Modified: 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/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=1074157&r1=1074156&r2=1074157&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 Thu Feb 24 14:13:07 2011 @@ -48,6 +48,7 @@ import org.apache.cxf.common.util.String import org.apache.cxf.configuration.Configurable; import org.apache.cxf.configuration.security.AuthorizationPolicy; import org.apache.cxf.continuations.ContinuationProvider; +import org.apache.cxf.continuations.SuspendedInvocationException; import org.apache.cxf.helpers.HttpHeaderHelper; import org.apache.cxf.interceptor.Fault; import org.apache.cxf.interceptor.Interceptor; @@ -180,20 +181,32 @@ public abstract class AbstractHTTPDestin final ServletContext context, final HttpServletRequest req, final HttpServletResponse resp) throws IOException { - - MessageImpl inMessage = new MessageImpl(); - setupMessage(inMessage, + Message inMessage = retrieveFromContinuation(req); + if (inMessage == null) { + LOG.fine("Create a new message for processing"); + inMessage = new MessageImpl(); + setupMessage(inMessage, config, context, req, resp); - ExchangeImpl exchange = new ExchangeImpl(); - exchange.setInMessage(inMessage); - exchange.setSession(new HTTPSession(req)); - inMessage.setDestination(this); + ExchangeImpl exchange = new ExchangeImpl(); + exchange.setInMessage(inMessage); + exchange.setSession(new HTTPSession(req)); + ((MessageImpl)inMessage).setDestination(this); + } else { + LOG.fine("Get the message from the request for processing"); + } - incomingObserver.onMessage(inMessage); + try { + incomingObserver.onMessage(inMessage); + } catch (SuspendedInvocationException ex) { + if (ex.getRuntimeException() != null) { + throw ex.getRuntimeException(); + } + //else nothing to do, just finishing the processing + } } @@ -309,17 +322,25 @@ public abstract class AbstractHTTPDestin return retrieveFromServlet3Async(req); } protected Message retrieveFromServlet3Async(HttpServletRequest req) { - if (req.isAsyncStarted()) { - return (Message)req.getAttribute(CXF_CONTINUATION_MESSAGE); + try { + if (req.isAsyncStarted()) { + return (Message)req.getAttribute(CXF_CONTINUATION_MESSAGE); + } + } catch (Throwable ex) { + // the request may not implement the Servlet3 API } return null; } - protected void setupContinuation(Message inMessage, - final HttpServletRequest req, - final HttpServletResponse resp) { - if (isServlet3) { - inMessage.put(ContinuationProvider.class.getName(), - new Servlet3ContinuationProvider(req, resp, inMessage)); + + protected void setupContinuation(Message inMessage, final HttpServletRequest req, + final HttpServletResponse resp) { + try { + if (isServlet3 && req.isAsyncSupported()) { + inMessage.put(ContinuationProvider.class.getName(), + new Servlet3ContinuationProvider(req, resp, inMessage)); + } + } catch (Throwable ex) { + // the request may not implement the Servlet3 API } } protected String getBasePath(String contextPath) throws IOException { 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=1074157&r1=1074156&r2=1074157&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 Thu Feb 24 14:13:07 2011 @@ -64,7 +64,9 @@ public class Servlet3ContinuationProvide Object obj; public Servlet3Continuation() { - isNew = !req.isAsyncStarted(); + // It looks current Servlet3 implementation request doesn't pass the isAsyncStart + // status to the redispatched request, so we use the attribute to check the statues + isNew = req.getAttribute(AbstractHTTPDestination.CXF_CONTINUATION_MESSAGE) == null; if (isNew) { req.setAttribute(AbstractHTTPDestination.CXF_CONTINUATION_MESSAGE, inMessage.getExchange().getInMessage()); @@ -83,7 +85,6 @@ public class Servlet3ContinuationProvide isNew = false; // Need to get the right message which is handled in the interceptor chain inMessage.getExchange().getInMessage().getInterceptorChain().suspend(); - isPending = true; return true; } 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=1074157&r1=1074156&r2=1074157&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 Thu Feb 24 14:13:07 2011 @@ -23,8 +23,11 @@ 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; @@ -58,6 +61,21 @@ 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; + } + + protected String getBasePath(String contextPath) throws IOException {