You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by da...@apache.org on 2018/02/06 09:14:16 UTC

[camel] branch 8958 updated (b416c74 -> a1b419b)

This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a change to branch 8958
in repository https://gitbox.apache.org/repos/asf/camel.git.


    from b416c74  CAMEL-8958: Claim Check EIP with push/pop. Work in progress.
     new b7c3250  CAMEL-8958: Claim Check EIP with push/pop. Work in progress.
     new b9b52f7  CAMEL-8958: Claim Check EIP with push/pop. Work in progress.
     new a1b419b  CAMEL-8958: Claim Check EIP with push/pop. Work in progress.

The 3 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails.  The revisions
listed as "add" were already present in the repository and have only
been added to this reference.


Summary of changes:
 camel-core/readme-eip.adoc                         |   5 +-
 camel-core/src/main/docs/eips/claimCheck-eip.adoc  |   5 +-
 .../apache/camel/model/ClaimCheckDefinition.java   |  55 +++++++--
 .../apache/camel/model/ProcessorDefinition.java    |  30 +++--
 .../processor/ClaimCheckAggregationStrategy.java   | 123 +++++++++++++++++----
 .../camel/processor/ClaimCheckProcessor.java       |  30 +++--
 ...va => ClaimCheckEipPushPopExcludeBodyTest.java} |  15 ++-
 .../processor/ClaimCheckEipPushPopBodyTest.xml     |   2 +-
 .../ClaimCheckEipPushPopHeadersPatternTest.xml     |   2 +-
 .../processor/ClaimCheckEipPushPopHeadersTest.xml  |   2 +-
 10 files changed, 205 insertions(+), 64 deletions(-)
 copy camel-core/src/test/java/org/apache/camel/processor/{ClaimCheckEipPushPopBodyTest.java => ClaimCheckEipPushPopExcludeBodyTest.java} (77%)

-- 
To stop receiving notification emails like this one, please contact
davsclaus@apache.org.

[camel] 03/03: CAMEL-8958: Claim Check EIP with push/pop. Work in progress.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch 8958
in repository https://gitbox.apache.org/repos/asf/camel.git

commit a1b419bacca8fccb3f4408e32270d8830d678010
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Feb 6 09:55:41 2018 +0100

    CAMEL-8958: Claim Check EIP with push/pop. Work in progress.
---
 camel-core/src/main/docs/eips/claimCheck-eip.adoc  |   5 +-
 .../apache/camel/model/ClaimCheckDefinition.java   |  33 ++++++-
 .../apache/camel/model/ProcessorDefinition.java    |  25 +++--
 .../processor/ClaimCheckAggregationStrategy.java   | 106 +++++++++++++++++----
 .../camel/processor/ClaimCheckProcessor.java       |  12 ++-
 .../ClaimCheckEipPushPopExcludeBodyTest.java       |  60 ++++++++++++
 6 files changed, 213 insertions(+), 28 deletions(-)

diff --git a/camel-core/src/main/docs/eips/claimCheck-eip.adoc b/camel-core/src/main/docs/eips/claimCheck-eip.adoc
index e4dc44a..a0ff103 100644
--- a/camel-core/src/main/docs/eips/claimCheck-eip.adoc
+++ b/camel-core/src/main/docs/eips/claimCheck-eip.adoc
@@ -12,7 +12,7 @@ NOTE: The Camel implementation of this EIP pattern stores the message content te
 
 
 // eip options: START
-The Claim Check EIP supports 5 options which are listed below:
+The Claim Check EIP supports 6 options which are listed below:
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -20,7 +20,8 @@ The Claim Check EIP supports 5 options which are listed below:
 | Name | Description | Default | Type
 | *operation* | *Required* The claim check operation to use. The following operations is supported: Get - Gets (does not remove) the claim check by the given key. GetAndRemove - Gets and remove the claim check by the given key. Set - Sets a new (will override if key already exists) claim check with the given key. Push - Sets a new claim check on the stack (does not use key). Pop - Gets the latest claim check from the stack (does not use key). |  | ClaimCheckOperation
 | *key* | To use a specific key for claim check id. |  | String
-| *include* | What data to include when merging data back from claim check repository. The following syntax is supported: body - to aggregate the message body headers - to aggregate all the message headers header:pattern - to aggregate all the message headers that matches the pattern. The pattern syntax is documented by: link EndpointHelpermatchPattern(String String). You can specify multiple rules separated by comma. For example to include the message body and all headers starting with  [...]
+| *include* | What data to include when merging data back from claim check repository. The following syntax is supported: body - to aggregate the message body headers - to aggregate all the message headers header:pattern - to aggregate all the message headers that matches the pattern. The pattern syntax is documented by: link EndpointHelpermatchPattern(String String). You can specify multiple rules separated by comma. For example to include the message body and all headers starting with  [...]
+| *exclude* | What data to exclude when merging data back from claim check repository. The following syntax is supported: body - to aggregate the message body headers - to aggregate all the message headers header:pattern - to aggregate all the message headers that matches the pattern. The pattern syntax is documented by: link EndpointHelpermatchPattern(String String). You can specify multiple rules separated by comma. For example to exclude the message body and all headers starting with  [...]
 | *strategyRef* | To use a custom AggregationStrategy instead of the default implementation. Notice you cannot use both custom aggregation strategy and configure data at the same time. |  | String
 | *strategyMethodName* | This option can be used to explicit declare the method name to use when using POJOs as the AggregationStrategy. |  | String
 |===
diff --git a/camel-core/src/main/java/org/apache/camel/model/ClaimCheckDefinition.java b/camel-core/src/main/java/org/apache/camel/model/ClaimCheckDefinition.java
index a78fe60..4dc1609 100644
--- a/camel-core/src/main/java/org/apache/camel/model/ClaimCheckDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/ClaimCheckDefinition.java
@@ -47,6 +47,8 @@ public class ClaimCheckDefinition extends NoOutputDefinition<ClaimCheckDefinitio
     private String key;
     @XmlAttribute
     private String include;
+    @XmlAttribute
+    private String exclude;
     @XmlAttribute(name = "strategyRef") @Metadata(label = "advanced")
     private String aggregationStrategyRef;
     @XmlAttribute(name = "strategyMethodName") @Metadata(label = "advanced")
@@ -79,6 +81,7 @@ public class ClaimCheckDefinition extends NoOutputDefinition<ClaimCheckDefinitio
         claim.setOperation(operation.name());
         claim.setKey(getKey());
         claim.setInclude(getInclude());
+        claim.setExclude(getExclude());
 
         AggregationStrategy strategy = createAggregationStrategy(routeContext);
         if (strategy != null) {
@@ -86,7 +89,7 @@ public class ClaimCheckDefinition extends NoOutputDefinition<ClaimCheckDefinitio
         }
 
         // only data or aggregation strategy can be configured not both
-        if (getInclude() != null && strategy != null) {
+        if ((getInclude() != null || getExclude() != null) && strategy != null) {
             throw new IllegalArgumentException("Cannot use both include/exclude and custom aggregation strategy on ClaimCheck EIP");
         }
 
@@ -153,6 +156,7 @@ public class ClaimCheckDefinition extends NoOutputDefinition<ClaimCheckDefinitio
      * You can specify multiple rules separated by comma. For example to include the message body and all headers starting with foo
      * <tt>body,header:foo*</tt>.
      * If the include rule is specified as empty or as wildcard then everything is included.
+     * If you have configured both include and exclude then exclude take precedence over include.
      */
     public ClaimCheckDefinition include(String include) {
         setInclude(include);
@@ -160,6 +164,25 @@ public class ClaimCheckDefinition extends NoOutputDefinition<ClaimCheckDefinitio
     }
 
     /**
+     * What data to exclude when merging data back from claim check repository.
+     *
+     * The following syntax is supported:
+     * <ul>
+     *     <li>body</li> - to aggregate the message body
+     *     <li>headers</li> - to aggregate all the message headers
+     *     <li>header:pattern</li> - to aggregate all the message headers that matches the pattern.
+     *     The pattern syntax is documented by: {@link EndpointHelper#matchPattern(String, String)}.
+     * </ul>
+     * You can specify multiple rules separated by comma. For example to exclude the message body and all headers starting with bar
+     * <tt>body,header:bar*</tt>.
+     * If you have configured both include and exclude then exclude take precedence over include.
+     */
+    public ClaimCheckDefinition exclude(String exclude) {
+        setExclude(exclude);
+        return this;
+    }
+
+    /**
      * To use a custom {@link AggregationStrategy} instead of the default implementation.
      * Notice you cannot use both custom aggregation strategy and configure data at the same time.
      */
@@ -212,6 +235,14 @@ public class ClaimCheckDefinition extends NoOutputDefinition<ClaimCheckDefinitio
         this.include = include;
     }
 
+    public String getExclude() {
+        return exclude;
+    }
+
+    public void setExclude(String exclude) {
+        this.exclude = exclude;
+    }
+
     public String getAggregationStrategyRef() {
         return aggregationStrategyRef;
     }
diff --git a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
index ac0e635..39a0c6d 100644
--- a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
@@ -3478,11 +3478,7 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
      * @param key       the unique key to use for the get and set operations, can be <tt>null</tt> for push/pop operations
      */
     public Type claimCheck(ClaimCheckOperation operation, String key) {
-        ClaimCheckDefinition answer = new ClaimCheckDefinition();
-        answer.setOperation(operation);
-        answer.setKey(key);
-        addOutput(answer);
-        return (Type) this;
+        return claimCheck(operation, key, null, null);
     }
 
     /**
@@ -3492,13 +3488,30 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
      *
      * @param operation the claim check operation to use.
      * @param key       the unique key to use for the get and set operations, can be <tt>null</tt> for push/pop operations
-     * @param include   describes what data to include and retrieve and merge back when using get or pop operations.
+     * @param include   describes what data to include when merging data back when using get or pop operations.
      */
     public Type claimCheck(ClaimCheckOperation operation, String key, String include) {
+        return claimCheck(operation, key, include, null);
+    }
+
+    /**
+     * The <a href="http://camel.apache.org/claim-check.html">Claim Check EIP</a>
+     * allows you to replace message content with a claim check (a unique key),
+     * which can be used to retrieve the message content at a later time.
+     *
+     * @param operation the claim check operation to use.
+     * @param key       the unique key to use for the get and set operations, can be <tt>null</tt> for push/pop operations
+     * @param include   describes what data to include when merging data back when using get or pop operations.
+     *                  If you have configured both include and exclude then exclude take precedence over include.
+     * @param exclude   describes what data to exclude when merging data back when using get or pop operations.
+     *                  If you have configured both include and exclude then exclude take precedence over include.
+     */
+    public Type claimCheck(ClaimCheckOperation operation, String key, String include, String exclude) {
         ClaimCheckDefinition answer = new ClaimCheckDefinition();
         answer.setOperation(operation);
         answer.setKey(key);
         answer.setInclude(include);
+        answer.setExclude(exclude);
         addOutput(answer);
         return (Type) this;
     }
diff --git a/camel-core/src/main/java/org/apache/camel/processor/ClaimCheckAggregationStrategy.java b/camel-core/src/main/java/org/apache/camel/processor/ClaimCheckAggregationStrategy.java
index 02e0d7d..fb58346 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/ClaimCheckAggregationStrategy.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/ClaimCheckAggregationStrategy.java
@@ -23,6 +23,8 @@ import org.apache.camel.processor.aggregate.AggregationStrategy;
 import org.apache.camel.util.EndpointHelper;
 import org.apache.camel.util.ObjectHelper;
 import org.apache.camel.util.StringHelper;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
 
 /**
  * Default {@link AggregationStrategy} used by the {@link ClaimCheckProcessor} EIP.
@@ -37,10 +39,13 @@ import org.apache.camel.util.StringHelper;
  * You can specify multiple rules separated by comma. For example to include the message body and all headers starting with foo
  * <tt>body,header:foo*</tt>.
  * If the include rule is specified as empty or as wildcard then everything is merged.
+ * If you have configured both include and exclude then exclude take precedence over include.
  */
 public class ClaimCheckAggregationStrategy implements AggregationStrategy {
 
+    private static final Logger LOG = LoggerFactory.getLogger(ClaimCheckAggregationStrategy.class);
     private String include;
+    private String exclude;
 
     public ClaimCheckAggregationStrategy() {
     }
@@ -53,34 +58,82 @@ public class ClaimCheckAggregationStrategy implements AggregationStrategy {
         this.include = include;
     }
 
+    public String getExclude() {
+        return exclude;
+    }
+
+    public void setExclude(String exclude) {
+        this.exclude = exclude;
+    }
+
     @Override
     public Exchange aggregate(Exchange oldExchange, Exchange newExchange) {
         if (newExchange == null) {
             return oldExchange;
         }
 
-        if (ObjectHelper.isEmpty(include) || "*".equals(include)) {
-            // grab everything if data is empty or wildcard
+        if (ObjectHelper.isEmpty(exclude) && (ObjectHelper.isEmpty(include) || "*".equals(include))) {
+            // grab everything if include is empty or wildcard (and exclude is not in use)
             return newExchange;
         }
 
-        Iterable it = ObjectHelper.createIterable(include, ",");
-        for (Object k : it) {
-            String part = k.toString();
-            if ("body".equals(part)) {
+        // if we have include
+        if (ObjectHelper.isNotEmpty(include)) {
+            Iterable it = ObjectHelper.createIterable(include, ",");
+            for (Object k : it) {
+                String part = k.toString();
+                if ("body".equals(part) && !isExcluded("body")) {
+                    oldExchange.getMessage().setBody(newExchange.getMessage().getBody());
+                    LOG.trace("Including: body");
+                } else if ("headers".equals(part) && !isExcluded("headers")) {
+                    oldExchange.getMessage().getHeaders().putAll(newExchange.getMessage().getHeaders());
+                    LOG.trace("Including: headers");
+                } else if (part.startsWith("header:")) {
+                    // pattern matching for headers, eg header:foo, header:foo*, header:(foo|bar)
+                    String after = StringHelper.after(part, "header:");
+                    Iterable i = ObjectHelper.createIterable(after, ",");
+                    for (Object o : i) {
+                        String pattern = o.toString();
+                        for (Map.Entry<String, Object> header : newExchange.getMessage().getHeaders().entrySet()) {
+                            String key = header.getKey();
+                            boolean matched = EndpointHelper.matchPattern(key, pattern);
+                            if (matched && !isExcluded(key)) {
+                                LOG.trace("Including: header:{}", key);
+                                oldExchange.getMessage().getHeaders().put(key, header.getValue());
+                            }
+                        }
+                    }
+                }
+            }
+        } else if (ObjectHelper.isNotEmpty(exclude)) {
+            // grab body unless its excluded
+            if (!isExcluded("body")) {
                 oldExchange.getMessage().setBody(newExchange.getMessage().getBody());
-            } else if ("headers".equals(part)) {
-                oldExchange.getMessage().getHeaders().putAll(newExchange.getMessage().getHeaders());
-            } else if (part.startsWith("header:")) {
-                // pattern matching for headers, eg header:foo, header:foo*, header:(foo|bar)
-                String after = StringHelper.after(part, "header:");
-                Iterable i = ObjectHelper.createIterable(after, ",");
-                for (Object o : i) {
-                    String pattern = o.toString();
-                    for (Map.Entry<String, Object> header : newExchange.getMessage().getHeaders().entrySet()) {
-                        String key = header.getKey();
-                        if (EndpointHelper.matchPattern(key, pattern)) {
-                            oldExchange.getMessage().getHeaders().put(key, header.getValue());
+                LOG.trace("Including: body");
+            }
+
+            // if not all headers is excluded, then check each header one-by-one
+            if (!isExcluded("headers")) {
+                // check if we exclude a specific headers
+                Iterable it = ObjectHelper.createIterable(exclude, ",");
+                for (Object k : it) {
+                    String part = k.toString();
+                    if (part.startsWith("header:")) {
+                        // pattern matching for headers, eg header:foo, header:foo*, header:(foo|bar)
+                        String after = StringHelper.after(part, "header:");
+                        Iterable i = ObjectHelper.createIterable(after, ",");
+                        for (Object o : i) {
+                            String pattern = o.toString();
+                            for (Map.Entry<String, Object> header : newExchange.getMessage().getHeaders().entrySet()) {
+                                String key = header.getKey();
+                                boolean excluded = EndpointHelper.matchPattern(key, pattern);
+                                if (!excluded) {
+                                    LOG.trace("Including: header:{}", key);
+                                    oldExchange.getMessage().getHeaders().put(key, header.getValue());
+                                } else {
+                                    LOG.trace("Excluding: header:{}", key);
+                                }
+                            }
                         }
                     }
                 }
@@ -89,4 +142,21 @@ public class ClaimCheckAggregationStrategy implements AggregationStrategy {
 
         return oldExchange;
     }
+
+    private boolean isExcluded(String key) {
+        if (ObjectHelper.isEmpty(exclude)) {
+            return false;
+        }
+        String[] excludes = exclude.split(",");
+        for (String pattern : excludes) {
+            if (pattern.startsWith("header:")) {
+                pattern = StringHelper.after(pattern, "header:");
+            }
+            if (EndpointHelper.matchPattern(key, pattern)) {
+                LOG.trace("Excluding: {}", key);
+                return true;
+            }
+        }
+        return false;
+    }
 }
diff --git a/camel-core/src/main/java/org/apache/camel/processor/ClaimCheckProcessor.java b/camel-core/src/main/java/org/apache/camel/processor/ClaimCheckProcessor.java
index 137ecbf..2421878 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/ClaimCheckProcessor.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/ClaimCheckProcessor.java
@@ -38,7 +38,7 @@ import org.slf4j.LoggerFactory;
  * <p/>
  * The current Claim Check EIP implementation in Camel is only intended for temporary memory repository. Likewise
  * the repository is not shared among {@link Exchange}s, but a private instance is created per {@link Exchange}.
- * This guards against concurrent and thread-safe issues. For off-memeory persistent storage of data, then use
+ * This guards against concurrent and thread-safe issues. For off-memory persistent storage of data, then use
  * any of the many Camel components that support persistent storage, and do not use this Claim Check EIP implementation.
  */
 public class ClaimCheckProcessor extends ServiceSupport implements AsyncProcessor, IdAware, CamelContextAware {
@@ -50,6 +50,7 @@ public class ClaimCheckProcessor extends ServiceSupport implements AsyncProcesso
     private AggregationStrategy aggregationStrategy;
     private String key;
     private String include;
+    private String exclude;
 
     @Override
     public CamelContext getCamelContext() {
@@ -103,6 +104,14 @@ public class ClaimCheckProcessor extends ServiceSupport implements AsyncProcesso
         this.include = include;
     }
 
+    public String getExclude() {
+        return exclude;
+    }
+
+    public void setExclude(String exclude) {
+        this.exclude = exclude;
+    }
+
     public void process(Exchange exchange) throws Exception {
         AsyncProcessorHelper.process(this, exchange);
     }
@@ -198,6 +207,7 @@ public class ClaimCheckProcessor extends ServiceSupport implements AsyncProcesso
     protected AggregationStrategy createAggregationStrategy() {
         ClaimCheckAggregationStrategy answer = new ClaimCheckAggregationStrategy();
         answer.setInclude(include);
+        answer.setExclude(exclude);
         return answer;
     }
 }
diff --git a/camel-core/src/test/java/org/apache/camel/processor/ClaimCheckEipPushPopExcludeBodyTest.java b/camel-core/src/test/java/org/apache/camel/processor/ClaimCheckEipPushPopExcludeBodyTest.java
new file mode 100644
index 0000000..6ddbb29
--- /dev/null
+++ b/camel-core/src/test/java/org/apache/camel/processor/ClaimCheckEipPushPopExcludeBodyTest.java
@@ -0,0 +1,60 @@
+/**
+ * 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.camel.processor;
+
+import org.apache.camel.ContextTestSupport;
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.model.ClaimCheckOperation;
+
+public class ClaimCheckEipPushPopExcludeBodyTest extends ContextTestSupport {
+
+    public void testPushPopBodyExclude() throws Exception {
+        getMockEndpoint("mock:a").expectedBodiesReceived("Hello World");
+        getMockEndpoint("mock:a").expectedHeaderReceived("foo", 123);
+        getMockEndpoint("mock:a").expectedHeaderReceived("bar", "Moes");
+        getMockEndpoint("mock:b").expectedBodiesReceived("Bye World");
+        getMockEndpoint("mock:b").expectedHeaderReceived("foo", 456);
+        getMockEndpoint("mock:b").expectedHeaderReceived("bar", "Jacks");
+        getMockEndpoint("mock:c").expectedBodiesReceived("Hello World");
+        getMockEndpoint("mock:c").expectedHeaderReceived("foo", 123);
+        getMockEndpoint("mock:c").expectedHeaderReceived("bar", "Jacks");
+
+        template.sendBodyAndHeader("direct:start", "Hello World", "foo", 123);
+
+        assertMockEndpointsSatisfied();
+    }
+
+    @Override
+    protected RouteBuilder createRouteBuilder() throws Exception {
+        return new RouteBuilder() {
+            @Override
+            public void configure() throws Exception {
+                from("direct:start")
+                    .setHeader("bar", constant("Moes"))
+                    .to("mock:a")
+                    .claimCheck(ClaimCheckOperation.Push)
+                    .transform().constant("Bye World")
+                    .setHeader("foo", constant(456))
+                    .setHeader("bar", constant("Jacks"))
+                    .to("mock:b")
+                    // skip the foo header
+                    .claimCheck(ClaimCheckOperation.Pop, null, null, "header:bar")
+                    .to("mock:c");
+            }
+        };
+    }
+}

-- 
To stop receiving notification emails like this one, please contact
davsclaus@apache.org.

[camel] 02/03: CAMEL-8958: Claim Check EIP with push/pop. Work in progress.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch 8958
in repository https://gitbox.apache.org/repos/asf/camel.git

commit b9b52f74f2bbc48c38b93d8db0833e9a4cd79231
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Feb 6 09:40:13 2018 +0100

    CAMEL-8958: Claim Check EIP with push/pop. Work in progress.
---
 camel-core/src/main/docs/eips/claimCheck-eip.adoc  |  2 +-
 .../apache/camel/model/ClaimCheckDefinition.java   | 24 +++++++++++-----------
 .../apache/camel/model/ProcessorDefinition.java    |  7 +++----
 .../processor/ClaimCheckAggregationStrategy.java   | 21 ++++++++++++-------
 .../camel/processor/ClaimCheckProcessor.java       | 18 ++++++++--------
 .../processor/ClaimCheckEipPushPopBodyTest.xml     |  2 +-
 .../ClaimCheckEipPushPopHeadersPatternTest.xml     |  2 +-
 .../processor/ClaimCheckEipPushPopHeadersTest.xml  |  2 +-
 8 files changed, 43 insertions(+), 35 deletions(-)

diff --git a/camel-core/src/main/docs/eips/claimCheck-eip.adoc b/camel-core/src/main/docs/eips/claimCheck-eip.adoc
index a250cff..e4dc44a 100644
--- a/camel-core/src/main/docs/eips/claimCheck-eip.adoc
+++ b/camel-core/src/main/docs/eips/claimCheck-eip.adoc
@@ -20,7 +20,7 @@ The Claim Check EIP supports 5 options which are listed below:
 | Name | Description | Default | Type
 | *operation* | *Required* The claim check operation to use. The following operations is supported: Get - Gets (does not remove) the claim check by the given key. GetAndRemove - Gets and remove the claim check by the given key. Set - Sets a new (will override if key already exists) claim check with the given key. Push - Sets a new claim check on the stack (does not use key). Pop - Gets the latest claim check from the stack (does not use key). |  | ClaimCheckOperation
 | *key* | To use a specific key for claim check id. |  | String
-| *data* | What data to merge when claiming from the repository. The following syntax is supported: body - to aggregate the message body headers - to aggregate all the message headers header:pattern - to aggregate all the message headers that matches the pattern. The pattern syntax is documented by: link EndpointHelpermatchPattern(String String). You can specify multiple rules separated by comma. For example to include the message body and all headers starting with foo bodyheader:foo. If [...]
+| *include* | What data to include when merging data back from claim check repository. The following syntax is supported: body - to aggregate the message body headers - to aggregate all the message headers header:pattern - to aggregate all the message headers that matches the pattern. The pattern syntax is documented by: link EndpointHelpermatchPattern(String String). You can specify multiple rules separated by comma. For example to include the message body and all headers starting with  [...]
 | *strategyRef* | To use a custom AggregationStrategy instead of the default implementation. Notice you cannot use both custom aggregation strategy and configure data at the same time. |  | String
 | *strategyMethodName* | This option can be used to explicit declare the method name to use when using POJOs as the AggregationStrategy. |  | String
 |===
diff --git a/camel-core/src/main/java/org/apache/camel/model/ClaimCheckDefinition.java b/camel-core/src/main/java/org/apache/camel/model/ClaimCheckDefinition.java
index d38460f..a78fe60 100644
--- a/camel-core/src/main/java/org/apache/camel/model/ClaimCheckDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/ClaimCheckDefinition.java
@@ -46,7 +46,7 @@ public class ClaimCheckDefinition extends NoOutputDefinition<ClaimCheckDefinitio
     @XmlAttribute
     private String key;
     @XmlAttribute
-    private String data;
+    private String include;
     @XmlAttribute(name = "strategyRef") @Metadata(label = "advanced")
     private String aggregationStrategyRef;
     @XmlAttribute(name = "strategyMethodName") @Metadata(label = "advanced")
@@ -78,7 +78,7 @@ public class ClaimCheckDefinition extends NoOutputDefinition<ClaimCheckDefinitio
         ClaimCheckProcessor claim = new ClaimCheckProcessor();
         claim.setOperation(operation.name());
         claim.setKey(getKey());
-        claim.setData(getData());
+        claim.setInclude(getInclude());
 
         AggregationStrategy strategy = createAggregationStrategy(routeContext);
         if (strategy != null) {
@@ -86,8 +86,8 @@ public class ClaimCheckDefinition extends NoOutputDefinition<ClaimCheckDefinitio
         }
 
         // only data or aggregation strategy can be configured not both
-        if (getData() != null && strategy != null) {
-            throw new IllegalArgumentException("Cannot use both data and custom aggregation strategy on ClaimCheck EIP");
+        if (getInclude() != null && strategy != null) {
+            throw new IllegalArgumentException("Cannot use both include/exclude and custom aggregation strategy on ClaimCheck EIP");
         }
 
         return claim;
@@ -141,7 +141,7 @@ public class ClaimCheckDefinition extends NoOutputDefinition<ClaimCheckDefinitio
     }
 
     /**
-     * What data to merge when claiming from the repository.
+     * What data to include when merging data back from claim check repository.
      *
      * The following syntax is supported:
      * <ul>
@@ -152,10 +152,10 @@ public class ClaimCheckDefinition extends NoOutputDefinition<ClaimCheckDefinitio
      * </ul>
      * You can specify multiple rules separated by comma. For example to include the message body and all headers starting with foo
      * <tt>body,header:foo*</tt>.
-     * If the data rule is specified as empty or as wildcard then everything is merged.
+     * If the include rule is specified as empty or as wildcard then everything is included.
      */
-    public ClaimCheckDefinition data(String data) {
-        setData(data);
+    public ClaimCheckDefinition include(String include) {
+        setInclude(include);
         return this;
     }
 
@@ -204,12 +204,12 @@ public class ClaimCheckDefinition extends NoOutputDefinition<ClaimCheckDefinitio
         this.operation = operation;
     }
 
-    public String getData() {
-        return data;
+    public String getInclude() {
+        return include;
     }
 
-    public void setData(String data) {
-        this.data = data;
+    public void setInclude(String include) {
+        this.include = include;
     }
 
     public String getAggregationStrategyRef() {
diff --git a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
index 19ac9c8..ac0e635 100644
--- a/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
+++ b/camel-core/src/main/java/org/apache/camel/model/ProcessorDefinition.java
@@ -69,7 +69,6 @@ import org.apache.camel.processor.interceptor.StreamCaching;
 import org.apache.camel.processor.loadbalancer.LoadBalancer;
 import org.apache.camel.spi.AsEndpointUri;
 import org.apache.camel.spi.AsPredicate;
-import org.apache.camel.spi.ClaimCheckRepository;
 import org.apache.camel.spi.DataFormat;
 import org.apache.camel.spi.IdAware;
 import org.apache.camel.spi.IdempotentRepository;
@@ -3493,13 +3492,13 @@ public abstract class ProcessorDefinition<Type extends ProcessorDefinition<Type>
      *
      * @param operation the claim check operation to use.
      * @param key       the unique key to use for the get and set operations, can be <tt>null</tt> for push/pop operations
-     * @param data      describes what data to retrieve and merge back when using get or pop operations.
+     * @param include   describes what data to include and retrieve and merge back when using get or pop operations.
      */
-    public Type claimCheck(ClaimCheckOperation operation, String key, String data) {
+    public Type claimCheck(ClaimCheckOperation operation, String key, String include) {
         ClaimCheckDefinition answer = new ClaimCheckDefinition();
         answer.setOperation(operation);
         answer.setKey(key);
-        answer.setData(data);
+        answer.setInclude(include);
         addOutput(answer);
         return (Type) this;
     }
diff --git a/camel-core/src/main/java/org/apache/camel/processor/ClaimCheckAggregationStrategy.java b/camel-core/src/main/java/org/apache/camel/processor/ClaimCheckAggregationStrategy.java
index 80b9bc0..02e0d7d 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/ClaimCheckAggregationStrategy.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/ClaimCheckAggregationStrategy.java
@@ -27,7 +27,7 @@ import org.apache.camel.util.StringHelper;
 /**
  * Default {@link AggregationStrategy} used by the {@link ClaimCheckProcessor} EIP.
  * <p/>
- * This strategy supports the following data rules syntax:
+ * This strategy supports the following include rules syntax:
  * <ul>
  *     <li>body</li> - to aggregate the message body
  *     <li>headers</li> - to aggregate all the message headers
@@ -36,14 +36,21 @@ import org.apache.camel.util.StringHelper;
  * </ul>
  * You can specify multiple rules separated by comma. For example to include the message body and all headers starting with foo
  * <tt>body,header:foo*</tt>.
- * If the data rule is specified as empty or as wildcard then everything is merged.
+ * If the include rule is specified as empty or as wildcard then everything is merged.
  */
 public class ClaimCheckAggregationStrategy implements AggregationStrategy {
 
-    private final String data; // describes what data to merge
+    private String include;
 
-    public ClaimCheckAggregationStrategy(String data) {
-        this.data = data;
+    public ClaimCheckAggregationStrategy() {
+    }
+
+    public String getInclude() {
+        return include;
+    }
+
+    public void setInclude(String include) {
+        this.include = include;
     }
 
     @Override
@@ -52,12 +59,12 @@ public class ClaimCheckAggregationStrategy implements AggregationStrategy {
             return oldExchange;
         }
 
-        if (ObjectHelper.isEmpty(data) || "*".equals(data)) {
+        if (ObjectHelper.isEmpty(include) || "*".equals(include)) {
             // grab everything if data is empty or wildcard
             return newExchange;
         }
 
-        Iterable it = ObjectHelper.createIterable(data, ",");
+        Iterable it = ObjectHelper.createIterable(include, ",");
         for (Object k : it) {
             String part = k.toString();
             if ("body".equals(part)) {
diff --git a/camel-core/src/main/java/org/apache/camel/processor/ClaimCheckProcessor.java b/camel-core/src/main/java/org/apache/camel/processor/ClaimCheckProcessor.java
index 9a904e9..137ecbf 100644
--- a/camel-core/src/main/java/org/apache/camel/processor/ClaimCheckProcessor.java
+++ b/camel-core/src/main/java/org/apache/camel/processor/ClaimCheckProcessor.java
@@ -49,7 +49,7 @@ public class ClaimCheckProcessor extends ServiceSupport implements AsyncProcesso
     private String operation;
     private AggregationStrategy aggregationStrategy;
     private String key;
-    private String data;
+    private String include;
 
     @Override
     public CamelContext getCamelContext() {
@@ -95,12 +95,12 @@ public class ClaimCheckProcessor extends ServiceSupport implements AsyncProcesso
         this.key = key;
     }
 
-    public String getData() {
-        return data;
+    public String getInclude() {
+        return include;
     }
 
-    public void setData(String data) {
-        this.data = data;
+    public void setInclude(String include) {
+        this.include = include;
     }
 
     public void process(Exchange exchange) throws Exception {
@@ -176,7 +176,7 @@ public class ClaimCheckProcessor extends ServiceSupport implements AsyncProcesso
         ObjectHelper.notNull(operation, "operation", this);
 
         if (aggregationStrategy == null) {
-            aggregationStrategy = createAggregationStrategy(data);
+            aggregationStrategy = createAggregationStrategy();
         }
         if (aggregationStrategy instanceof CamelContextAware) {
             ((CamelContextAware) aggregationStrategy).setCamelContext(camelContext);
@@ -195,7 +195,9 @@ public class ClaimCheckProcessor extends ServiceSupport implements AsyncProcesso
         return "ClaimCheck[" + operation + "]";
     }
 
-    protected AggregationStrategy createAggregationStrategy(String data) {
-        return new ClaimCheckAggregationStrategy(data);
+    protected AggregationStrategy createAggregationStrategy() {
+        ClaimCheckAggregationStrategy answer = new ClaimCheckAggregationStrategy();
+        answer.setInclude(include);
+        return answer;
     }
 }
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ClaimCheckEipPushPopBodyTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ClaimCheckEipPushPopBodyTest.xml
index 7abb4f8..e4e2661 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ClaimCheckEipPushPopBodyTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ClaimCheckEipPushPopBodyTest.xml
@@ -36,7 +36,7 @@
         <constant>456</constant>
       </setHeader>
       <to uri="mock:b"/>
-      <claimCheck operation="Pop" data="body"/>
+      <claimCheck operation="Pop" include="body"/>
       <to uri="mock:c"/>
     </route>
   </camelContext>
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ClaimCheckEipPushPopHeadersPatternTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ClaimCheckEipPushPopHeadersPatternTest.xml
index e79fdfb..13eb12e 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ClaimCheckEipPushPopHeadersPatternTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ClaimCheckEipPushPopHeadersPatternTest.xml
@@ -37,7 +37,7 @@
       </setHeader>
       <removeHeader headerName="bar"/>
       <to uri="mock:b"/>
-      <claimCheck operation="Pop" data="header:(foo|bar)"/>
+      <claimCheck operation="Pop" include="header:(foo|bar)"/>
       <to uri="mock:c"/>
     </route>
   </camelContext>
diff --git a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ClaimCheckEipPushPopHeadersTest.xml b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ClaimCheckEipPushPopHeadersTest.xml
index 1210b5e..e56be5e 100644
--- a/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ClaimCheckEipPushPopHeadersTest.xml
+++ b/components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ClaimCheckEipPushPopHeadersTest.xml
@@ -36,7 +36,7 @@
         <constant>456</constant>
       </setHeader>
       <to uri="mock:b"/>
-      <claimCheck operation="Pop" data="headers"/>
+      <claimCheck operation="Pop" include="headers"/>
       <to uri="mock:c"/>
     </route>
   </camelContext>

-- 
To stop receiving notification emails like this one, please contact
davsclaus@apache.org.

[camel] 01/03: CAMEL-8958: Claim Check EIP with push/pop. Work in progress.

Posted by da...@apache.org.
This is an automated email from the ASF dual-hosted git repository.

davsclaus pushed a commit to branch 8958
in repository https://gitbox.apache.org/repos/asf/camel.git

commit b7c3250a071a36be00eaa16c890093d5602a6352
Author: Claus Ibsen <cl...@gmail.com>
AuthorDate: Tue Feb 6 09:31:56 2018 +0100

    CAMEL-8958: Claim Check EIP with push/pop. Work in progress.
---
 camel-core/readme-eip.adoc | 5 ++++-
 1 file changed, 4 insertions(+), 1 deletion(-)

diff --git a/camel-core/readme-eip.adoc b/camel-core/readme-eip.adoc
index c7474f3..3d652eb 100644
--- a/camel-core/readme-eip.adoc
+++ b/camel-core/readme-eip.adoc
@@ -4,7 +4,7 @@ Enterprise Integration Patterns
 Camel supports most of the link:http://www.eaipatterns.com/toc.html[Enterprise Integration Patterns] from the excellent book by link:http://www.amazon.com/exec/obidos/search-handle-url/105-9796798-8100401?%5Fencoding=UTF8&search-type=ss&index=books&field-author=Gregor%20Hohpe[Gregor Hohpe] and link:http://www.amazon.com/exec/obidos/search-handle-url/105-9796798-8100401?%5Fencoding=UTF8&search-type=ss&index=books&field-author=Bobby%20Woolf[Bobby Woolf].
 
 // eips: START
-Number of EIPs: 63 (2 deprecated)
+Number of EIPs: 64 (2 deprecated)
 
 [width="100%",cols="4,6",options="header"]
 |===
@@ -25,6 +25,9 @@ Number of EIPs: 63 (2 deprecated)
 | link:src/main/docs/eips/circuitBreaker-eip.adoc[Circuit Breaker] +
 `<circuitBreaker>` | *deprecated* Circuit break load balancer
 
+| link:src/main/docs/eips/claimCheck-eip.adoc[Claim Check] +
+`<claimCheck>` | The Claim Check EIP allows you to replace message content with a claim check (a unique key) which can be used to retrieve the message content at a later time.
+
 | link:src/main/docs/eips/convertBodyTo-eip.adoc[Convert Body To] +
 `<convertBodyTo>` | Converts the message body to another type
 

-- 
To stop receiving notification emails like this one, please contact
davsclaus@apache.org.