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 5bbccd50a76cc8cea97246a00c79d9ea9877a6a0
Author: Nicolas Filotto <[email protected]>
AuthorDate: Wed Apr 6 17:14:10 2022 +0200

    CAMEL-17792: Add doc about the message headers of camel-xslt
---
 .../org/apache/camel/component/xslt/xslt.json          |  5 ++++-
 .../camel-xslt/src/main/docs/xslt-component.adoc       |  4 +++-
 .../camel/component/xslt/FileResultHandlerFactory.java |  2 +-
 .../org/apache/camel/component/xslt/XsltBuilder.java   |  2 +-
 ...ileResultHandlerFactory.java => XsltConstants.java} | 18 +++++++-----------
 .../org/apache/camel/component/xslt/XsltEndpoint.java  |  4 ++--
 6 files changed, 18 insertions(+), 17 deletions(-)

diff --git 
a/components/camel-xslt/src/generated/resources/org/apache/camel/component/xslt/xslt.json
 
b/components/camel-xslt/src/generated/resources/org/apache/camel/component/xslt/xslt.json
index 8911b0eefa6..de59a3faa72 100644
--- 
a/components/camel-xslt/src/generated/resources/org/apache/camel/component/xslt/xslt.json
+++ 
b/components/camel-xslt/src/generated/resources/org/apache/camel/component/xslt/xslt.json
@@ -30,13 +30,16 @@
     "uriResolver": { "kind": "property", "displayName": "Uri Resolver", 
"group": "advanced", "label": "advanced", "required": false, "type": "object", 
"javaType": "javax.xml.transform.URIResolver", "deprecated": false, 
"autowired": false, "secret": false, "description": "To use a custom 
UriResolver. Should not be used together with the option 'uriResolverFactory'." 
},
     "uriResolverFactory": { "kind": "property", "displayName": "Uri Resolver 
Factory", "group": "advanced", "label": "advanced", "required": false, "type": 
"object", "javaType": "org.apache.camel.component.xslt.XsltUriResolverFactory", 
"deprecated": false, "autowired": false, "secret": false, "description": "To 
use a custom UriResolver which depends on a dynamic endpoint resource URI. 
Should not be used together with the option 'uriResolver'." }
   },
+  "headers": {
+    "CamelXsltFileName": { "kind": "header", "displayName": "", "group": 
"producer", "label": "", "required": false, "javaType": "String", "deprecated": 
false, "deprecationNote": "", "autowired": false, "secret": false, 
"description": "The XSLT file name" }
+  },
   "properties": {
     "resourceUri": { "kind": "path", "displayName": "Resource Uri", "group": 
"producer", "label": "", "required": true, "type": "string", "javaType": 
"java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": 
false, "secret": false, "description": "Path to the template. The following is 
supported by the default URIResolver. You can prefix with: classpath, file, 
http, ref, or bean. classpath, file and http loads the resource using these 
protocols (classpath is default).  [...]
     "contentCache": { "kind": "parameter", "displayName": "Content Cache", 
"group": "producer", "label": "", "required": false, "type": "boolean", 
"javaType": "boolean", "deprecated": false, "autowired": false, "secret": 
false, "defaultValue": true, "description": "Cache for the resource content 
(the stylesheet file) when it is loaded. If set to false Camel will reload the 
stylesheet file on each message processing. This is good for development. A 
cached stylesheet can be forced to reloa [...]
     "deleteOutputFile": { "kind": "parameter", "displayName": "Delete Output 
File", "group": "producer", "label": "", "required": false, "type": "boolean", 
"javaType": "boolean", "deprecated": false, "autowired": false, "secret": 
false, "defaultValue": false, "description": "If you have output=file then this 
option dictates whether or not the output file should be deleted when the 
Exchange is done processing. For example suppose the output file is a temporary 
file, then it can be a good  [...]
     "failOnNullBody": { "kind": "parameter", "displayName": "Fail On Null 
Body", "group": "producer", "label": "", "required": false, "type": "boolean", 
"javaType": "boolean", "deprecated": false, "autowired": false, "secret": 
false, "defaultValue": true, "description": "Whether or not to throw an 
exception if the input body is null." },
     "lazyStartProducer": { "kind": "parameter", "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 sta [...]
-    "output": { "kind": "parameter", "displayName": "Output", "group": 
"producer", "label": "", "required": false, "type": "object", "javaType": 
"org.apache.camel.component.xslt.XsltOutput", "enum": [ "string", "bytes", 
"DOM", "file" ], "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": "string", "description": "Option to specify which output type 
to use. Possible values are: string, bytes, DOM, file. The first three options 
are all in memory based, where as file i [...]
+    "output": { "kind": "parameter", "displayName": "Output", "group": 
"producer", "label": "", "required": false, "type": "object", "javaType": 
"org.apache.camel.component.xslt.XsltOutput", "enum": [ "string", "bytes", 
"DOM", "file" ], "deprecated": false, "autowired": false, "secret": false, 
"defaultValue": "string", "description": "Option to specify which output type 
to use. Possible values are: string, bytes, DOM, file. The first three options 
are all in memory based, where as file i [...]
     "transformerCacheSize": { "kind": "parameter", "displayName": "Transformer 
Cache Size", "group": "producer", "label": "", "required": false, "type": 
"integer", "javaType": "int", "deprecated": false, "autowired": false, 
"secret": false, "defaultValue": 0, "description": "The number of 
javax.xml.transform.Transformer object that are cached for reuse to avoid calls 
to Template.newTransformer()." },
     "entityResolver": { "kind": "parameter", "displayName": "Entity Resolver", 
"group": "advanced", "label": "advanced", "required": false, "type": "object", 
"javaType": "org.xml.sax.EntityResolver", "deprecated": false, "autowired": 
false, "secret": false, "description": "To use a custom 
org.xml.sax.EntityResolver with javax.xml.transform.sax.SAXSource." },
     "errorListener": { "kind": "parameter", "displayName": "Error Listener", 
"group": "advanced", "label": "advanced", "required": false, "type": "object", 
"javaType": "javax.xml.transform.ErrorListener", "deprecated": false, 
"autowired": false, "secret": false, "description": "Allows to configure to use 
a custom javax.xml.transform.ErrorListener. Beware when doing this then the 
default error listener which captures any errors or fatal errors and store 
information on the Exchange as prop [...]
diff --git a/components/camel-xslt/src/main/docs/xslt-component.adoc 
b/components/camel-xslt/src/main/docs/xslt-component.adoc
index 87d4e112ccb..5e2e270aac8 100644
--- a/components/camel-xslt/src/main/docs/xslt-component.adoc
+++ b/components/camel-xslt/src/main/docs/xslt-component.adoc
@@ -57,7 +57,9 @@ include::partial$component-endpoint-options.adoc[]
 
 // endpoint options: END
 
-
+/ component headers: START
+include::partial$component-endpoint-headers.adoc[]
+// component headers: END
 
 == Using XSLT endpoints
 
diff --git 
a/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/FileResultHandlerFactory.java
 
b/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/FileResultHandlerFactory.java
index 08e92c5e95e..bf71b6278cb 100644
--- 
a/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/FileResultHandlerFactory.java
+++ 
b/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/FileResultHandlerFactory.java
@@ -28,7 +28,7 @@ public class FileResultHandlerFactory implements 
ResultHandlerFactory {
 
     @Override
     public ResultHandler createResult(Exchange exchange) throws Exception {
-        String fileName = ExchangeHelper.getMandatoryHeader(exchange, 
Exchange.XSLT_FILE_NAME, String.class);
+        String fileName = ExchangeHelper.getMandatoryHeader(exchange, 
XsltConstants.XSLT_FILE_NAME, String.class);
         return new FileResultHandler(new File(fileName));
     }
 }
diff --git 
a/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltBuilder.java
 
b/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltBuilder.java
index af7556e78ac..0fc6904e955 100644
--- 
a/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltBuilder.java
+++ 
b/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltBuilder.java
@@ -95,7 +95,7 @@ public class XsltBuilder implements Processor {
 
         if (isDeleteOutputFile()) {
             // add on completion so we can delete the file when the Exchange 
is done
-            String fileName = ExchangeHelper.getMandatoryHeader(exchange, 
Exchange.XSLT_FILE_NAME, String.class);
+            String fileName = ExchangeHelper.getMandatoryHeader(exchange, 
XsltConstants.XSLT_FILE_NAME, String.class);
             exchange.adapt(ExtendedExchange.class).addOnCompletion(new 
XsltBuilderOnCompletion(fileName));
         }
 
diff --git 
a/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/FileResultHandlerFactory.java
 
b/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltConstants.java
similarity index 64%
copy from 
components/camel-xslt/src/main/java/org/apache/camel/component/xslt/FileResultHandlerFactory.java
copy to 
components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltConstants.java
index 08e92c5e95e..9d92ad6db83 100644
--- 
a/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/FileResultHandlerFactory.java
+++ 
b/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltConstants.java
@@ -16,19 +16,15 @@
  */
 package org.apache.camel.component.xslt;
 
-import java.io.File;
-
 import org.apache.camel.Exchange;
-import org.apache.camel.support.ExchangeHelper;
+import org.apache.camel.spi.Metadata;
 
-/**
- * Factory for {@link javax.xml.transform.stream.StreamResult} which is 
streamed to file.
- */
-public class FileResultHandlerFactory implements ResultHandlerFactory {
+public final class XsltConstants {
+
+    @Metadata(description = "The XSLT file name", javaType = "String")
+    public static final String XSLT_FILE_NAME = Exchange.XSLT_FILE_NAME;
+
+    private XsltConstants() {
 
-    @Override
-    public ResultHandler createResult(Exchange exchange) throws Exception {
-        String fileName = ExchangeHelper.getMandatoryHeader(exchange, 
Exchange.XSLT_FILE_NAME, String.class);
-        return new FileResultHandler(new File(fileName));
     }
 }
diff --git 
a/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltEndpoint.java
 
b/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltEndpoint.java
index 9d3b8971a38..2285fcf2a4e 100644
--- 
a/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltEndpoint.java
+++ 
b/components/camel-xslt/src/main/java/org/apache/camel/component/xslt/XsltEndpoint.java
@@ -52,7 +52,7 @@ import org.slf4j.LoggerFactory;
  */
 @ManagedResource(description = "Managed XsltEndpoint")
 @UriEndpoint(firstVersion = "1.3.0", scheme = "xslt", title = "XSLT", syntax = 
"xslt:resourceUri", producerOnly = true,
-             label = "core,transformation")
+             label = "core,transformation", headersClass = XsltConstants.class)
 public class XsltEndpoint extends ProcessorEndpoint {
 
     private static final Logger LOG = 
LoggerFactory.getLogger(XsltEndpoint.class);
@@ -206,7 +206,7 @@ public class XsltEndpoint extends ProcessorEndpoint {
     /**
      * Option to specify which output type to use. Possible values are: 
string, bytes, DOM, file. The first three
      * options are all in memory based, where as file is streamed directly to 
a java.io.File. For file you must specify
-     * the filename in the IN header with the key Exchange.XSLT_FILE_NAME 
which is also CamelXsltFileName. Also any
+     * the filename in the IN header with the key XsltConstants.XSLT_FILE_NAME 
which is also CamelXsltFileName. Also any
      * paths leading to the filename must be created beforehand, otherwise an 
exception is thrown at runtime.
      */
     public void setOutput(XsltOutput output) {

Reply via email to