You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@cxf.apache.org by ni...@apache.org on 2013/09/12 05:39:38 UTC

svn commit: r1522231 - /cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java

Author: ningjiang
Date: Thu Sep 12 03:39:38 2013
New Revision: 1522231

URL: http://svn.apache.org/r1522231
Log:
CXF-5273 polish the code of WSDLGetInterceptor

Modified:
    cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java

Modified: cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java
URL: http://svn.apache.org/viewvc/cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java?rev=1522231&r1=1522230&r2=1522231&view=diff
==============================================================================
--- cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java (original)
+++ cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java Thu Sep 12 03:39:38 2013
@@ -30,25 +30,29 @@ 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();
     public static final String DOCUMENT_HOLDER = WSDLGetInterceptor.class.getName() + ".documentHolder";
-
+    private Interceptor<Message> wsdlGetOutInterceptor = WSDLGetOutInterceptor.INSTANCE;
+    
     public WSDLGetInterceptor() {
         super(Phase.READ);
         getAfter().add(EndpointSelectionInterceptor.class.getName());
     }
-
+    
+    public WSDLGetInterceptor(Interceptor<Message> outInterceptor) {
+        this();
+        // Let people override the wsdlGetOutInterceptor 
+        wsdlGetOutInterceptor = outInterceptor;
+    }
+    
     public void handleMessage(Message message) throws Fault {
         String method = (String)message.get(Message.HTTP_REQUEST_METHOD);
         String query = (String)message.get(Message.QUERY_STRING);
@@ -79,15 +83,20 @@ public class WSDLGetInterceptor extends 
             Iterator<Interceptor<? extends Message>> iterator = mout.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)) {
+                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);
                 }
             }
 
             // notice this is being added after the purge above, don't swap the order!
-            mout.getInterceptorChain().add(WSDLGetOutInterceptor.INSTANCE);
+            mout.getInterceptorChain().add(wsdlGetOutInterceptor);
 
             // skip the service executor and goto the end of the chain.
             message.getInterceptorChain().doInterceptStartingAt(