Author: ningjiang Date: Fri Sep 13 09:52:49 2013 New Revision: 1522840 URL: http://svn.apache.org/r1522840 Log: Merged revisions 1522830 via svnmerge from https://svn.apache.org/repos/asf/cxf/trunk
........ r1522830 | ningjiang | 2013-09-13 17:35:23 +0800 (Fri, 13 Sep 2013) | 1 line CXF-5273 should not remove the interceptor base on the Phase ........ Modified: cxf/branches/2.7.x-fixes/ (props changed) cxf/branches/2.7.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java Propchange: cxf/branches/2.7.x-fixes/ ------------------------------------------------------------------------------ Merged /cxf/trunk:r1522830 Propchange: cxf/branches/2.7.x-fixes/ ------------------------------------------------------------------------------ Binary property 'svnmerge-integrated' - no diff available. Modified: cxf/branches/2.7.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java URL: http://svn.apache.org/viewvc/cxf/branches/2.7.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java?rev=1522840&r1=1522839&r2=1522840&view=diff ============================================================================== --- cxf/branches/2.7.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java (original) +++ cxf/branches/2.7.x-fixes/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java Fri Sep 13 09:52:49 2013 @@ -30,12 +30,15 @@ import org.apache.cxf.common.util.UrlUti import org.apache.cxf.endpoint.Endpoint; import org.apache.cxf.interceptor.Fault; import org.apache.cxf.interceptor.Interceptor; +import org.apache.cxf.interceptor.MessageSenderInterceptor; import org.apache.cxf.interceptor.OutgoingChainInterceptor; +import org.apache.cxf.interceptor.StaxOutInterceptor; import org.apache.cxf.message.Message; import org.apache.cxf.message.MessageImpl; import org.apache.cxf.phase.AbstractPhaseInterceptor; import org.apache.cxf.phase.Phase; import org.apache.cxf.service.model.EndpointInfo; +import org.apache.cxf.transport.common.gzip.GZIPOutInterceptor; public class WSDLGetInterceptor extends AbstractPhaseInterceptor<Message> { public static final WSDLGetInterceptor INSTANCE = new WSDLGetInterceptor(); @@ -77,25 +80,9 @@ public class WSDLGetInterceptor extends message.getExchange().setOutMessage(mout); mout.put(DOCUMENT_HOLDER, doc); - - // TODO - how can I improve this to provide a specific interceptor chain that just has the - // stax, gzip and message sender components, while also ensuring that GZIP is only provided - // if its already configured for the endpoint. - Iterator<Interceptor<? extends Message>> iterator = mout.getInterceptorChain().iterator(); - while (iterator.hasNext()) { - Interceptor<? extends Message> inInterceptor = iterator.next(); - if (inInterceptor instanceof AbstractPhaseInterceptor) { - AbstractPhaseInterceptor<?> interceptor = (AbstractPhaseInterceptor<?>)inInterceptor; - if (interceptor.getPhase().equals(Phase.PREPARE_SEND) - || interceptor.getPhase().equals(Phase.PRE_STREAM)) { - // just make sure we keep the right interceptors - // like stax, gzip and sendingInterceptor here - continue; - } - mout.getInterceptorChain().remove(inInterceptor); - } - } - + // just remove the interceptor which should not be used + cleanUpOutInterceptors(mout); + // notice this is being added after the purge above, don't swap the order! mout.getInterceptorChain().add(wsdlGetOutInterceptor); @@ -106,6 +93,22 @@ public class WSDLGetInterceptor extends OutgoingChainInterceptor.class.getName()); } } + + protected void cleanUpOutInterceptors(Message outMessage) { + // TODO - how can I improve this to provide a specific interceptor chain that just has the + // stax, gzip and message sender components, while also ensuring that GZIP is only provided + // if its already configured for the endpoint. + Iterator<Interceptor<? extends Message>> iterator = outMessage.getInterceptorChain().iterator(); + while (iterator.hasNext()) { + Interceptor<? extends Message> inInterceptor = iterator.next(); + if (!inInterceptor.getClass().equals(StaxOutInterceptor.class) + && !inInterceptor.getClass().equals(GZIPOutInterceptor.class) + && !inInterceptor.getClass().equals(MessageSenderInterceptor.class)) { + outMessage.getInterceptorChain().remove(inInterceptor); + } + } + + } private Document getDocument(Message message, String base, Map<String, String> params, String ctxUri) { // cannot have two wsdl's being generated for the same endpoint at the same