servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r671114 - in /servicemix/components/bindings/servicemix-cxf-bc/trunk/src: main/java/org/apache/servicemix/cxfbc/ main/java/org/apache/servicemix/cxfbc/interceptors/ test/java/org/apache/servicemix/cxfbc/provider/ test/resources/org/apache/s...
Date Tue, 24 Jun 2008 10:13:43 GMT
Author: ffang
Date: Tue Jun 24 03:13:43 2008
New Revision: 671114

URL: http://svn.apache.org/viewvc?rev=671114&view=rev
Log:
[SM-1419]cxf bc provider should load cxf bus interceptor configuration as well

Added:
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/RetrievePayLoadInterceptor.java
  (with props)
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/log-feature.xml
  (with props)
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_bus_logger_feature.xml
  (with props)
Modified:
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProvider.java
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/provider/CxfBCSEProviderSystemTest.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=671114&r1=671113&r2=671114&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
Tue Jun 24 03:13:43 2008
@@ -34,8 +34,6 @@
 import javax.wsdl.factory.WSDLFactory;
 import javax.wsdl.xml.WSDLReader;
 import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamWriter;
 import javax.xml.transform.Source;
 import javax.xml.transform.dom.DOMSource;
 import javax.xml.transform.stream.StreamSource;
@@ -72,7 +70,6 @@
 import org.apache.cxf.service.Service;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.service.model.OperationInfo;
 import org.apache.cxf.service.model.SchemaInfo;
 import org.apache.cxf.service.model.ServiceInfo;
 import org.apache.cxf.transport.Conduit;
@@ -189,6 +186,14 @@
         outList.add(new SoapPreProtocolOutInterceptor());
         outList.add(new SoapOutInterceptor(getBus()));
         outList.add(new SoapActionOutInterceptor());
+        outList.add(new StaxOutInterceptor());
+        
+        
+        getInInterceptors().addAll(getBus().getInInterceptors());
+        getInFaultInterceptors().addAll(getBus().getInFaultInterceptors());
+        getOutInterceptors().addAll(getBus().getOutInterceptors());
+        getOutFaultInterceptors()
+                .addAll(getBus().getOutFaultInterceptors());
         PhaseInterceptorChain outChain = outboundChainCache.get(pm
                 .getOutPhases(), outList);
         outChain.add(getOutInterceptors());
@@ -204,17 +209,7 @@
 
         conduit.prepare(message);
         OutputStream os = message.getContent(OutputStream.class);
-        XMLStreamWriter writer = message.getContent(XMLStreamWriter.class);
-
-        String encoding = getEncoding(message);
-
-        try {
-            writer = StaxOutInterceptor.getXMLOutputFactory(message)
-                    .createXMLStreamWriter(os, encoding);
-        } catch (XMLStreamException e) {
-            //
-        }
-        message.setContent(XMLStreamWriter.class, writer);
+        
         message.put(org.apache.cxf.message.Message.REQUESTOR_ROLE, true);
         try {
             outChain.doIntercept(message);
@@ -228,12 +223,8 @@
                 throw ex;
             }
             
-            XMLStreamWriter xtw = message.getContent(XMLStreamWriter.class);
-            if (xtw != null) {
-                xtw.writeEndDocument();
-                xtw.close();
-            }
-
+            
+            os = message.getContent(OutputStream.class);
             os.flush();
             is.close();
             os.close();
@@ -378,15 +369,10 @@
                                                         .getAttribute("targetNamespace")))
{
 
                             sInfo.setElement(ele);
-                            
                         }
                     }
                 }
                 serInfo.setProperty(WSDLServiceBuilder.WSDL_DEFINITION, null);
-                serInfo.getInterface().setProperty(WSDLServiceBuilder.WSDL_PORTTYPE, null);
-                for (OperationInfo opInfo : serInfo.getInterface().getOperations()) {
-                    opInfo.setProperty(WSDLServiceBuilder.WSDL_OPERATION, null);
-                }
                 description = WSDLFactory.newInstance().newWSDLWriter()
                         .getDocument(swBuilder.build());
 
@@ -451,20 +437,7 @@
         return locationURI;
     }
 
-    private String getEncoding(Message message) {
-        Exchange ex = message.getExchange();
-        String encoding = (String) message.get(Message.ENCODING);
-        if (encoding == null && ex.getInMessage() != null) {
-            encoding = (String) ex.getInMessage().get(Message.ENCODING);
-            message.put(Message.ENCODING, encoding);
-        }
-
-        if (encoding == null) {
-            encoding = "UTF-8";
-            message.put(Message.ENCODING, encoding);
-        }
-        return encoding;
-    }
+    
 
     Endpoint getCxfEndpoint() {
         return this.ep;

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java?rev=671114&r1=671113&r2=671114&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java
(original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java
Tue Jun 24 03:13:43 2008
@@ -17,7 +17,6 @@
 package org.apache.servicemix.cxfbc;
 
 import java.io.ByteArrayOutputStream;
-import java.io.InputStream;
 import java.util.ArrayList;
 import java.util.List;
 
@@ -28,10 +27,7 @@
 import javax.jbi.messaging.MessageExchange;
 import javax.jbi.messaging.NormalizedMessage;
 import javax.xml.namespace.QName;
-import javax.xml.stream.XMLStreamException;
-import javax.xml.stream.XMLStreamReader;
 import javax.xml.transform.Source;
-import javax.xml.transform.stream.StreamSource;
 
 import org.apache.cxf.binding.soap.SoapMessage;
 import org.apache.cxf.endpoint.Endpoint;
@@ -44,11 +40,10 @@
 import org.apache.cxf.phase.PhaseManager;
 import org.apache.cxf.service.model.BindingOperationInfo;
 import org.apache.cxf.service.model.EndpointInfo;
-import org.apache.cxf.staxutils.DepthXMLStreamReader;
-import org.apache.cxf.staxutils.StaxUtils;
 import org.apache.cxf.transport.MessageObserver;
 import org.apache.servicemix.JbiConstants;
 import org.apache.servicemix.cxfbc.interceptors.JbiInWsdl1Interceptor;
+import org.apache.servicemix.cxfbc.interceptors.RetrievePayLoadInterceptor;
 
 public class CxfBcProviderMessageObserver implements MessageObserver {
     ByteArrayOutputStream response = new ByteArrayOutputStream();
@@ -90,7 +85,6 @@
             SoapMessage soapMessage = 
                 (SoapMessage) this.providerEndpoint.getCxfEndpoint().getBinding().createMessage(message);
             
-            // create XmlStreamReader
             EndpointInfo ei = this.providerEndpoint.getEndpointInfo();
             QName opeName = messageExchange.getOperation();
             BindingOperationInfo boi = null;
@@ -110,8 +104,7 @@
             if (boi.getOperationInfo().isOneWay()) {
                 return;
             }
-            XMLStreamReader xmlStreamReader = createXMLStreamReaderFromMessage(soapMessage);
-            soapMessage.setContent(XMLStreamReader.class, xmlStreamReader);
+            
             soapMessage
                     .put(org.apache.cxf.message.Message.REQUESTOR_ROLE, true);
             Exchange cxfExchange = new ExchangeImpl();
@@ -126,12 +119,14 @@
                     PhaseManager.class);
             List<Interceptor> inList = new ArrayList<Interceptor>();
             
+            inList.add(new RetrievePayLoadInterceptor());
             inList.add(new JbiInWsdl1Interceptor(this.providerEndpoint.isUseJBIWrapper()));
-
             PhaseInterceptorChain inChain = inboundChainCache.get(pm
                     .getInPhases(), inList);
             inChain.add(providerEndpoint.getInInterceptors());
             inChain.add(providerEndpoint.getInFaultInterceptors());
+            inChain.add(this.providerEndpoint.getInInterceptors());
+            inChain.add(this.providerEndpoint.getInFaultInterceptors());
             soapMessage.setInterceptorChain(inChain);
             inChain.doIntercept(soapMessage);
            
@@ -180,36 +175,4 @@
         }
     }
 
-    private XMLStreamReader createXMLStreamReaderFromMessage(Message message) {
-        XMLStreamReader xmlReader = null;
-        StreamSource bodySource = new StreamSource(message
-                .getContent(InputStream.class));
-        xmlReader = StaxUtils.createXMLStreamReader(bodySource);
-        
-        findBody(message, xmlReader);
-        
-        return xmlReader;
-    }
-    
-    private void findBody(Message message, XMLStreamReader xmlReader) {
-        DepthXMLStreamReader reader = new DepthXMLStreamReader(xmlReader);
-        try {
-            int depth = reader.getDepth();
-            int event = reader.getEventType();
-            while (reader.getDepth() >= depth && reader.hasNext()) {
-                QName name = null;
-                if (event == XMLStreamReader.START_ELEMENT) {
-                    name = reader.getName();
-                }
-                if (event == XMLStreamReader.START_ELEMENT && name.equals(((SoapMessage)message).getVersion().getBody()))
{
-                    reader.nextTag();
-                    return;
-                }
-                event = reader.next();
-            }
-            return;
-        } catch (XMLStreamException e) {
-            throw new RuntimeException("Couldn't parse stream.", e);
-        }
-    }
 }

Added: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/RetrievePayLoadInterceptor.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/RetrievePayLoadInterceptor.java?rev=671114&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/RetrievePayLoadInterceptor.java
(added)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/RetrievePayLoadInterceptor.java
Tue Jun 24 03:13:43 2008
@@ -0,0 +1,72 @@
+/*
+ * 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.servicemix.cxfbc.interceptors;
+
+import java.io.InputStream;
+
+import javax.xml.namespace.QName;
+import javax.xml.stream.XMLStreamException;
+import javax.xml.stream.XMLStreamReader;
+import javax.xml.transform.stream.StreamSource;
+
+import org.apache.cxf.binding.soap.SoapMessage;
+import org.apache.cxf.interceptor.Fault;
+import org.apache.cxf.message.Message;
+import org.apache.cxf.phase.AbstractPhaseInterceptor;
+import org.apache.cxf.phase.Phase;
+import org.apache.cxf.staxutils.DepthXMLStreamReader;
+import org.apache.cxf.staxutils.StaxUtils;
+
+public class RetrievePayLoadInterceptor extends AbstractPhaseInterceptor<Message> {
+
+    public RetrievePayLoadInterceptor() {
+        super(Phase.POST_STREAM);
+    }
+    
+    public void handleMessage(Message message) throws Fault {
+        InputStream is = message.getContent(InputStream.class);
+        XMLStreamReader xmlReader = null;
+        if (is != null) {
+            StreamSource bodySource = new StreamSource(message.getContent(InputStream.class));
+            xmlReader = StaxUtils.createXMLStreamReader(bodySource);
+            findBody(message, xmlReader);
+            message.setContent(XMLStreamReader.class, xmlReader);
+        }
+    }
+
+    private void findBody(Message message, XMLStreamReader xmlReader) {
+        DepthXMLStreamReader reader = new DepthXMLStreamReader(xmlReader);
+        try {
+            int depth = reader.getDepth();
+            int event = reader.getEventType();
+            while (reader.getDepth() >= depth && reader.hasNext()) {
+                QName name = null;
+                if (event == XMLStreamReader.START_ELEMENT) {
+                    name = reader.getName();
+                }
+                if (event == XMLStreamReader.START_ELEMENT && name.equals(((SoapMessage)message).getVersion().getBody()))
{
+                    reader.nextTag();
+                    return;
+                }
+                event = reader.next();
+            }
+            return;
+        } catch (XMLStreamException e) {
+            throw new RuntimeException("Couldn't parse stream.", e);
+        }
+    }
+}

Propchange: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/RetrievePayLoadInterceptor.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/interceptors/RetrievePayLoadInterceptor.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Modified: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/provider/CxfBCSEProviderSystemTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/provider/CxfBCSEProviderSystemTest.java?rev=671114&r1=671113&r2=671114&view=diff
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/provider/CxfBCSEProviderSystemTest.java
(original)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/provider/CxfBCSEProviderSystemTest.java
Tue Jun 24 03:13:43 2008
@@ -178,6 +178,11 @@
         greetMeProviderJmsTestBase(false, "ffang");
     }
         
+    public void testGreetMeProviderWithBusLoggerFeature() throws Exception {
+        setUpJBI("org/apache/servicemix/cxfbc/provider/xbean_provider_with_bus_logger_feature.xml");
+        greetMeProviderTestBase(true);
+    }
+    
     private void greetMeProviderTestBase(boolean useDynamicUri) throws Exception {
 
         client = new DefaultServiceMixClient(jbi);

Added: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/log-feature.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/log-feature.xml?rev=671114&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/log-feature.xml
(added)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/log-feature.xml
Tue Jun 24 03:13:43 2008
@@ -0,0 +1,34 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  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.
+-->
+<beans xmlns="http://www.springframework.org/schema/beans"
+       xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
+       xmlns:foo="http://cxf.apache.org/configuration/foo"
+       xmlns:cxf="http://cxf.apache.org/core"
+       xsi:schemaLocation="
+http://cxf.apache.org/core http://cxf.apache.org/schemas/core.xsd
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+    <bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl"/>
+    <cxf:bus>
+        <cxf:features>
+            <cxf:logging/>
+        </cxf:features>
+    </cxf:bus>
+</beans>

Propchange: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/log-feature.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/log-feature.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/log-feature.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Added: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_bus_logger_feature.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_bus_logger_feature.xml?rev=671114&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_bus_logger_feature.xml
(added)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_bus_logger_feature.xml
Tue Jun 24 03:13:43 2008
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+  
+  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.
+  
+-->
+<beans xmlns:sm="http://servicemix.apache.org/config/1.0"
+       xmlns:cxfbc="http://servicemix.apache.org/cxfbc/1.0"
+       xmlns:test="urn:test"
+       xmlns:greeter="http://apache.org/hello_world_soap_http_provider">
+
+       
+  <sm:container id="jbi" embedded="true">
+    
+    <sm:endpoints>      
+      
+            <cxfbc:provider wsdl="./hello_world.wsdl"
+                      locationURI="http://localhost:9000/SoapContext/SoapPort"
+                      endpoint="SoapPort"
+                      service="greeter:SOAPService"
+                      interfaceName="greeter:Greeter"                      
+                      useJBIWrapper="false"
+                      busCfg="org/apache/servicemix/cxfbc/provider/log-feature.xml"
+                      >
+            </cxfbc:provider>
+    </sm:endpoints>
+    
+  </sm:container>
+  
+</beans>

Propchange: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_bus_logger_feature.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_bus_logger_feature.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/provider/xbean_provider_with_bus_logger_feature.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml



Mime
View raw message