servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ff...@apache.org
Subject svn commit: r777002 - in /servicemix/components/bindings/servicemix-cxf-bc/trunk/src: main/java/org/apache/servicemix/cxfbc/ test/java/org/apache/servicemix/cxfbc/ test/resources/org/apache/servicemix/cxfbc/
Date Thu, 21 May 2009 08:12:13 GMT
Author: ffang
Date: Thu May 21 08:12:13 2009
New Revision: 777002

URL: http://svn.apache.org/viewvc?rev=777002&view=rev
Log:
[SMXCOMP-549]add decoupled endpoint support for cxf bc provider

Added:
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/CxfBcDecoupledProviderTest.java
  (with props)
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/decoupled.xml
  (with props)
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/decoupled_provider.xml
  (with props)
Modified:
    servicemix/components/bindings/servicemix-cxf-bc/trunk/src/main/java/org/apache/servicemix/cxfbc/CxfBcProviderMessageObserver.java

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=777002&r1=777001&r2=777002&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
Thu May 21 08:12:13 2009
@@ -91,45 +91,22 @@
                 MessageObserver messageObserver = message.getExchange().get(MessageObserver.class);
                 if (messageObserver != null) {
                     messageObserver.onMessage(message);
+                    return;
                 }
-                return;
             }
-            if (messageExchange.getStatus() != ExchangeStatus.ACTIVE) {
+            if (messageExchange != null && messageExchange.getStatus() != ExchangeStatus.ACTIVE)
{
                 return;
             }
 
+                       
             contentType = (String) message.get(Message.CONTENT_TYPE);
             SoapMessage soapMessage = 
                 (SoapMessage) this.providerEndpoint.getCxfEndpoint().getBinding().createMessage(message);
             
-            EndpointInfo ei = this.providerEndpoint.getEndpointInfo();
-            QName opeName = messageExchange.getOperation();
-            BindingOperationInfo boi = null;
-            if (opeName == null) {
-                // if interface only have one operation, may not specify the opeName in MessageExchange
-                if (ei.getBinding().getOperations().size() == 1) {
-                    boi = ei.getBinding().getOperations().iterator().next();
-                } else {
-                    throw new org.apache.cxf.interceptor.Fault(
-                                new Exception("Operation not bound on this MessageExchange"));
-                    
-                }
-            } else {
-                boi = ei.getBinding().getOperation(messageExchange.getOperation());   
-            }
-            
-            if (boi.getOperationInfo().isOneWay()) {
-                return;
-            }
             
             soapMessage
                     .put(org.apache.cxf.message.Message.REQUESTOR_ROLE, true);
-            Exchange cxfExchange = new ExchangeImpl();
-            cxfExchange.put(Bus.class, this.providerEndpoint.getBus());
-            soapMessage.setExchange(cxfExchange);
-
-            cxfExchange.put(BindingOperationInfo.class, boi);
-            cxfExchange.put(Endpoint.class, providerEndpoint.getCxfEndpoint());
+            
             // create Interceptor chain
 
             PhaseChainCache inboundChainCache = new PhaseChainCache();
@@ -148,7 +125,12 @@
             soapMessage.setInterceptorChain(inChain);
             inChain.doIntercept(soapMessage);
             closeConnectionStream(soapMessage);
-            if (boi.getOperationInfo().isOneWay()) {
+            if (soapMessage.getContent(Source.class) == null) {
+                return;
+            }
+          
+            messageExchange = soapMessage.getExchange().get(MessageExchange.class);
+            if (soapMessage.getExchange().get(BindingOperationInfo.class).getOperationInfo().isOneWay())
{
                 messageExchange.setStatus(ExchangeStatus.DONE);
             } else if (soapMessage.get("jbiFault") != null
                     && soapMessage.get("jbiFault").equals(true)) {

Added: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/CxfBcDecoupledProviderTest.java
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/CxfBcDecoupledProviderTest.java?rev=777002&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/CxfBcDecoupledProviderTest.java
(added)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/java/org/apache/servicemix/cxfbc/CxfBcDecoupledProviderTest.java
Thu May 21 08:12:13 2009
@@ -0,0 +1,133 @@
+/*
+ * 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;
+
+import java.io.File;
+import java.net.URL;
+import java.util.logging.Logger;
+
+import javax.jbi.messaging.InOut;
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.Bus;
+import org.apache.cxf.BusFactory;
+import org.apache.cxf.bus.spring.SpringBusFactory;
+import org.apache.cxf.calculator.CalculatorImpl;
+import org.apache.cxf.calculator.CalculatorPortType;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.endpoint.Endpoint;
+import org.apache.cxf.endpoint.Server;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+import org.apache.cxf.interceptor.LoggingOutInterceptor;
+import org.apache.cxf.jaxws.JaxWsServerFactoryBean;
+import org.apache.cxf.service.model.ServiceInfo;
+import org.apache.servicemix.client.DefaultServiceMixClient;
+import org.apache.servicemix.cxfse.CxfSeComponent;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.jbi.jaxp.StringSource;
+import org.apache.servicemix.tck.SpringTestSupport;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
+
+public class CxfBcDecoupledProviderTest extends SpringTestSupport {
+
+    private static final Logger LOG = LogUtils.getL7dLogger(org.apache.servicemix.cxfbc.CxfBcDecoupledProviderTest.class);
+    
+    private DefaultServiceMixClient client;
+    private InOut io;
+    private CxfSeComponent component;
+    private JaxWsServerFactoryBean factory;
+    private Server server;
+    private Endpoint endpoint;
+    private ServiceInfo service;
+    
+    protected void setUp() throws Exception {
+        super.setUp();
+        
+        component = new CxfSeComponent();
+        jbi.activateComponent(component, "CxfSeComponent");
+        //Deploy proxy SU
+        component.getServiceUnitManager().deploy("proxy", getServiceUnitPath("provider"));
+        component.getServiceUnitManager().init("proxy", getServiceUnitPath("provider"));
+        component.getServiceUnitManager().start("proxy");
+    }
+    
+    protected void tearDown() throws Exception {
+        component.getServiceUnitManager().stop("proxy");
+        component.getServiceUnitManager().shutDown("proxy");
+        component.getServiceUnitManager().undeploy("proxy", getServiceUnitPath("provider"));
+    }
+    
+    
+    public void testDecoupledProvider() throws Exception {
+        LOG.info("test provider");
+           
+        
+        //start external service
+        SpringBusFactory bf = new SpringBusFactory();
+        Bus bus = bf.createBus("/org/apache/servicemix/cxfbc/decoupled.xml");
+        BusFactory.setDefaultBus(bus);
+        factory = new JaxWsServerFactoryBean();
+        factory.setServiceClass(CalculatorPortType.class);
+        factory.setServiceBean(new CalculatorImpl());
+        String address = "http://localhost:9001/providertest";
+        factory.setAddress(address);
+        factory.setBindingId("http://schemas.xmlsoap.org/wsdl/soap12/");
+        server = factory.create();
+        endpoint = server.getEndpoint();
+        endpoint.getInInterceptors().add(new LoggingInInterceptor());
+        endpoint.getOutInterceptors().add(new LoggingOutInterceptor());
+        service = endpoint.getEndpointInfo().getService();
+        assertNotNull(service);
+        client = new DefaultServiceMixClient(jbi);
+        io = client.createInOutExchange();
+        io.setService(new QName("http://apache.org/hello_world_soap_http", "SOAPServiceProvider"));
+        io.setInterfaceName(new QName("http://apache.org/hello_world_soap_http", "Greeter"));
+        io.setOperation(new QName("http://apache.org/hello_world_soap_http", "greetMe"));
+        //send message to proxy
+        io.getInMessage().setContent(new StringSource(
+                "<message xmlns='http://java.sun.com/xml/ns/jbi/wsdl-11-wrapper'>"
+              + "<part> "
+              + "<greetMe xmlns='http://apache.org/hello_world_soap_http/types'><requestType>"
+              + "ffang"
+              + "</requestType></greetMe>"
+              + "</part> "
+              + "</message>"));
+        client.sendSync(io);
+        client.done(io);
+        assertTrue(new SourceTransformer().contentToString(
+                io.getOutMessage()).indexOf("Hello ffang 3") >= 0);
+
+        // Shutdown CXF Service/Endpoint so that next test doesn't fail.
+        factory.getBus().shutdown(true);
+    }
+
+       
+    
+    @Override
+    protected AbstractXmlApplicationContext createBeanFactory() {
+        return new ClassPathXmlApplicationContext("org/apache/servicemix/cxfbc/decoupled_provider.xml");
+    }
+
+    protected String getServiceUnitPath(String name) {
+        URL url = getClass().getClassLoader().getResource("org/apache/servicemix/cxfbc/"
+ name + "/xbean.xml");
+        File path = new File(url.getFile());
+        path = path.getParentFile();
+        return path.getAbsolutePath();
+    }
+}

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

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

Added: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/decoupled.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/decoupled.xml?rev=777002&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/decoupled.xml
(added)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/decoupled.xml
Thu May 21 08:12:13 2009
@@ -0,0 +1,63 @@
+<?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:http="http://cxf.apache.org/transports/http/configuration"
+       xsi:schemaLocation="
+http://cxf.apache.org/transports/http/configuration http://cxf.apache.org/schemas/configuration/http-conf.xsd
+http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd">
+
+    <http:conduit name="{http://apache.org/cxf/calculator}CalculatorPort.http-conduit">
+      <http:client DecoupledEndpoint="http://localhost:9995/decoupled_endpoint"/>
+    </http:conduit>
+
+     <bean id="mapAggregator" class="org.apache.cxf.ws.addressing.MAPAggregator"/>
+    <bean id="mapCodec" class="org.apache.cxf.ws.addressing.soap.MAPCodec"/>
+
+    <!-- We are adding the interceptors to the bus as we will have only one endpoint/service/bus.
-->
+
+    <bean id="cxf" class="org.apache.cxf.bus.CXFBusImpl">
+        <property name="inInterceptors">
+            <list>
+                <ref bean="mapAggregator"/>
+                <ref bean="mapCodec"/>
+            </list>
+        </property>
+        <property name="inFaultInterceptors">
+            <list>
+                <ref bean="mapAggregator"/>
+                <ref bean="mapCodec"/>
+            </list>
+        </property>
+        <property name="outInterceptors">
+            <list>
+                <ref bean="mapAggregator"/>
+                <ref bean="mapCodec"/>
+            </list>
+        </property>
+        <property name="outFaultInterceptors">
+            <list>
+                <ref bean="mapAggregator"/>
+                <ref bean="mapCodec"/>
+            </list>
+        </property>
+    </bean>
+
+</beans>

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

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

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

Added: servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/decoupled_provider.xml
URL: http://svn.apache.org/viewvc/servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/decoupled_provider.xml?rev=777002&view=auto
==============================================================================
--- servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/decoupled_provider.xml
(added)
+++ servicemix/components/bindings/servicemix-cxf-bc/trunk/src/test/resources/org/apache/servicemix/cxfbc/decoupled_provider.xml
Thu May 21 08:12:13 2009
@@ -0,0 +1,58 @@
+<?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:cxfse="http://servicemix.apache.org/cxfse/1.0"
+       xmlns:cxfbc="http://servicemix.apache.org/cxfbc/1.0"
+       xmlns:test="urn:test"
+       xmlns:hello="uri:HelloWorld"
+       xmlns:calculator="http://apache.org/cxf/calculator"
+       xmlns:greeter="http://apache.org/hello_world_soap_http"
+       xmlns:mtom="http://cxf.apache.org/mime">
+
+    <sm:container id="jbi" embedded="true">
+
+        <sm:endpoints>
+
+            <cxfbc:provider wsdl="/wsdl/calculator.wsdl"
+                            locationURI="http://localhost:9001/providertest"
+                            endpoint="CalculatorPort"
+                            service="calculator:CalculatorService"
+                            interfaceName="calculator:CalculatorPortType"
+                            busCfg="org/apache/servicemix/cxfbc/decoupled.xml"
+                    >
+                <cxfbc:inInterceptors>
+                    <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+                </cxfbc:inInterceptors>
+                <cxfbc:outInterceptors>
+                    <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+                </cxfbc:outInterceptors>
+                <cxfbc:inFaultInterceptors>
+                    <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+                </cxfbc:inFaultInterceptors>
+                <cxfbc:outFaultInterceptors>
+                    <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+                </cxfbc:outFaultInterceptors>
+            </cxfbc:provider>
+
+        </sm:endpoints>
+
+    </sm:container>
+
+</beans>

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

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

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



Mime
View raw message