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 e0d71c494b6dccef22f6055108ae7e142e287cc0
Author: Claus Ibsen <claus.ib...@gmail.com>
AuthorDate: Tue Feb 6 14:46:04 2018 +0100

    CAMEL-8958: Claim Check EIP with push/pop. Work in progress.
---
 camel-core/src/main/docs/eips/claimCheck-eip.adoc  | 59 ++++++++++++++++------
 ...SpringClaimCheckEipPushPopRemoveHeaderTest.java | 29 +++++++++++
 .../processor/ClaimCheckEipPushPopBodyTest.xml     |  2 +-
 .../ClaimCheckEipPushPopHeadersPatternTest.xml     |  2 +-
 .../processor/ClaimCheckEipPushPopHeadersTest.xml  |  2 +-
 ...ml => ClaimCheckEipPushPopRemoveHeaderTest.xml} |  9 +++-
 6 files changed, 83 insertions(+), 20 deletions(-)

diff --git a/camel-core/src/main/docs/eips/claimCheck-eip.adoc 
b/camel-core/src/main/docs/eips/claimCheck-eip.adoc
index a0ff103..4a505ca 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 6 options which are listed below:
+The Claim Check EIP supports 5 options which are listed below:
 
 
 [width="100%",cols="2,5,^1,2",options="header"]
@@ -20,8 +20,7 @@ The Claim Check EIP supports 6 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  [...]
-| *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  [...]
+| *filter* | Specified a filter to control what data gets merging data back 
from the 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  [...]
 | *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
 |===
@@ -44,24 +43,26 @@ These operations will then store and retrieve the data 
using this key. You can u
 The `Push` and `Pop` operations do *not* use a key but stores the data in a 
stack structure.
 
 
-=== What data to merge back
+=== Filter what data to merge back
 
-The `data` option is used to define what data to merge back when using the 
`Get` or `Pop` operation. When data is merged back
-then its merged using a `AggregationStrategy`. The default strategy uses the 
`data` option to easily specify what data to merge back.
+The `filter` option is used to define what data to merge back when using the 
`Get` or `Pop` operation. When data is merged back
+then its merged using a `AggregationStrategy`. The default strategy uses the 
`filter` option to easily specify what data to merge back.
 
-The `data` option takes a String value with the following syntax:
+The `filter` option takes a `String` value with the following syntax:
 
-* 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.
+* `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 rule supports wildcard and regular expression:
 
-* wildcard match (pattern ends with a * and the name starts with the pattern)
+* wildcard match (pattern ends with a `*` and the name starts with the pattern)
 * regular expression match
 
 You can specify multiple rules separated by comma.
 
+==== Basic filter examples
+
 For example to include the message body and all headers starting with _foo_:
 
 [text]
@@ -90,9 +91,34 @@ To only merge back a header name foo:
 header:foo
 ----
 
-If the data rule is specified as empty or as wildcard then everything is 
merged.
+If the filter rule is specified as empty or as wildcard then everything is 
merged.
+
+Notice that when merging back data, then any existing data is overwritten, and 
any other existing data is preserved.
+
+==== Fine grained filtering with include and explude pattern
+
+The syntax also supports the following prefixes which can be used to specify 
include,exclude, or remove
+
+* `+` = to include (which is the default mode)
+* `-` = to exclude (exclude takes precedence over include)
+* `--` = to remove (remove takes precedence)
+
+For example to skip the message body, and merge back everything else
+----
+-body
+----
+
+Or to skip the message header foo, and merge back everything else
+----
+-header:foo
+----
+
+You can also instruct to remove headers when merging data back, for example to 
remove all headers starting with _bar_:
+----
+--headers:bar*
+----
 
-Notice that when merging back data, then any existing data is overriden, and 
any other existing data is preserved.
+Note you cannot have both include (`+`) and exclude (`-`) `header:pattern` at 
the same time.
 
 
 === Java Examples
@@ -134,7 +160,7 @@ from("direct:start")
 Notice how we can `Get` the same data twice using the `Get` operation as it 
will not remove the data. If you only want
 to get the data once, you can use `GetAndRemove`.
 
-The last example shows how to use the `data` option where we only want to get 
back header named `foo` or `bar`:
+The last example shows how to use the `filter` option where we only want to 
get back header named `foo` or `bar`:
 
 [java]
 ----
@@ -199,7 +225,7 @@ Here is an example using `Get` and `Set` operations, which 
uses the key `foo`:
 Notice how we can `Get` the same data twice using the `Get` operation as it 
will not remove the data. If you only want
 to get the data once, you can use `GetAndRemove`.
 
-The last example shows how to use the `data` option where we only want to get 
back header named `foo` or `bar`:
+The last example shows how to use the `filter` option where we only want to 
get back header named `foo` or `bar`:
 
 [xml]
 ----
@@ -215,7 +241,8 @@ The last example shows how to use the `data` option where 
we only want to get ba
   </setHeader>
   <removeHeader headerName="bar"/>
   <to uri="mock:b"/>
-  <claimCheck operation="Pop" data="header:(foo|bar)"/>
+  <!-- only merge in the message headers foo or bar -->
+  <claimCheck operation="Pop" filter="header:(foo|bar)"/>
   <to uri="mock:c"/>
 </route>
 ----
diff --git 
a/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringClaimCheckEipPushPopRemoveHeaderTest.java
 
b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringClaimCheckEipPushPopRemoveHeaderTest.java
new file mode 100644
index 0000000..15bdb20
--- /dev/null
+++ 
b/components/camel-spring/src/test/java/org/apache/camel/spring/processor/SpringClaimCheckEipPushPopRemoveHeaderTest.java
@@ -0,0 +1,29 @@
+/**
+ * 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.spring.processor;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.processor.ClaimCheckEipPushPopRemoveHeaderTest;
+
+import static 
org.apache.camel.spring.processor.SpringTestHelper.createSpringCamelContext;
+
+public class SpringClaimCheckEipPushPopRemoveHeaderTest extends 
ClaimCheckEipPushPopRemoveHeaderTest {
+
+    protected CamelContext createCamelContext() throws Exception {
+        return createSpringCamelContext(this, 
"org/apache/camel/spring/processor/ClaimCheckEipPushPopRemoveHeaderTest.xml");
+    }
+}
\ No newline at end of file
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 e4e2661..d6c53ad 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" include="body"/>
+      <claimCheck operation="Pop" filter="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 13eb12e..6efad19 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" include="header:(foo|bar)"/>
+      <claimCheck operation="Pop" filter="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 e56be5e..a0deac7 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" include="headers"/>
+      <claimCheck operation="Pop" filter="headers"/>
       <to uri="mock:c"/>
     </route>
   </camelContext>
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/ClaimCheckEipPushPopRemoveHeaderTest.xml
similarity index 84%
copy from 
components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ClaimCheckEipPushPopBodyTest.xml
copy to 
components/camel-spring/src/test/resources/org/apache/camel/spring/processor/ClaimCheckEipPushPopRemoveHeaderTest.xml
index e4e2661..752f2d1 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/ClaimCheckEipPushPopRemoveHeaderTest.xml
@@ -27,6 +27,9 @@
   <camelContext xmlns="http://camel.apache.org/schema/spring";>
     <route>
       <from uri="direct:start"/>
+      <setHeader headerName="bar">
+        <constant>Moes</constant>
+      </setHeader>
       <to uri="mock:a"/>
       <claimCheck operation="Push"/>
       <transform>
@@ -35,8 +38,12 @@
       <setHeader headerName="foo">
         <constant>456</constant>
       </setHeader>
+      <setHeader headerName="bar">
+        <constant>Jacks</constant>
+      </setHeader>
       <to uri="mock:b"/>
-      <claimCheck operation="Pop" include="body"/>
+      <!-- // skip the body and remove the bar header -->
+      <claimCheck operation="Pop" filter="-body,--header:bar"/>
       <to uri="mock:c"/>
     </route>
   </camelContext>

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

Reply via email to