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 526ce2adc54c4ca4436eefc16d90567a546a0794
Author: Nicolas Filotto <[email protected]>
AuthorDate: Thu Mar 31 10:56:56 2022 +0200

    CAMEL-17792: Add doc about the message headers of camel-language
---
 .../apache/camel/component/language/language.json  |  3 +++
 .../src/main/docs/language-component.adoc          | 20 ++++----------
 .../component/language/LanguageConstants.java      | 31 ++++++++++++++++++++++
 .../camel/component/language/LanguageEndpoint.java |  2 +-
 .../camel/component/language/LanguageProducer.java |  4 +--
 5 files changed, 42 insertions(+), 18 deletions(-)

diff --git 
a/components/camel-language/src/generated/resources/org/apache/camel/component/language/language.json
 
b/components/camel-language/src/generated/resources/org/apache/camel/component/language/language.json
index 8c70707..cebbf73 100644
--- 
a/components/camel-language/src/generated/resources/org/apache/camel/component/language/language.json
+++ 
b/components/camel-language/src/generated/resources/org/apache/camel/component/language/language.json
@@ -25,6 +25,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": {
+    "CamelLanguageScript": { "kind": "header", "displayName": "", "group": 
"producer", "label": "", "required": false, "javaType": "String or Expression", 
"deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "description": "The script to execute provided in the header. Takes 
precedence over\nscript configured on the endpoint." }
+  },
   "properties": {
     "languageName": { "kind": "path", "displayName": "Language Name", "group": 
"producer", "label": "", "required": true, "type": "string", "javaType": 
"java.lang.String", "enum": [ "bean", "constant", "exchangeProperty", "file", 
"groovy", "header", "javascript", "jsonpath", "mvel", "ognl", "", "ref", 
"simple", "spel", "sql", "terser", "tokenize", "xpath", "xquery", "xtokenize" 
], "deprecated": false, "deprecationNote": "", "autowired": false, "secret": 
false, "description": "Sets the na [...]
     "resourceUri": { "kind": "path", "displayName": "Resource Uri", "group": 
"producer", "label": "", "required": false, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "Path to the resource, or a reference to 
lookup a bean in the Registry to use as the resource" },
diff --git a/components/camel-language/src/main/docs/language-component.adoc 
b/components/camel-language/src/main/docs/language-component.adoc
index a1fde42..1415ba8 100644
--- a/components/camel-language/src/main/docs/language-component.adoc
+++ b/components/camel-language/src/main/docs/language-component.adoc
@@ -55,23 +55,13 @@ include::partial$component-endpoint-options.adoc[]
 
 // endpoint options: END
 
-
-== Message Headers
-
-The following message headers can be used to affect the behavior of the
-component
-
-[width="100%",cols="10%,90%",options="header",]
-|===
-|Header |Description
-
-|`CamelLanguageScript` |The script to execute provided in the header. Takes 
precedence over
-script configured on the endpoint.
-|===
+// component headers: START
+include::partial$component-endpoint-headers.adoc[]
+// component headers: END
 
 == Examples
 
-For example you can use the xref:languages:simple-language.adoc[Simple] 
language to
+For example, you can use the xref:languages:simple-language.adoc[Simple] 
language to
 Message Translator a message:
 
 In case you want to convert the message body type you can do this as
@@ -96,7 +86,7 @@ You can specify a resource uri for a script to load in either 
the
 endpoint uri, or in the `Exchange.LANGUAGE_SCRIPT` header.
 The uri must start with one of the following schemes: file:, classpath:, or 
http:
 
-By default the script is loaded once and cached. However you can disable
+By default, the script is loaded once and cached. However, you can disable
 the `contentCache` option and have the script loaded on each
 evaluation. For example if the file myscript.txt is changed on disk, then the
 updated script is used:
diff --git 
a/components/camel-language/src/main/java/org/apache/camel/component/language/LanguageConstants.java
 
b/components/camel-language/src/main/java/org/apache/camel/component/language/LanguageConstants.java
new file mode 100644
index 0000000..dc5ca43
--- /dev/null
+++ 
b/components/camel-language/src/main/java/org/apache/camel/component/language/LanguageConstants.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.language;
+
+import org.apache.camel.Exchange;
+import org.apache.camel.spi.Metadata;
+
+public final class LanguageConstants {
+
+    @Metadata(description = "The script to execute provided in the header. 
Takes precedence over\n" +
+                            "script configured on the endpoint.",
+              javaType = "String or Expression")
+    public static final String LANGUAGE_SCRIPT = Exchange.LANGUAGE_SCRIPT;
+
+    private LanguageConstants() {
+    }
+}
diff --git 
a/components/camel-language/src/main/java/org/apache/camel/component/language/LanguageEndpoint.java
 
b/components/camel-language/src/main/java/org/apache/camel/component/language/LanguageEndpoint.java
index 0cab7b8..2363b37 100644
--- 
a/components/camel-language/src/main/java/org/apache/camel/component/language/LanguageEndpoint.java
+++ 
b/components/camel-language/src/main/java/org/apache/camel/component/language/LanguageEndpoint.java
@@ -47,7 +47,7 @@ import org.apache.camel.util.IOHelper;
  * defined as well.
  */
 @UriEndpoint(firstVersion = "2.5.0", scheme = "language", title = "Language", 
syntax = "language:languageName:resourceUri",
-             producerOnly = true, category = { Category.CORE, Category.SCRIPT 
})
+             producerOnly = true, category = { Category.CORE, Category.SCRIPT 
}, headersClass = LanguageConstants.class)
 public class LanguageEndpoint extends ResourceEndpoint {
     private Language language;
     private Expression expression;
diff --git 
a/components/camel-language/src/main/java/org/apache/camel/component/language/LanguageProducer.java
 
b/components/camel-language/src/main/java/org/apache/camel/component/language/LanguageProducer.java
index 01d3c6c..ae825ad 100644
--- 
a/components/camel-language/src/main/java/org/apache/camel/component/language/LanguageProducer.java
+++ 
b/components/camel-language/src/main/java/org/apache/camel/component/language/LanguageProducer.java
@@ -45,9 +45,9 @@ public class LanguageProducer extends DefaultProducer {
         String script = null;
 
         // is there a custom expression in the header?
-        Expression exp = exchange.getIn().getHeader(Exchange.LANGUAGE_SCRIPT, 
Expression.class);
+        Expression exp = 
exchange.getIn().getHeader(LanguageConstants.LANGUAGE_SCRIPT, Expression.class);
         if (exp == null) {
-            script = exchange.getIn().getHeader(Exchange.LANGUAGE_SCRIPT, 
String.class);
+            script = 
exchange.getIn().getHeader(LanguageConstants.LANGUAGE_SCRIPT, String.class);
             if (script != null) {
                 // the script may be a file: so resolve it before using
                 script = getEndpoint().resolveScript(script);

Reply via email to