camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject [10/13] camel git commit: CAMEL-11149: SPI - Allow to plugin different headers map implementation
Date Thu, 25 May 2017 09:33:22 GMT
CAMEL-11149: SPI - Allow to plugin different headers map implementation


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/d50e4804
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/d50e4804
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/d50e4804

Branch: refs/heads/master
Commit: d50e480483563a0c9605917fbef62504a00af172
Parents: 4767924
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Thu May 25 10:46:11 2017 +0200
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Thu May 25 11:09:53 2017 +0200

----------------------------------------------------------------------
 .../component/zookeeper/ZooKeeperConsumer.java  | 10 ++++-----
 .../component/zookeeper/ZooKeeperMessage.java   | 22 +++++++++++++-------
 .../component/zookeeper/ZooKeeperProducer.java  |  2 +-
 3 files changed, 21 insertions(+), 13 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/d50e4804/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperConsumer.java
----------------------------------------------------------------------
diff --git a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperConsumer.java
b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperConsumer.java
index 44b8f49..96b2686 100644
--- a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperConsumer.java
+++ b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperConsumer.java
@@ -108,15 +108,15 @@ public class ZooKeeperConsumer extends DefaultConsumer {
     }
 
     private Exchange createExchange(String path, OperationResult result, WatchedEvent watchedEvent)
{
-        Exchange e = getEndpoint().createExchange();
-        ZooKeeperMessage in = new ZooKeeperMessage(path, result.getStatistics(), watchedEvent);
-        e.setIn(in);
+        Exchange exchange = getEndpoint().createExchange();
+        ZooKeeperMessage in = new ZooKeeperMessage(getEndpoint().getCamelContext(), path,
result.getStatistics(), watchedEvent);
+        exchange.setIn(in);
         if (result.isOk()) {
             in.setBody(result.getResult());
         } else {
-            e.setException(result.getException());
+            exchange.setException(result.getException());
         }
-        return e;
+        return exchange;
     }
 
     private class OperationsExecutor implements Runnable {

http://git-wip-us.apache.org/repos/asf/camel/blob/d50e4804/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperMessage.java
----------------------------------------------------------------------
diff --git a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperMessage.java
b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperMessage.java
index 06dbc7f..9a79792 100644
--- a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperMessage.java
+++ b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperMessage.java
@@ -19,6 +19,7 @@ package org.apache.camel.component.zookeeper;
 import java.util.Collections;
 import java.util.Map;
 
+import org.apache.camel.CamelContext;
 import org.apache.camel.Message;
 import org.apache.camel.impl.DefaultMessage;
 import org.apache.zookeeper.WatchedEvent;
@@ -48,15 +49,20 @@ public class ZooKeeperMessage extends DefaultMessage {
 
     public static final String ZOOKEEPER_OPERATION = "CamelZookeeperOperation";
 
-    public ZooKeeperMessage(String node, Stat statistics, WatchedEvent watchedEvent) {
-        this(node, statistics, Collections.<String, Object>emptyMap(), watchedEvent);
+    public ZooKeeperMessage(CamelContext camelContext) {
+        super(camelContext);
     }
 
-    public ZooKeeperMessage(String node, Stat statistics, Map<String, Object> headers)
{
-        this(node, statistics, headers, null);
+    public ZooKeeperMessage(CamelContext camelContext, String node, Stat statistics, WatchedEvent
watchedEvent) {
+        this(camelContext, node, statistics, Collections.<String, Object>emptyMap(),
watchedEvent);
     }
 
-    public ZooKeeperMessage(String node, Stat statistics, Map<String, Object> headers,
WatchedEvent watchedEvent) {
+    public ZooKeeperMessage(CamelContext camelContext, String node, Stat statistics, Map<String,
Object> headers) {
+        this(camelContext, node, statistics, headers, null);
+    }
+
+    public ZooKeeperMessage(CamelContext camelContext, String node, Stat statistics, Map<String,
Object> headers, WatchedEvent watchedEvent) {
+        super(camelContext);
         setHeaders(headers);
         this.setHeader(ZOOKEEPER_NODE, node);
         this.setHeader(ZOOKEEPER_STATISTICS, statistics);
@@ -80,7 +86,9 @@ public class ZooKeeperMessage extends DefaultMessage {
         }
         return path;
     }
-    
-    
 
+    @Override
+    public DefaultMessage newInstance() {
+        return new ZooKeeperMessage(getCamelContext());
+    }
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/d50e4804/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperProducer.java
----------------------------------------------------------------------
diff --git a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperProducer.java
b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperProducer.java
index 37b236e..7f48980 100644
--- a/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperProducer.java
+++ b/components/camel-zookeeper/src/main/java/org/apache/camel/component/zookeeper/ZooKeeperProducer.java
@@ -137,7 +137,7 @@ public class ZooKeeperProducer extends DefaultProducer {
     }
 
     private void updateExchangeWithResult(ProductionContext context, OperationResult result)
{
-        ZooKeeperMessage out = new ZooKeeperMessage(context.node, result.getStatistics(),
context.in.getHeaders());
+        ZooKeeperMessage out = new ZooKeeperMessage(getEndpoint().getCamelContext(), context.node,
result.getStatistics(), context.in.getHeaders());
         if (result.isOk()) {
             out.setBody(result.getResult());
         } else {


Mime
View raw message