cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dk...@apache.org
Subject svn commit: r1544657 - in /cxf/trunk/rt: frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/ transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/ transports/http-jetty/src/test/java/org/apache/cxf/transport/http...
Date Fri, 22 Nov 2013 19:28:08 GMT
Author: dkulp
Date: Fri Nov 22 19:28:07 2013
New Revision: 1544657

URL: http://svn.apache.org/r1544657
Log:
Reduce some duplicate code between the various HTTP providers

Modified:
    cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiDestination.java
    cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
    cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpDestination.java
    cxf/trunk/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/netty/server/NettyHttpDestinationTest.java
    cxf/trunk/rt/transports/http/src/main/java/org/apache/cxf/transport/http/AbstractHTTPDestination.java

Modified: cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiDestination.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiDestination.java?rev=1544657&r1=1544656&r2=1544657&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiDestination.java
(original)
+++ cxf/trunk/rt/frontend/jaxws/src/main/jaxws22/org/apache/cxf/transport/http_jaxws_spi/JAXWSHttpSpiDestination.java
Fri Nov 22 19:28:07 2013
@@ -85,7 +85,8 @@ public class JAXWSHttpSpiDestination ext
         Message inMessage = new MessageImpl();
         ExchangeImpl exchange = new ExchangeImpl();
         exchange.setInMessage(inMessage);
-        setupMessage(inMessage, null, req, resp);
+        
+        setupMessage(inMessage, null, req.getServletContext(), req, resp);
 
         ((MessageImpl)inMessage).setDestination(this);
 

Modified: cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java?rev=1544657&r1=1544656&r2=1544657&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/main/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestination.java
Fri Nov 22 19:28:07 2013
@@ -42,17 +42,13 @@ import org.apache.cxf.common.util.Reflec
 import org.apache.cxf.configuration.jsse.TLSServerParameters;
 import org.apache.cxf.configuration.security.CertificateConstraintsType;
 import org.apache.cxf.continuations.ContinuationProvider;
-import org.apache.cxf.continuations.SuspendedInvocationException;
 import org.apache.cxf.helpers.IOUtils;
 import org.apache.cxf.interceptor.Fault;
 import org.apache.cxf.io.CopyingOutputStream;
-import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
-import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
 import org.apache.cxf.transport.http.DestinationRegistry;
-import org.apache.cxf.transport.http.HTTPSession;
 import org.apache.cxf.transport.http_jetty.continuations.JettyContinuationProvider;
 import org.apache.cxf.transport.https.CertConstraintsJaxBUtils;
 import org.eclipse.jetty.http.Generator;
@@ -248,7 +244,7 @@ public class JettyHTTPDestination extend
             if (loader != null) {
                 origLoader = ClassLoaderUtils.setThreadContextClassloader(loader);
             }
-            serviceRequest(context, req, resp);
+            invoke(null, context, req, resp);
         } finally {
             if (origBus != bus) {
                 BusFactory.setThreadDefaultBus(origBus);
@@ -258,58 +254,16 @@ public class JettyHTTPDestination extend
             }
         }    
     }
-
-    protected void serviceRequest(final ServletContext context, 
+    
+    protected void invokeComplete(final ServletContext context, 
                                   final HttpServletRequest req, 
-                                  final HttpServletResponse resp)
-        throws IOException {
+                                  final HttpServletResponse resp,
+                                  Message m) throws IOException {
+        resp.flushBuffer();
         Request baseRequest = (req instanceof Request) 
             ? (Request)req : getCurrentRequest();
-        
-        if (LOG.isLoggable(Level.FINE)) {
-            LOG.fine("Service http request on thread: " + Thread.currentThread());
-        }
-        Message inMessage = retrieveFromContinuation(req);
-        
-        if (inMessage == null) {
-            
-            inMessage = new MessageImpl();
-            ExchangeImpl exchange = new ExchangeImpl();
-            exchange.setInMessage(inMessage);
-            setupMessage(inMessage, context, req, resp);
-            
-            ((MessageImpl)inMessage).setDestination(this);
-    
-            exchange.setSession(new HTTPSession(req));
-        }
-        
-        try {    
-            incomingObserver.onMessage(inMessage);
-            resp.flushBuffer();
-            baseRequest.setHandled(true);
-            ContinuationProvider p = inMessage.get(ContinuationProvider.class);
-            if (p != null) {
-                p.complete();
-            }
-        } catch (SuspendedInvocationException ex) {
-            if (ex.getRuntimeException() != null) {
-                throw ex.getRuntimeException();
-            }
-            //else nothing to do
-        } catch (Fault ex) {
-            Throwable cause = ex.getCause();
-            if (cause instanceof RuntimeException) {
-                throw (RuntimeException)cause;
-            } else {
-                throw ex;
-            }
-        } catch (RuntimeException ex) {
-            throw ex;
-        } finally {
-            if (LOG.isLoggable(Level.FINE)) {
-                LOG.fine("Finished servicing http request on thread: " + Thread.currentThread());
-            }
-        }
+        baseRequest.setHandled(true);
+        super.invokeComplete(context, req, resp, m);
     }
     
     protected OutputStream flushHeaders(Message outMessage, boolean getStream) throws IOException
{

Modified: cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java?rev=1544657&r1=1544656&r2=1544657&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
(original)
+++ cxf/trunk/rt/transports/http-jetty/src/test/java/org/apache/cxf/transport/http_jetty/JettyHTTPDestinationTest.java
Fri Nov 22 19:28:07 2013
@@ -664,6 +664,7 @@ public class JettyHTTPDestinationTest ex
                 EasyMock.expect(request.getHeader("Accept")).andReturn("*/*");  
                 EasyMock.expect(request.getContentType()).andReturn("text/xml charset=utf8").times(2);
                 EasyMock.expect(request.getAttribute("org.eclipse.jetty.ajax.Continuation")).andReturn(null);
+                EasyMock.expect(request.getAttribute("http.service.redirection")).andReturn(null).anyTimes();
                 
                 HttpFields httpFields = new HttpFields();
                 httpFields.add("content-type", "text/xml");

Modified: cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpDestination.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpDestination.java?rev=1544657&r1=1544656&r2=1544657&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpDestination.java
(original)
+++ cxf/trunk/rt/transports/http-netty/netty-server/src/main/java/org/apache/cxf/transport/http/netty/server/NettyHttpDestination.java
Fri Nov 22 19:28:07 2013
@@ -36,16 +36,11 @@ import org.apache.cxf.common.classloader
 import org.apache.cxf.common.classloader.ClassLoaderUtils.ClassLoaderHolder;
 import org.apache.cxf.common.logging.LogUtils;
 import org.apache.cxf.common.util.StringUtils;
-import org.apache.cxf.continuations.ContinuationProvider;
-import org.apache.cxf.continuations.SuspendedInvocationException;
 import org.apache.cxf.interceptor.Fault;
-import org.apache.cxf.message.ExchangeImpl;
 import org.apache.cxf.message.Message;
-import org.apache.cxf.message.MessageImpl;
 import org.apache.cxf.service.model.EndpointInfo;
 import org.apache.cxf.transport.http.AbstractHTTPDestination;
 import org.apache.cxf.transport.http.DestinationRegistry;
-import org.apache.cxf.transport.http.HTTPSession;
 
 public class NettyHttpDestination extends AbstractHTTPDestination {
 
@@ -176,7 +171,7 @@ public class NettyHttpDestination extend
             if (loader != null) {
                 origLoader = ClassLoaderUtils.setThreadContextClassloader(loader);
             }
-            serviceRequest(context, req, resp);
+            invoke(null, context, req, resp);
         } finally {
             if (origBus != bus) {
                 BusFactory.setThreadDefaultBus(origBus);
@@ -186,59 +181,15 @@ public class NettyHttpDestination extend
             }
         }
     }
-
-    protected void serviceRequest(final ServletContext context,
-                                  final HttpServletRequest req,
-                                  final HttpServletResponse resp)
-        throws IOException {
-
-        if (LOG.isLoggable(Level.FINE)) {
-            LOG.fine("Service http request on thread: " + Thread.currentThread());
-        }
-        Message inMessage = retrieveFromContinuation(req);
-
-        if (inMessage == null) {
-
-            ExchangeImpl exchange = new ExchangeImpl();
-            inMessage = new MessageImpl();
-            exchange.setInMessage(inMessage);
-            setupMessage(inMessage, context, req, resp);
-
-            ((MessageImpl) inMessage).setDestination(this);
-
-            exchange.setSession(new HTTPSession(req));
-        }
-
-        try {
-            incomingObserver.onMessage(inMessage);
-
-            resp.flushBuffer();
-            ContinuationProvider p = inMessage.get(ContinuationProvider.class);
-            if (p != null) {
-                p.complete();
-            }
-        } catch (SuspendedInvocationException ex) {
-            if (ex.getRuntimeException() != null) {
-                throw ex.getRuntimeException();
-            }
-            //else nothing to do
-        } catch (Fault ex) {
-            Throwable cause = ex.getCause();
-            if (cause instanceof RuntimeException) {
-                throw (RuntimeException) cause;
-            } else {
-                throw ex;
-            }
-        } catch (RuntimeException ex) {
-            throw ex;
-        } finally {
-            if (LOG.isLoggable(Level.FINE)) {
-                LOG.fine("Finished servicing http request on thread: " + Thread.currentThread());
-            }
-        }
+    
+    protected void invokeComplete(final ServletContext context, 
+                                  final HttpServletRequest req, 
+                                  final HttpServletResponse resp,
+                                  Message m) throws IOException {
+        resp.flushBuffer();
+        super.invokeComplete(context, req, resp, m);
     }
 
-
     public ServerEngine getEngine() {
         return engine;
     }

Modified: cxf/trunk/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/netty/server/NettyHttpDestinationTest.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/netty/server/NettyHttpDestinationTest.java?rev=1544657&r1=1544656&r2=1544657&view=diff
==============================================================================
--- cxf/trunk/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/netty/server/NettyHttpDestinationTest.java
(original)
+++ cxf/trunk/rt/transports/http-netty/netty-server/src/test/java/org/apache/cxf/transport/http/netty/server/NettyHttpDestinationTest.java
Fri Nov 22 19:28:07 2013
@@ -661,6 +661,7 @@ public class NettyHttpDestinationTest ex
                 EasyMock.expect(request.getHeader("Accept")).andReturn("*/*");  
                 EasyMock.expect(request.getContentType()).andReturn("text/xml charset=utf8").times(2);
                 EasyMock.expect(request.getAttribute("org.eclipse.jetty.ajax.Continuation")).andReturn(null);
+                EasyMock.expect(request.getAttribute("http.service.redirection")).andReturn(null).anyTimes();
 
                 List<String> contentType = new ArrayList<String>();
                 contentType.add("text/xml");

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=1544657&r1=1544656&r2=1544657&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 Nov 22 19:28:07 2013
@@ -212,7 +212,7 @@ public abstract class AbstractHTTPDestin
         return ex == null ? false : ex.isOneWay();
     }
     
-    public void invoke(final ServletConfig config,
+    public void invoke(final ServletConfig config, 
                        final ServletContext context, 
                        final HttpServletRequest req, 
                        final HttpServletResponse resp) throws IOException {
@@ -238,31 +238,42 @@ public abstract class AbstractHTTPDestin
         
         try {    
             incomingObserver.onMessage(inMessage);
-            ContinuationProvider p = inMessage.get(ContinuationProvider.class);
-            if (p != null) {
-                p.complete();
-            }
+            invokeComplete(context, req, resp, inMessage);
         } catch (SuspendedInvocationException ex) {
             if (ex.getRuntimeException() != null) {
                 throw ex.getRuntimeException();
             }
             //else nothing to do, just finishing the processing
+        } catch (Fault ex) {
+            Throwable cause = ex.getCause();
+            if (cause instanceof RuntimeException) {
+                throw (RuntimeException)cause;
+            } else {
+                throw ex;
+            }
+        } catch (RuntimeException ex) {
+            throw ex;
+        } finally {
+            if (LOG.isLoggable(Level.FINE)) {
+                LOG.fine("Finished servicing http request on thread: " + Thread.currentThread());
+            }
+        }
+    }
+    
+    protected void invokeComplete(final ServletContext context, 
+                                  final HttpServletRequest req, 
+                                  final HttpServletResponse resp,
+                                  Message m) throws IOException {
+        ContinuationProvider p = m.get(ContinuationProvider.class);
+        if (p != null) {
+            p.complete();
         }
-
- 
     }
 
     private void copyKnownRequestAttributes(HttpServletRequest request, Message message)
{
         message.put(SERVICE_REDIRECTION, request.getAttribute(SERVICE_REDIRECTION));
     }
-    
-    protected void setupMessage(Message inMessage,
-                                final ServletContext context, 
-                                final HttpServletRequest req, 
-                                final HttpServletResponse resp) throws IOException {
-        setupMessage(inMessage, null, context, req, resp);
-    }
-    
+        
     protected void setupMessage(final Message inMessage,
                                 final ServletConfig config,
                                 final ServletContext context, 



Mime
View raw message