camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject svn commit: r778655 - /camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisProducer.java
Date Tue, 26 May 2009 11:26:58 GMT
Author: davsclaus
Date: Tue May 26 11:26:57 2009
New Revision: 778655

URL: http://svn.apache.org/viewvc?rev=778655&view=rev
Log:
CAMEL-1649: camel-ibatis. Only set the response as Body if SELECT statement. Always set response
as header. And honor MEP.

Modified:
    camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisProducer.java

Modified: camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisProducer.java
URL: http://svn.apache.org/viewvc/camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisProducer.java?rev=778655&r1=778654&r2=778655&view=diff
==============================================================================
--- camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisProducer.java
(original)
+++ camel/branches/camel-1.x/components/camel-ibatis/src/main/java/org/apache/camel/component/ibatis/IBatisProducer.java
Tue May 26 11:26:57 2009
@@ -22,6 +22,7 @@
 import org.apache.camel.Exchange;
 import org.apache.camel.Message;
 import org.apache.camel.impl.DefaultProducer;
+import org.apache.camel.util.ExchangeHelper;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.commons.logging.Log;
 import org.apache.commons.logging.LogFactory;
@@ -178,9 +179,25 @@
     }
 
     private void doProcessResult(Exchange exchange, Object result) {
-        Message msg = exchange.getOut();
-        msg.setBody(result);
-        msg.setHeader("org.apache.camel.ibatis.queryName", statement);
+        if (endpoint.getStatementType() == StatementType.QueryForList || endpoint.getStatementType()
== StatementType.QueryForObject) {
+            Message answer = exchange.getIn();
+            if (ExchangeHelper.isOutCapable(exchange)) {
+                answer = exchange.getOut();
+                // preserve headers
+                answer.getHeaders().putAll(exchange.getIn().getHeaders());
+            }
+            // set the result as body for insert
+            answer.setBody(result);
+
+            answer.setHeader("CamelIBatisResult", result);
+            answer.setHeader("CamelIBatisStatementName", statement);
+            answer.setHeader("org.apache.camel.ibatis.queryName", statement);
+        } else {
+            Message msg = exchange.getIn();
+            msg.setHeader("CamelIBatisResult", result);
+            msg.setHeader("CamelIBatisStatementName", statement);
+            msg.setHeader("org.apache.camel.ibatis.queryName", statement);
+        }
     }
 
 }



Mime
View raw message