cxf-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ningji...@apache.org
Subject svn commit: r1522830 - /cxf/trunk/rt/frontend/simple/src/main/java/org/apache/cxf/frontend/WSDLGetInterceptor.java
Date Fri, 13 Sep 2013 09:35:24 GMT
Author: ningjiang
Date: Fri Sep 13 09:35:23 2013
New Revision: 1522830

URL: http://svn.apache.org/r1522830
Log:
CXF-5273 should not remove the interceptor base on the Phase

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=1522830&r1=1522829&r2=1522830&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
Fri Sep 13 09:35:23 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



Mime
View raw message