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

nfilotto pushed a commit to branch CAMEL-17792/doc-message-headers
in repository https://gitbox.apache.org/repos/asf/camel.git

commit 808555f64b57f6ef67a05c75996e77a9a9994c3b
Author: Nicolas Filotto <[email protected]>
AuthorDate: Mon Mar 21 14:52:36 2022 +0100

    CAMEL-17792: Add doc about the message headers of camel-flatpack
---
 .../apache/camel/component/flatpack/flatpack.json  |  3 +++
 .../src/main/docs/flatpack-component.adoc          | 15 +++--------
 .../component/flatpack/FlatpackConstants.java      | 31 ++++++++++++++++++++++
 .../camel/component/flatpack/FlatpackEndpoint.java |  4 +--
 4 files changed, 39 insertions(+), 14 deletions(-)

diff --git 
a/components/camel-flatpack/src/generated/resources/org/apache/camel/component/flatpack/flatpack.json
 
b/components/camel-flatpack/src/generated/resources/org/apache/camel/component/flatpack/flatpack.json
index 9de2d96..1dd426e 100644
--- 
a/components/camel-flatpack/src/generated/resources/org/apache/camel/component/flatpack/flatpack.json
+++ 
b/components/camel-flatpack/src/generated/resources/org/apache/camel/component/flatpack/flatpack.json
@@ -26,6 +26,9 @@
     "lazyStartProducer": { "kind": "property", "displayName": "Lazy Start 
Producer", "group": "producer", "label": "producer", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": false, "description": "Whether the producer 
should be started lazy (on the first message). By starting lazy you can use 
this to allow CamelContext and routes to startup in situations where a producer 
may otherwise fail during star [...]
     "autowiredEnabled": { "kind": "property", "displayName": "Autowired 
Enabled", "group": "advanced", "label": "advanced", "required": false, "type": 
"boolean", "javaType": "boolean", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": true, "description": "Whether autowiring is 
enabled. This is used for automatic autowiring options (the option must be 
marked as autowired) by looking up in the registry to find if there is a single 
instance of matching type, which t [...]
   },
+  "headers": {
+    "CamelFlatpackCounter": { "kind": "header", "displayName": "", "group": 
"producer", "label": "producer", "required": false, "javaType": "int", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "description": "The current row index. For `splitRows=false` the counter 
is the total\nnumber of rows." }
+  },
   "properties": {
     "type": { "kind": "path", "displayName": "Type", "group": "common", 
"label": "", "required": false, "type": "object", "javaType": 
"org.apache.camel.component.flatpack.FlatpackType", "enum": [ "fixed", "delim" 
], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "defaultValue": "delim", "description": "Whether to use fixed or 
delimiter" },
     "resourceUri": { "kind": "path", "displayName": "Resource Uri", "group": 
"common", "label": "", "required": true, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "URL for loading the flatpack mapping 
file from classpath or file system" },
diff --git a/components/camel-flatpack/src/main/docs/flatpack-component.adoc 
b/components/camel-flatpack/src/main/docs/flatpack-component.adoc
index 781060b..9dbbb5a 100644
--- a/components/camel-flatpack/src/main/docs/flatpack-component.adoc
+++ b/components/camel-flatpack/src/main/docs/flatpack-component.adoc
@@ -45,6 +45,9 @@ include::partial$component-endpoint-options.adoc[]
 // endpoint options: START
 
 // endpoint options: END
+// component headers: START
+include::partial$component-endpoint-headers.adoc[]
+// component headers: END
 
 == Examples
 
@@ -55,18 +58,6 @@ the `foo.pzmap.xml` file configuration.
 * `flatpack:foo` creates a delimited endpoint called `foo` with no file
 configuration.
 
-== Message Headers
-
-Camel will store the following headers on the IN message:
-
-[width="100%",cols="50%,50%",options="header",]
-|=======================================================================
-|Header |Description
-
-|`camelFlatpackCounter` |The current row index. For `splitRows=false` the 
counter is the total
-number of rows.
-|=======================================================================
-
 == Message Body
 
 The component delivers the data in the IN message as a
diff --git 
a/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackConstants.java
 
b/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackConstants.java
new file mode 100644
index 0000000..5e6c396
--- /dev/null
+++ 
b/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackConstants.java
@@ -0,0 +1,31 @@
+/*
+ * 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.component.flatpack;
+
+import org.apache.camel.spi.Metadata;
+
+public final class FlatpackConstants {
+
+    @Metadata(label = "producer", description = "The current row index. For 
`splitRows=false` the counter is the total\n" +
+                                                "number of rows.",
+              javaType = "int")
+    public static final String FLATPACK_COUNTER = "CamelFlatpackCounter";
+
+    private FlatpackConstants() {
+        // Utility class
+    }
+}
diff --git 
a/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackEndpoint.java
 
b/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackEndpoint.java
index 8b5d315..eb00dcf 100644
--- 
a/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackEndpoint.java
+++ 
b/components/camel-flatpack/src/main/java/org/apache/camel/component/flatpack/FlatpackEndpoint.java
@@ -49,7 +49,7 @@ import org.apache.camel.util.ObjectHelper;
  * Parse fixed width and delimited files using the FlatPack library.
  */
 @UriEndpoint(firstVersion = "1.4.0", scheme = "flatpack", title = "Flatpack", 
syntax = "flatpack:type:resourceUri",
-             category = { Category.TRANSFORMATION })
+             category = { Category.TRANSFORMATION }, headersClass = 
FlatpackConstants.class)
 public class FlatpackEndpoint extends DefaultPollingEndpoint {
 
     private LoadBalancer loadBalancer = new RoundRobinLoadBalancer();
@@ -101,7 +101,7 @@ public class FlatpackEndpoint extends 
DefaultPollingEndpoint {
         Exchange exchange = 
ExchangeHelper.createCorrelatedCopy(originalExchange, false);
         Message in = exchange.getIn();
         in.setBody(dataSet);
-        in.setHeader("CamelFlatpackCounter", counter);
+        in.setHeader(FlatpackConstants.FLATPACK_COUNTER, counter);
         loadBalancer.process(exchange);
     }
 

Reply via email to