You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by gn...@apache.org on 2010/05/13 20:02:57 UTC

svn commit: r943957 - /servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java

Author: gnodet
Date: Thu May 13 18:02:57 2010
New Revision: 943957

URL: http://svn.apache.org/viewvc?rev=943957&view=rev
Log:
SMXCOMP-744: Cache the servicemix-cxf-bc interceptor chain

Modified:
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java?rev=943957&r1=943956&r2=943957&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java (original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java Thu May 13 18:02:57 2010
@@ -42,6 +42,7 @@ import javax.xml.transform.TransformerEx
 import javax.xml.transform.TransformerFactory;
 import javax.xml.transform.dom.DOMSource;
 
+import org.apache.cxf.phase.PhaseChainCache;
 import org.w3c.dom.Document;
 import org.w3c.dom.Element;
 import org.w3c.dom.Node;
@@ -154,7 +155,32 @@ public class CxfBcProvider extends Provi
     private List<AbstractFeature> features = new CopyOnWriteArrayList<AbstractFeature>();
     
     private Map<String, Object> properties = new ConcurrentHashMap<String, Object>();    
-    
+
+    private List<Interceptor> outList;
+
+    private PhaseChainCache cache = new PhaseChainCache();
+
+
+    @Override
+    public void activate() throws Exception {
+        super.activate();
+        outList = new ArrayList<Interceptor>();
+        if (isMtomEnabled()) {
+            outList.add(new JbiOutInterceptor());
+            outList.add(new MtomCheckInterceptor(true));
+            outList.add(new AttachmentOutInterceptor());
+        }
+
+        outList.add(new JbiOutInterceptor());
+        if (isSchemaValidationEnabled()) {
+            outList.add(new SchemaValidationOutInterceptor(isUseJBIWrapper(), isUseSOAPEnvelope()));
+        }
+        outList.add(new JbiOutWsdl1Interceptor(isUseJBIWrapper(), isUseSOAPEnvelope()));
+        outList.add(new SoapPreProtocolOutInterceptor());
+        outList.add(new SoapOutInterceptor(getBus()));
+        outList.add(new SoapActionOutInterceptor());
+        outList.add(new StaxOutInterceptor());
+    }
 
     public void processExchange(MessageExchange exchange) {
 
@@ -205,36 +231,19 @@ public class CxfBcProvider extends Provi
         cxfExchange.put(Service.class, cxfService);
         cxfExchange.put(Bus.class, getBus());
         PhaseManager pm = getBus().getExtension(PhaseManager.class);
-        List<Interceptor> outList = new ArrayList<Interceptor>();
-        if (isMtomEnabled()) {
-            outList.add(new JbiOutInterceptor());
-            outList.add(new MtomCheckInterceptor(true));
-            outList.add(new AttachmentOutInterceptor());
-        }
-         
-        outList.add(new JbiOutInterceptor());
-        if (isSchemaValidationEnabled()) {
-            outList.add(new SchemaValidationOutInterceptor(isUseJBIWrapper(), isUseSOAPEnvelope()));
-        }
-        outList.add(new JbiOutWsdl1Interceptor(isUseJBIWrapper(), isUseSOAPEnvelope()));
-        outList.add(new SoapPreProtocolOutInterceptor());
-        outList.add(new SoapOutInterceptor(getBus()));
-        outList.add(new SoapActionOutInterceptor());
-        outList.add(new StaxOutInterceptor());
-        
+
         
-        PhaseInterceptorChain outChain = new PhaseInterceptorChain(pm.getOutPhases());
-        outChain.add(outList);
-        outChain.add(getBus().getOutInterceptors());
-        outChain.add(getBus().getOutFaultInterceptors());
-        outChain.add(getOutInterceptors());
-        outChain.add(getOutFaultInterceptors());
+        PhaseInterceptorChain outChain = cache.get(pm.getOutPhases(), 
+                                                   outList,
+                                                   getBus().getOutInterceptors(),
+                                                   getBus().getOutFaultInterceptors(),
+                                                   getOutInterceptors(),
+                                                   getOutFaultInterceptors());
 
         message.setInterceptorChain(outChain);
         message.setContent(Source.class, nm.getContent());
 
         conduit.prepare(message);
-        OutputStream os = message.getContent(OutputStream.class);
         
         message.put(org.apache.cxf.message.Message.REQUESTOR_ROLE, true);
         try {
@@ -249,7 +258,7 @@ public class CxfBcProvider extends Provi
                 throw ex;
             }
             
-            os = message.getContent(OutputStream.class);
+            OutputStream os = message.getContent(OutputStream.class);
             os.flush();
             os.close();
         } catch (Exception e) {