servicemix-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jstrac...@apache.org
Subject svn commit: r567098 - in /incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache: camel/ servicemix/camel/JbiBinding.java
Date Fri, 17 Aug 2007 18:08:58 GMT
Author: jstrachan
Date: Fri Aug 17 11:08:57 2007
New Revision: 567098

URL: http://svn.apache.org/viewvc?view=rev&rev=567098
Log:
further improvements in the defaulting of the MEP when converting a Camel Exchange into a
JBI MessageExchange - if there is an OUT message with a non-null body, then assume by default
InOut otherwise use InOnly

Removed:
    incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/camel/
Modified:
    incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/JbiBinding.java

Modified: incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/JbiBinding.java
URL: http://svn.apache.org/viewvc/incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/JbiBinding.java?view=diff&rev=567098&r1=567097&r2=567098
==============================================================================
--- incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/JbiBinding.java
(original)
+++ incubator/servicemix/trunk/deployables/serviceengines/servicemix-camel/src/main/java/org/apache/servicemix/camel/JbiBinding.java
Fri Aug 17 11:08:57 2007
@@ -29,8 +29,7 @@
 import javax.xml.transform.stream.StreamSource;
 
 import org.apache.camel.Exchange;
-import org.apache.commons.logging.Log;
-import org.apache.commons.logging.LogFactory;
+import org.apache.camel.Message;
 import static org.apache.servicemix.camel.CamelConstants.MessageExchangePattern.*;
 
 /**
@@ -39,8 +38,7 @@
  * @version $Revision: 563665 $
  */
 public class JbiBinding {
-    private static final transient Log LOG = LogFactory.getLog(JbiBinding.class);
-    private String messageExchangePattern = IN_ONLY;
+    private String messageExchangePattern;
 
     /**
      * Extracts the body from the given normalized message
@@ -87,21 +85,30 @@
         if (mep == null) {
             mep = getMessageExchangePattern();
         }
+        MessageExchange answer = null;
         if (mep != null) {
             if (IN_ONLY.equals(mep)) {
-                return exchangeFactory.createInOnlyExchange();
+                answer = exchangeFactory.createInOnlyExchange();
             } else if (IN_OPTIONAL_OUT.equals(mep)) {
-                return exchangeFactory.createInOptionalOutExchange();
+                answer = exchangeFactory.createInOptionalOutExchange();
             } else if (IN_OUT.equals(mep)) {
-                return exchangeFactory.createInOutExchange();
+                answer = exchangeFactory.createInOutExchange();
             } else if (ROBUST_IN_ONLY.equals(mep)) {
-                return exchangeFactory.createRobustInOnlyExchange();
+                answer = exchangeFactory.createRobustInOnlyExchange();
             } else {
-                return exchangeFactory.createExchange(new URI(mep));
+                answer = exchangeFactory.createExchange(new URI(mep));
             }
         }
-        LOG.warn("No MessageExchangePattern specified so using InOnly");
-        return exchangeFactory.createInOnlyExchange();
+        if (answer == null) {
+            // lets try choose the best MEP based on the camel message
+            Message out = camelExchange.getOut(false);
+            if (out == null || out.getBody() == null) {
+                answer = exchangeFactory.createInOnlyExchange();
+            } else {
+                answer = exchangeFactory.createInOutExchange();
+            }
+        }
+        return answer;
     }
 
     protected Source getJbiInContent(Exchange camelExchange) {



Mime
View raw message