cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From serg...@apache.org
Subject svn commit: r1537939 - in /cxf/trunk: rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/ systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/ systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/
Date Fri, 01 Nov 2013 14:08:07 GMT
Author: sergeyb
Date: Fri Nov  1 14:08:06 2013
New Revision: 1537939

URL: http://svn.apache.org/r1537939
Log:
[CXF-5371] Updating JAXRSInInterceptor to skip the rest of the in chain if Response is ready

Added:
    cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/ResponseCheckInterceptor.java
  (with props)
Modified:
    cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
    cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml

Modified: cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java?rev=1537939&r1=1537938&r2=1537939&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
(original)
+++ cxf/trunk/rt/frontend/jaxrs/src/main/java/org/apache/cxf/jaxrs/interceptor/JAXRSInInterceptor.java
Fri Nov  1 14:08:06 2013
@@ -87,8 +87,12 @@ public class JAXRSInInterceptor extends 
         } catch (RuntimeException ex) {
             convertExceptionToResponseIfPossible(ex, message);
         }
-        
-        
+        Response r = message.getExchange().get(Response.class);
+        if (r != null) {
+            createOutMessage(message, r);
+            message.getInterceptorChain().doInterceptStartingAt(message,
+                                                                OutgoingChainInterceptor.class.getName());
+        }
     }
     
     private void processRequest(Message message) {
@@ -266,14 +270,7 @@ public class JAXRSInInterceptor extends 
                     message.put(FaultListener.class.getName(), new NoOpFaultListener());
                 }
                 
-                Endpoint e = message.getExchange().get(Endpoint.class);
-                Message mout = new MessageImpl();
-                mout.setContent(List.class, new MessageContentsList(r));
-                mout.setExchange(message.getExchange());
-                mout = e.getBinding().createMessage(mout);
-                mout.setInterceptorChain(OutgoingChainInterceptor.getOutInterceptorChain(message.getExchange()));
-                message.getExchange().setOutMessage(mout);
-                
+                createOutMessage(message, r);
                 
                 Iterator<Interceptor<? extends Message>> iterator = message.getInterceptorChain().iterator();
                 while (iterator.hasNext()) {
@@ -304,4 +301,16 @@ public class JAXRSInInterceptor extends 
             cri.clearThreadLocalProxies();
         }
     }
+    
+    private Message createOutMessage(Message inMessage, Response r) {
+        Endpoint e = inMessage.getExchange().get(Endpoint.class);
+        Message mout = new MessageImpl();
+        mout.setContent(List.class, new MessageContentsList(r));
+        mout.setExchange(inMessage.getExchange());
+        mout = e.getBinding().createMessage(mout);
+        mout.setInterceptorChain(
+             OutgoingChainInterceptor.getOutInterceptorChain(inMessage.getExchange()));
+        inMessage.getExchange().setOutMessage(mout);
+        return mout;
+    }
 }

Added: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/ResponseCheckInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/ResponseCheckInterceptor.java?rev=1537939&view=auto
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/ResponseCheckInterceptor.java
(added)
+++ cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/ResponseCheckInterceptor.java
Fri Nov  1 14:08:06 2013
@@ -0,0 +1,46 @@
+/**
+ * Licensed to the Apache Software Foundation (ASF) under one
+ * or more contributor license agreements. See the NOTICE file
+ * distributed with this work for additional information
+ * regarding copyright ownership. The ASF licenses this file
+ * to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance
+ * with the License. You may obtain a copy of the License at
+ *
+ * http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing,
+ * software distributed under the License is distributed on an
+ * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
+ * KIND, either express or implied. See the License for the
+ * specific language governing permissions and limitations
+ * under the License.
+ */
+package org.apache.cxf.systest.jaxrs;
+
+import javax.ws.rs.WebApplicationException;
+import javax.ws.rs.core.Response;
+
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+
+public class ResponseCheckInterceptor extends AbstractPhaseInterceptor<Message> {
+
+    public ResponseCheckInterceptor() {
+        super(Phase.PRE_INVOKE);
+    }
+
+    public void handleMessage(Message message) throws Fault {
+        if (message.getExchange().get(Response.class) != null) {
+            throw new WebApplicationException(500);
+        }
+        
+        String query = (String)message.get(Message.QUERY_STRING);
+        if (query != null && query.contains("wadl")) {
+            throw new WebApplicationException(500);
+        }
+    }
+
+}

Propchange: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/ResponseCheckInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: cxf/trunk/systests/jaxrs/src/test/java/org/apache/cxf/systest/jaxrs/ResponseCheckInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml
URL: http://svn.apache.org/viewvc/cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml?rev=1537939&r1=1537938&r2=1537939&view=diff
==============================================================================
--- cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml (original)
+++ cxf/trunk/systests/jaxrs/src/test/resources/jaxrs_spring_providers/WEB-INF/beans.xml Fri
Nov  1 14:08:06 2013
@@ -45,6 +45,9 @@ http://cxf.apache.org/schemas/jaxrs.xsd"
         <jaxrs:serviceBeans>
             <ref bean="petstore"/>
         </jaxrs:serviceBeans>
+        <jaxrs:inInterceptors>
+           <bean class="org.apache.cxf.systest.jaxrs.ResponseCheckInterceptor"/>
+        </jaxrs:inInterceptors>
         <jaxrs:providers>
             <bean class="org.apache.cxf.jaxrs.provider.JAXBElementProvider">
                 <property name="marshallAsJaxbElement" value="true"/>



Mime
View raw message