Return-Path: X-Original-To: apmail-cxf-commits-archive@www.apache.org Delivered-To: apmail-cxf-commits-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id A3DE9C983 for ; Fri, 1 Nov 2013 14:10:38 +0000 (UTC) Received: (qmail 11818 invoked by uid 500); 1 Nov 2013 14:08:51 -0000 Delivered-To: apmail-cxf-commits-archive@cxf.apache.org Received: (qmail 11452 invoked by uid 500); 1 Nov 2013 14:08:39 -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 11419 invoked by uid 99); 1 Nov 2013 14:08:28 -0000 Received: from athena.apache.org (HELO athena.apache.org) (140.211.11.136) by apache.org (qpsmtpd/0.29) with ESMTP; Fri, 01 Nov 2013 14:08:28 +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; Fri, 01 Nov 2013 14:08:27 +0000 Received: from eris.apache.org (localhost [127.0.0.1]) by eris.apache.org (Postfix) with ESMTP id 58AED23888E4; Fri, 1 Nov 2013 14:08:07 +0000 (UTC) Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit 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 -0000 To: commits@cxf.apache.org From: sergeyb@apache.org X-Mailer: svnmailer-1.0.9 Message-Id: <20131101140807.58AED23888E4@eris.apache.org> X-Virus-Checked: Checked by ClamAV on apache.org 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> 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 { + + 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" + + +