You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicemix.apache.org by ff...@apache.org on 2009/03/30 11:51:07 UTC

svn commit: r759899 - in /servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents: servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/ servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/ servicemix-cxf-bc/src/test/resour...

Author: ffang
Date: Mon Mar 30 09:51:06 2009
New Revision: 759899

URL: http://svn.apache.org/viewvc?rev=759899&view=rev
Log:
[SMXCOMP-493]STFlow doesn't work with servicemix-http/servicemix-cxf-bc

Added:
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcSeStFlowTest.java   (with props)
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/xbean-ST-flow.xml   (with props)
Modified:
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java
    servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java?rev=759899&r1=759898&r2=759899&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/main/java/org/apache/servicemix/cxfbc/CxfBcConsumer.java Mon Mar 30 09:51:06 2009
@@ -165,6 +165,8 @@
     private List<AbstractFeature> features = new CopyOnWriteArrayList<AbstractFeature>();
     
     private boolean transactionEnabled;
+    
+    private boolean isSTFlow; 
         
     
     /**
@@ -286,6 +288,7 @@
         if (exchange.getStatus() != ExchangeStatus.ACTIVE) {
             return;
         }
+        
         Message message = messages.remove(exchange.getExchangeId());
                        
         synchronized (message.getInterceptorChain()) {
@@ -294,7 +297,13 @@
             if (!isSynchronous() && !oneway) {
                 ContinuationProvider continuationProvider = (ContinuationProvider) message
                         .get(ContinuationProvider.class.getName());
-                continuationProvider.getContinuation().resume();
+                Continuation continuation = continuationProvider.getContinuation();
+                if (continuation.isPending()) {
+                    continuation.resume();
+                    isSTFlow = false;
+                } else {
+                    isSTFlow = true;
+                }
             } 
             if (exchange.getStatus() == ExchangeStatus.ACTIVE) {
                 exchange.setStatus(ExchangeStatus.DONE);
@@ -710,7 +719,9 @@
                         Continuation continuation = continuationProvider.getContinuation();
                         if (!continuation.isPending()) {
                             context.getDeliveryChannel().send(exchange);
-                            continuation.suspend(timeout * 1000);
+                            if (!isSTFlow) {
+                                continuation.suspend(timeout * 1000);
+                            }
                         } else {
                             //retry or timeout
                             if (!continuation.isResumed()) {

Added: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcSeStFlowTest.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcSeStFlowTest.java?rev=759899&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcSeStFlowTest.java (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcSeStFlowTest.java Mon Mar 30 09:51:06 2009
@@ -0,0 +1,117 @@
+/*
+ * 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.net.URL;
+import java.util.logging.Logger;
+
+import javax.xml.namespace.QName;
+
+import org.apache.cxf.calculator.AddNumbersFault;
+import org.apache.cxf.calculator.CalculatorPortType;
+import org.apache.cxf.calculator.CalculatorService;
+import org.apache.cxf.common.logging.LogUtils;
+import org.apache.cxf.frontend.ClientProxy;
+import org.apache.cxf.interceptor.LoggingInInterceptor;
+
+import org.apache.servicemix.jbi.container.SpringJBIContainer;
+import org.apache.servicemix.jbi.jaxp.SourceTransformer;
+import org.apache.servicemix.tck.SpringTestSupport;
+import org.apache.xbean.spring.context.ClassPathXmlApplicationContext;
+import org.springframework.context.support.AbstractXmlApplicationContext;
+
+public class CxfBcSeStFlowTest extends SpringTestSupport {
+    
+    private static final Logger LOG = LogUtils.getL7dLogger(CxfBcSeStFlowTest.class);
+    
+   
+    
+    public void setUp() throws Exception {
+        //override super setup
+        LOG.info("setUp is invoked");
+    }
+    
+    public void setUpJBI(String beanFile) throws Exception {
+        if (context != null) {
+            context.refresh();
+        }
+        transformer = new SourceTransformer();
+        if (beanFile == null) {
+            context = createBeanFactory();
+        } else {
+            context = createBeanFactory(beanFile);
+        }
+                
+        jbi = (SpringJBIContainer) context.getBean("jbi");
+        assertNotNull("JBI Container not found in spring!", jbi);
+    }
+    
+    public void tearDown() throws Exception {
+        if (context != null) {
+            context.destroy();
+            context = null;
+        }
+        if (jbi != null) {
+            jbi.shutDown();
+            jbi.destroy();
+            jbi = null;
+        }
+    }
+
+    public void testCalculatrorWithJBIWrapper() throws Exception {
+        setUpJBI("org/apache/servicemix/cxfbc/xbean-ST-flow.xml");
+        calculatorTestBase();
+    }
+    
+    
+    
+    private void calculatorTestBase() throws Exception {
+
+        URL wsdl = getClass().getResource("/wsdl/calculator.wsdl");
+        assertNotNull(wsdl);
+        CalculatorService service = new CalculatorService(wsdl, new QName(
+                "http://apache.org/cxf/calculator", "CalculatorService"));
+        CalculatorPortType port = service.getCalculatorPort();
+        ClientProxy.getClient(port).getInFaultInterceptors().add(new LoggingInInterceptor());
+        ClientProxy.getClient(port).getInInterceptors().add(new LoggingInInterceptor());
+        int ret = port.add(1, 2);
+        assertEquals(ret, 3);
+        try {
+            port.add(1, -2);
+            fail("should get exception since there is a negative arg");
+        } catch (AddNumbersFault e) {
+            assertEquals(e.getFaultInfo().getMessage(),
+                    "Negative number cant be added!");
+        }
+    }
+    
+   
+
+    @Override
+    protected AbstractXmlApplicationContext createBeanFactory() {
+        // load cxf se and bc from spring config file
+        return new ClassPathXmlApplicationContext(
+                "org/apache/servicemix/cxfbc/xbean-ST-flow.xml");
+    }
+    
+    protected AbstractXmlApplicationContext createBeanFactory(String beanFile) {
+        //load cxf se and bc from specified spring config file
+        return new ClassPathXmlApplicationContext(
+            beanFile);
+    }
+
+}

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcSeStFlowTest.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/java/org/apache/servicemix/cxfbc/CxfBcSeStFlowTest.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/xbean-ST-flow.xml
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/xbean-ST-flow.xml?rev=759899&view=auto
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/xbean-ST-flow.xml (added)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/xbean-ST-flow.xml Mon Mar 30 09:51:06 2009
@@ -0,0 +1,72 @@
+<?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:calculator="http://apache.org/cxf/calculator">
+  
+  <sm:container id="jbi" embedded="true">
+      <sm:flows>
+        <sm:stFlow />
+      </sm:flows>
+    
+    <sm:endpoints>
+      <cxfse:endpoint>
+        <cxfse:pojo>
+          <bean class="org.apache.cxf.calculator.CalculatorImpl" />
+        </cxfse:pojo>
+        <cxfse:inInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+        </cxfse:inInterceptors>
+        <cxfse:outInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+        </cxfse:outInterceptors>
+        <cxfse:inFaultInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingInInterceptor"/>
+        </cxfse:inFaultInterceptors>
+        <cxfse:outFaultInterceptors>
+          <bean class="org.apache.cxf.interceptor.LoggingOutInterceptor"/>
+        </cxfse:outFaultInterceptors>
+      </cxfse:endpoint>
+      <cxfbc:consumer wsdl="/wsdl/calculator.wsdl"
+                      targetEndpoint="CalculatorPort"
+                      targetService="calculator:CalculatorService"
+                      targetInterface="calculator:CalculatorPortType"
+                      synchronous="false"
+                      >
+        <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:consumer>
+    </sm:endpoints>
+    
+  </sm:container>
+  
+</beans>

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/xbean-ST-flow.xml
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/xbean-ST-flow.xml
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Propchange: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-cxf-bc/src/test/resources/org/apache/servicemix/cxfbc/xbean-ST-flow.xml
------------------------------------------------------------------------------
    svn:mime-type = text/xml

Modified: servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java
URL: http://svn.apache.org/viewvc/servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java?rev=759899&r1=759898&r2=759899&view=diff
==============================================================================
--- servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java (original)
+++ servicemix/smx3/branches/servicemix-3.2/deployables/bindingcomponents/servicemix-http/src/main/java/org/apache/servicemix/http/processors/ConsumerProcessor.java Mon Mar 30 09:51:06 2009
@@ -69,6 +69,8 @@
     protected Map<String, Continuation> locks;
     protected Map<String, MessageExchange> exchanges;
     protected int suspentionTime = 60000;
+    
+    private boolean isSTFlow;
         
     public ConsumerProcessor(HttpEndpoint endpoint) {
         super(endpoint);
@@ -91,24 +93,34 @@
     
     public void process(MessageExchange exchange) throws Exception {
         Continuation cont = locks.get(exchange.getExchangeId());
-        if (cont == null) {
-            throw new Exception("HTTP request has timed out");
-        }
-        synchronized (cont) {
-            if (locks.remove(exchange.getExchangeId()) == null) {
+        if (!cont.isPending()) {
+            isSTFlow = true;
+        } else {
+            isSTFlow = false;
+            if (cont == null) {
                 throw new Exception("HTTP request has timed out");
             }
-            if (log.isDebugEnabled()) {
-                log.debug("Resuming continuation for exchange: " + exchange.getExchangeId());
-            }
-            exchanges.put(exchange.getExchangeId(), exchange);
-            cont.resume();
-            if (!cont.isResumed()) {
+            synchronized (cont) {
+                if (locks.remove(exchange.getExchangeId()) == null) {
+                    throw new Exception("HTTP request has timed out");
+                }
                 if (log.isDebugEnabled()) {
-                    log.debug("Could not resume continuation for exchange: " + exchange.getExchangeId());
+                    log.debug("Resuming continuation for exchange: "
+                            + exchange.getExchangeId());
+                }
+                exchanges.put(exchange.getExchangeId(), exchange);
+                cont.resume();
+                if (!cont.isResumed()) {
+                    if (log.isDebugEnabled()) {
+                        log
+                                .debug("Could not resume continuation for exchange: "
+                                        + exchange.getExchangeId());
+                    }
+                    exchanges.remove(exchange.getExchangeId());
+                    throw new Exception(
+                            "HTTP request has timed out for exchange: "
+                                    + exchange.getExchangeId());
                 }
-                exchanges.remove(exchange.getExchangeId());
-                throw new Exception("HTTP request has timed out for exchange: " + exchange.getExchangeId());
             }
         }
     }
@@ -154,15 +166,17 @@
                 request.setAttribute(MessageExchange.class.getName(), exchange.getExchangeId());
                 synchronized (cont) {
                     channel.send(exchange);
-                    if (log.isDebugEnabled()) {
-                        log.debug("Suspending continuation for exchange: " + exchange.getExchangeId());
-                    }
-                    boolean result = cont.suspend(suspentionTime);
-                    exchange = exchanges.remove(exchange.getExchangeId());
-                    request.removeAttribute(MessageExchange.class.getName());
-                    if (!result) {
-                        locks.remove(exchange.getExchangeId());
-                        throw new Exception("Exchange timed out");
+                    if (!isSTFlow) {
+                        if (log.isDebugEnabled()) {
+                            log.debug("Suspending continuation for exchange: " + exchange.getExchangeId());
+                        }
+                        boolean result = cont.suspend(suspentionTime);
+                        exchange = exchanges.remove(exchange.getExchangeId());
+                        request.removeAttribute(MessageExchange.class.getName());
+                        if (!result) {
+                            locks.remove(exchange.getExchangeId());
+                            throw new Exception("Exchange timed out");
+                        }
                     }
                 }
             } catch (RetryRequest retry) {