From 1c7ef327fc5061786c902438929a2ed0bdf5a0ca Mon Sep 17 00:00:00 2001
From: cjmamo <823038+cjmamo@users.noreply.github.com>
Date: Wed, 30 Oct 2024 09:16:17 +0100
Subject: [PATCH] CAMEL-21398: migrate the Smooks Data Format from the Camel
cartridge to the Apache Camel code base (#16111)
* feat(CAMEL-21398): migrate the Smooks Data Format from https://github.com/smooks/smooks-camel-cartridge to the Apache Camel code base
Refs: https://github.com/smooks/smooks-camel-cartridge/issues/211
* fix: add uncommitted file
---
.../camel/catalog/components/smooks.json | 2 +-
.../camel/catalog/dataformats.properties | 1 +
.../camel/catalog/dataformats/smooks.json | 22 +++
.../apache/camel/catalog/models.properties | 1 +
.../camel/catalog/models/dataFormats.json | 2 +-
.../apache/camel/catalog/models/marshal.json | 2 +-
.../apache/camel/catalog/models/smooks.json | 19 +++
.../camel/catalog/models/unmarshal.json | 2 +-
.../camel/catalog/schemas/camel-spring.xsd | 29 ++++
components/camel-smooks/pom.xml | 2 -
.../smooks/SmooksDataFormatConfigurer.java | 27 ++++
.../smooks/SmooksDataFormatConfigurer.java | 30 ++++
.../apache/camel/component/smooks/smooks.json | 2 +-
.../camel/dataformat/smooks/smooks.json | 22 +++
.../apache/camel/configurer/smooks-dataformat | 2 +
.../org/apache/camel/dataformat.properties | 7 +
.../org/apache/camel/dataformat/smooks | 2 +
.../src/main/docs/smooks-component.adoc | 4 +-
.../src/main/docs/smooks-dataformat.adoc | 80 +++++++++
.../component/smooks/SmooksEndpoint.java | 2 +-
.../dataformat/smooks/SmooksDataFormat.java | 153 ++++++++++++++++++
.../component/smooks/SmooksProcessorTest.java | 12 +-
.../camel/dataformat/smooks/Customer.java | 68 ++++++++
.../smooks/SmooksDataFormatTest.java | 126 +++++++++++++++
.../dataformat/smooks/gender/Gender.java | 22 +++
.../resources/edi-to-xml-smooks-config.xml | 3 +-
.../src/test/resources/smooks-config.xml | 38 +++++
.../src/test/resources/xml/customer.xml | 25 +++
.../test/resources/xml/expected-customer.xml | 25 +++
.../camel/model/dataformat/dataFormats.json | 2 +-
.../apache/camel/model/dataformat/smooks.json | 19 +++
.../org/apache/camel/model/marshal.json | 2 +-
.../org/apache/camel/model/unmarshal.json | 2 +-
.../org/apache/camel/model.properties | 1 +
.../apache/camel/model/dataformat/jaxb.index | 1 +
.../builder/DataFormatBuilderFactory.java | 8 +
.../camel/builder/DataFormatClause.java | 10 ++
.../apache/camel/model/MarshalDefinition.java | 2 +
.../camel/model/UnmarshalDefinition.java | 2 +
.../dataformat/DataFormatsDefinition.java | 1 +
.../model/dataformat/SmooksDataFormat.java | 92 +++++++++++
.../DataFormatTransformerDefinition.java | 2 +
.../reifier/dataformat/DataFormatReifier.java | 3 +
.../dataformat/SmooksDataFormatReifier.java | 36 +++++
.../apache/camel/main/dataformats.properties | 1 +
.../org/apache/camel/xml/in/ModelParser.java | 7 +
.../org/apache/camel/xml/out/ModelWriter.java | 13 ++
.../apache/camel/yaml/out/ModelWriter.java | 13 ++
.../dataformats/examples/json/smooks.json | 1 +
docs/components/modules/dataformats/nav.adoc | 1 +
.../dataformats/pages/smooks-dataformat.adoc | 1 +
.../endpoint/StaticEndpointBuilders.java | 4 +-
.../dsl/SmooksEndpointBuilderFactory.java | 4 +-
.../deserializers/ModelDeserializers.java | 75 +++++++++
.../ModelDeserializersResolver.java | 2 +
.../resources/schema/camelYamlDsl.json | 55 +++++++
56 files changed, 1066 insertions(+), 26 deletions(-)
create mode 100644 catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/smooks.json
create mode 100644 catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/smooks.json
create mode 100644 components/camel-smooks/src/generated/java/org/apache/camel/component/smooks/SmooksDataFormatConfigurer.java
create mode 100644 components/camel-smooks/src/generated/java/org/apache/camel/dataformat/smooks/SmooksDataFormatConfigurer.java
create mode 100644 components/camel-smooks/src/generated/resources/META-INF/org/apache/camel/dataformat/smooks/smooks.json
create mode 100644 components/camel-smooks/src/generated/resources/META-INF/services/org/apache/camel/configurer/smooks-dataformat
create mode 100644 components/camel-smooks/src/generated/resources/META-INF/services/org/apache/camel/dataformat.properties
create mode 100644 components/camel-smooks/src/generated/resources/META-INF/services/org/apache/camel/dataformat/smooks
create mode 100644 components/camel-smooks/src/main/docs/smooks-dataformat.adoc
create mode 100644 components/camel-smooks/src/main/java/org/apache/camel/dataformat/smooks/SmooksDataFormat.java
create mode 100644 components/camel-smooks/src/test/java/org/apache/camel/dataformat/smooks/Customer.java
create mode 100644 components/camel-smooks/src/test/java/org/apache/camel/dataformat/smooks/SmooksDataFormatTest.java
create mode 100644 components/camel-smooks/src/test/java/org/apache/camel/dataformat/smooks/gender/Gender.java
create mode 100644 components/camel-smooks/src/test/resources/smooks-config.xml
create mode 100644 components/camel-smooks/src/test/resources/xml/customer.xml
create mode 100644 components/camel-smooks/src/test/resources/xml/expected-customer.xml
create mode 100644 core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/dataformat/smooks.json
create mode 100644 core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/SmooksDataFormat.java
create mode 100644 core/camel-core-reifier/src/main/java/org/apache/camel/reifier/dataformat/SmooksDataFormatReifier.java
create mode 120000 docs/components/modules/dataformats/examples/json/smooks.json
create mode 120000 docs/components/modules/dataformats/pages/smooks-dataformat.adoc
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/smooks.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/smooks.json
index b2844871613ad..b105f895b02c0 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/smooks.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/components/smooks.json
@@ -29,7 +29,7 @@
"autowiredEnabled": { "index": 2, "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 then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc." }
},
"properties": {
- "smooksConfig": { "index": 0, "kind": "path", "displayName": "Smooks Config", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Smooks XML configuration file" },
+ "smooksConfig": { "index": 0, "kind": "path", "displayName": "Smooks Config", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the Smooks configuration file" },
"reportPath": { "index": 1, "kind": "parameter", "displayName": "Report Path", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "File path to place the generated HTML execution report. The report is a useful tool in the developers arsenal for diagnosing issues or comprehending a transformation. Do not set in production since this is a major performance drain" },
"sendEmptyMessageWhenIdle": { "index": 2, "kind": "parameter", "displayName": "Send Empty Message When Idle", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead." },
"bridgeErrorHandler": { "index": 3, "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored." },
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats.properties b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats.properties
index 78c60922b0bcd..1afe6443c8998 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats.properties
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats.properties
@@ -32,6 +32,7 @@ pgp
protobuf
protobufJackson
rss
+smooks
snakeYaml
soap
swiftMt
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/smooks.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/smooks.json
new file mode 100644
index 0000000000000..cb0c68a58c0b4
--- /dev/null
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/smooks.json
@@ -0,0 +1,22 @@
+{
+ "dataformat": {
+ "kind": "dataformat",
+ "name": "smooks",
+ "title": "Smooks",
+ "description": "Transform and bind XML as well as non-XML data using Smooks.",
+ "deprecated": false,
+ "firstVersion": "4.9.0",
+ "label": "dataformat,transformation,smooks",
+ "javaType": "org.apache.camel.dataformat.smooks.SmooksDataFormat",
+ "supportLevel": "Preview",
+ "groupId": "org.apache.camel",
+ "artifactId": "camel-smooks",
+ "version": "4.9.0-SNAPSHOT",
+ "modelName": "smooks",
+ "modelJavaType": "org.apache.camel.model.dataformat.SmooksDataFormat"
+ },
+ "properties": {
+ "id": { "index": 0, "kind": "attribute", "displayName": "Id", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node" },
+ "smooksConfig": { "index": 1, "kind": "attribute", "displayName": "Smooks Config", "group": "common", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Path to the Smooks configuration file." }
+ }
+}
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models.properties b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models.properties
index 3b65a58958b9e..e69e1d2f49f17 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models.properties
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models.properties
@@ -184,6 +184,7 @@ setProperty
setVariable
setVariables
simple
+smooks
soap
sort
spel
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/dataFormats.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/dataFormats.json
index 7a5c949c25421..ea2b0bb8013ff 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/dataFormats.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/dataFormats.json
@@ -12,6 +12,6 @@
"output": false
},
"properties": {
- "dataFormats": { "index": 0, "kind": "element", "displayName": "Data Formats", "group": "common", "required": true, "type": "array", "javaType": "java.util.List", "oneOf": [ "asn1", "avro", "barcode", "base64", "beanio", "bindy", "cbor", "crypto", "csv", "custom", "fhirJson", "fhirXml", "flatpack", "grok", "gzipDeflater", "hl7", "ical", "jacksonXml", "jaxb", "json", "jsonApi", "lzf", "mimeMultipart", "parquetAvro", "pgp", "protobuf", "rss", "soap", "swiftMt", "swiftMx", "syslog", "tarFile", "thrift", "tidyMarkup", "univocityCsv", "univocityFixed", "univocityTsv", "xmlSecurity", "yaml", "zipDeflater", "zipFile" ], "deprecated": false, "autowired": false, "secret": false, "description": "A list holding the configured data formats" }
+ "dataFormats": { "index": 0, "kind": "element", "displayName": "Data Formats", "group": "common", "required": true, "type": "array", "javaType": "java.util.List", "oneOf": [ "asn1", "avro", "barcode", "base64", "beanio", "bindy", "cbor", "crypto", "csv", "custom", "fhirJson", "fhirXml", "flatpack", "grok", "gzipDeflater", "hl7", "ical", "jacksonXml", "jaxb", "json", "jsonApi", "lzf", "mimeMultipart", "parquetAvro", "pgp", "protobuf", "rss", "smooks", "soap", "swiftMt", "swiftMx", "syslog", "tarFile", "thrift", "tidyMarkup", "univocityCsv", "univocityFixed", "univocityTsv", "xmlSecurity", "yaml", "zipDeflater", "zipFile" ], "deprecated": false, "autowired": false, "secret": false, "description": "A list holding the configured data formats" }
}
}
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/marshal.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/marshal.json
index 98f8d55c65b77..ecc749299c3ac 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/marshal.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/marshal.json
@@ -15,7 +15,7 @@
"id": { "index": 0, "kind": "attribute", "displayName": "Id", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the id of this node" },
"description": { "index": 1, "kind": "attribute", "displayName": "Description", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the description of this node" },
"disabled": { "index": 2, "kind": "attribute", "displayName": "Disabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to disable this EIP from the route during build time. Once an EIP has been disabled then it cannot be enabled later at runtime." },
- "dataFormatType": { "index": 3, "kind": "element", "displayName": "Data Format Type", "group": "common", "required": true, "type": "object", "javaType": "org.apache.camel.model.DataFormatDefinition", "oneOf": [ "asn1", "avro", "barcode", "base64", "beanio", "bindy", "cbor", "crypto", "csv", "custom", "fhirJson", "fhirXml", "flatpack", "grok", "gzipDeflater", "hl7", "ical", "jacksonXml", "jaxb", "json", "jsonApi", "lzf", "mimeMultipart", "parquetAvro", "pgp", "protobuf", "rss", "soap", "swiftMt", "swiftMx", "syslog", "tarFile", "thrift", "tidyMarkup", "univocityCsv", "univocityFixed", "univocityTsv", "xmlSecurity", "yaml", "zipDeflater", "zipFile" ], "deprecated": false, "autowired": false, "secret": false, "description": "The data format to be used" },
+ "dataFormatType": { "index": 3, "kind": "element", "displayName": "Data Format Type", "group": "common", "required": true, "type": "object", "javaType": "org.apache.camel.model.DataFormatDefinition", "oneOf": [ "asn1", "avro", "barcode", "base64", "beanio", "bindy", "cbor", "crypto", "csv", "custom", "fhirJson", "fhirXml", "flatpack", "grok", "gzipDeflater", "hl7", "ical", "jacksonXml", "jaxb", "json", "jsonApi", "lzf", "mimeMultipart", "parquetAvro", "pgp", "protobuf", "rss", "smooks", "soap", "swiftMt", "swiftMx", "syslog", "tarFile", "thrift", "tidyMarkup", "univocityCsv", "univocityFixed", "univocityTsv", "xmlSecurity", "yaml", "zipDeflater", "zipFile" ], "deprecated": false, "autowired": false, "secret": false, "description": "The data format to be used" },
"variableSend": { "index": 4, "kind": "attribute", "displayName": "Variable Send", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use a variable as the source for the message body to send. This makes it handy to use variables for user data and to easily control what data to use for sending and receiving. Important: When using send variable then the message body is taken from this variable instead of the current message, however the headers from the message will still be used as well. In other words, the variable is used instead of the message body, but everything else is as usual." },
"variableReceive": { "index": 5, "kind": "attribute", "displayName": "Variable Receive", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use a variable to store the received message body (only body, not headers). This makes it handy to use variables for user data and to easily control what data to use for sending and receiving. Important: When using receive variable then the received body is stored only in this variable and not on the current message." }
}
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/smooks.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/smooks.json
new file mode 100644
index 0000000000000..841de6ce94d94
--- /dev/null
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/smooks.json
@@ -0,0 +1,19 @@
+{
+ "model": {
+ "kind": "model",
+ "name": "smooks",
+ "title": "Smooks",
+ "description": "Transform and bind XML as well as non-XML data using Smooks.",
+ "deprecated": false,
+ "firstVersion": "4.9.0",
+ "label": "dataformat,transformation,smooks",
+ "javaType": "org.apache.camel.model.dataformat.SmooksDataFormat",
+ "abstract": false,
+ "input": false,
+ "output": false
+ },
+ "properties": {
+ "id": { "index": 0, "kind": "attribute", "displayName": "Id", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node" },
+ "smooksConfig": { "index": 1, "kind": "attribute", "displayName": "Smooks Config", "group": "common", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Path to the Smooks configuration file." }
+ }
+}
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/unmarshal.json b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/unmarshal.json
index 5a832d4470d2c..fa3b561f0eaf6 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/unmarshal.json
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/unmarshal.json
@@ -15,7 +15,7 @@
"id": { "index": 0, "kind": "attribute", "displayName": "Id", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the id of this node" },
"description": { "index": 1, "kind": "attribute", "displayName": "Description", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Sets the description of this node" },
"disabled": { "index": 2, "kind": "attribute", "displayName": "Disabled", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Whether to disable this EIP from the route during build time. Once an EIP has been disabled then it cannot be enabled later at runtime." },
- "dataFormatType": { "index": 3, "kind": "element", "displayName": "Data Format Type", "group": "common", "required": true, "type": "object", "javaType": "org.apache.camel.model.DataFormatDefinition", "oneOf": [ "asn1", "avro", "barcode", "base64", "beanio", "bindy", "cbor", "crypto", "csv", "custom", "fhirJson", "fhirXml", "flatpack", "grok", "gzipDeflater", "hl7", "ical", "jacksonXml", "jaxb", "json", "jsonApi", "lzf", "mimeMultipart", "parquetAvro", "pgp", "protobuf", "rss", "soap", "swiftMt", "swiftMx", "syslog", "tarFile", "thrift", "tidyMarkup", "univocityCsv", "univocityFixed", "univocityTsv", "xmlSecurity", "yaml", "zipDeflater", "zipFile" ], "deprecated": false, "autowired": false, "secret": false, "description": "The data format to be used" },
+ "dataFormatType": { "index": 3, "kind": "element", "displayName": "Data Format Type", "group": "common", "required": true, "type": "object", "javaType": "org.apache.camel.model.DataFormatDefinition", "oneOf": [ "asn1", "avro", "barcode", "base64", "beanio", "bindy", "cbor", "crypto", "csv", "custom", "fhirJson", "fhirXml", "flatpack", "grok", "gzipDeflater", "hl7", "ical", "jacksonXml", "jaxb", "json", "jsonApi", "lzf", "mimeMultipart", "parquetAvro", "pgp", "protobuf", "rss", "smooks", "soap", "swiftMt", "swiftMx", "syslog", "tarFile", "thrift", "tidyMarkup", "univocityCsv", "univocityFixed", "univocityTsv", "xmlSecurity", "yaml", "zipDeflater", "zipFile" ], "deprecated": false, "autowired": false, "secret": false, "description": "The data format to be used" },
"variableSend": { "index": 4, "kind": "attribute", "displayName": "Variable Send", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use a variable as the source for the message body to send. This makes it handy to use variables for user data and to easily control what data to use for sending and receiving. Important: When using send variable then the message body is taken from this variable instead of the current message, however the headers from the message will still be used as well. In other words, the variable is used instead of the message body, but everything else is as usual." },
"variableReceive": { "index": 5, "kind": "attribute", "displayName": "Variable Receive", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "To use a variable to store the received message body (only body, not headers). This makes it handy to use variables for user data and to easily control what data to use for sending and receiving. Important: When using receive variable then the received body is stored only in this variable and not on the current message." },
"allowNullBody": { "index": 6, "kind": "attribute", "displayName": "Allow Null Body", "group": "advanced", "label": "advanced", "required": false, "type": "boolean", "javaType": "java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Indicates whether null is allowed as value of a body to unmarshall." }
diff --git a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
index 3a4a3e9447898..f3a8b148b658d 100644
--- a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
+++ b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-spring.xsd
@@ -1858,6 +1858,15 @@ Allows setting multiple variables at the same time.
+
+
+
+
+
+
+
@@ -7419,6 +7428,7 @@ down. Default value: false
+
@@ -9726,6 +9736,22 @@ value: true
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -14590,6 +14616,7 @@ To type used as a target data type in the transformation.
+
@@ -16794,6 +16821,7 @@ Set a reference to a custom Expression to use.
+
@@ -17597,6 +17625,7 @@ Sets the component name that this definition will apply to.
+
diff --git a/components/camel-smooks/pom.xml b/components/camel-smooks/pom.xml
index fc01790ec29eb..d4d5d7709ca8b 100644
--- a/components/camel-smooks/pom.xml
+++ b/components/camel-smooks/pom.xml
@@ -47,7 +47,6 @@
-
org.apache.camelcamel-support
@@ -56,7 +55,6 @@
org.smookssmooks-core
-
org.smooks.cartridges.edismooks-edi-cartridge
diff --git a/components/camel-smooks/src/generated/java/org/apache/camel/component/smooks/SmooksDataFormatConfigurer.java b/components/camel-smooks/src/generated/java/org/apache/camel/component/smooks/SmooksDataFormatConfigurer.java
new file mode 100644
index 0000000000000..439af9d6e16d9
--- /dev/null
+++ b/components/camel-smooks/src/generated/java/org/apache/camel/component/smooks/SmooksDataFormatConfigurer.java
@@ -0,0 +1,27 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.component.smooks;
+
+import javax.annotation.processing.Generated;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.dataformat.smooks.SmooksDataFormat;
+import org.apache.camel.spi.GeneratedPropertyConfigurer;
+import org.apache.camel.support.component.PropertyConfigurerSupport;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@Generated("org.apache.camel.maven.packaging.PackageDataFormatMojo")
+@SuppressWarnings("unchecked")
+public class SmooksDataFormatConfigurer extends PropertyConfigurerSupport implements GeneratedPropertyConfigurer {
+
+ @Override
+ public boolean configure(CamelContext camelContext, Object target, String name, Object value, boolean ignoreCase) {
+ SmooksDataFormat dataformat = (SmooksDataFormat) target;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ default: return false;
+ }
+ }
+
+}
+
diff --git a/components/camel-smooks/src/generated/java/org/apache/camel/dataformat/smooks/SmooksDataFormatConfigurer.java b/components/camel-smooks/src/generated/java/org/apache/camel/dataformat/smooks/SmooksDataFormatConfigurer.java
new file mode 100644
index 0000000000000..4381bae9cefe2
--- /dev/null
+++ b/components/camel-smooks/src/generated/java/org/apache/camel/dataformat/smooks/SmooksDataFormatConfigurer.java
@@ -0,0 +1,30 @@
+/* Generated by camel build tools - do NOT edit this file! */
+package org.apache.camel.dataformat.smooks;
+
+import javax.annotation.processing.Generated;
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.spi.GeneratedPropertyConfigurer;
+import org.apache.camel.support.component.PropertyConfigurerSupport;
+
+/**
+ * Generated by camel build tools - do NOT edit this file!
+ */
+@Generated("org.apache.camel.maven.packaging.PackageDataFormatMojo")
+@SuppressWarnings("unchecked")
+public class SmooksDataFormatConfigurer extends PropertyConfigurerSupport implements GeneratedPropertyConfigurer {
+
+ @Override
+ public boolean configure(CamelContext camelContext, Object target, String name, Object value, boolean ignoreCase) {
+ SmooksDataFormat dataformat = (SmooksDataFormat) target;
+ switch (ignoreCase ? name.toLowerCase() : name) {
+ case "smooksconfig":
+ case "smooksConfig": dataformat.setSmooksConfig(property(camelContext, java.lang.String.class, value)); return true;
+ default: return false;
+ }
+ }
+
+}
+
diff --git a/components/camel-smooks/src/generated/resources/META-INF/org/apache/camel/component/smooks/smooks.json b/components/camel-smooks/src/generated/resources/META-INF/org/apache/camel/component/smooks/smooks.json
index b2844871613ad..b105f895b02c0 100644
--- a/components/camel-smooks/src/generated/resources/META-INF/org/apache/camel/component/smooks/smooks.json
+++ b/components/camel-smooks/src/generated/resources/META-INF/org/apache/camel/component/smooks/smooks.json
@@ -29,7 +29,7 @@
"autowiredEnabled": { "index": 2, "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 then gets configured on the component. This can be used for automatic configuring JDBC data sources, JMS connection factories, AWS Clients, etc." }
},
"properties": {
- "smooksConfig": { "index": 0, "kind": "path", "displayName": "Smooks Config", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Smooks XML configuration file" },
+ "smooksConfig": { "index": 0, "kind": "path", "displayName": "Smooks Config", "group": "common", "label": "", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "deprecationNote": "", "autowired": false, "secret": false, "supportFileReference": true, "description": "Path to the Smooks configuration file" },
"reportPath": { "index": 1, "kind": "parameter", "displayName": "Report Path", "group": "common", "label": "", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "File path to place the generated HTML execution report. The report is a useful tool in the developers arsenal for diagnosing issues or comprehending a transformation. Do not set in production since this is a major performance drain" },
"sendEmptyMessageWhenIdle": { "index": 2, "kind": "parameter", "displayName": "Send Empty Message When Idle", "group": "consumer", "label": "consumer", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "If the polling consumer did not poll any files, you can enable this option to send an empty message (no body) instead." },
"bridgeErrorHandler": { "index": 3, "kind": "parameter", "displayName": "Bridge Error Handler", "group": "consumer (advanced)", "label": "consumer,advanced", "required": false, "type": "boolean", "javaType": "boolean", "deprecated": false, "autowired": false, "secret": false, "defaultValue": false, "description": "Allows for bridging the consumer to the Camel routing Error Handler, which mean any exceptions (if possible) occurred while the Camel consumer is trying to pickup incoming messages, or the likes, will now be processed as a message and handled by the routing Error Handler. Important: This is only possible if the 3rd party component allows Camel to be alerted if an exception was thrown. Some components handle this internally only, and therefore bridgeErrorHandler is not possible. In other situations we may improve the Camel component to hook into the 3rd party component and make this possible for future releases. By default the consumer will use the org.apache.camel.spi.ExceptionHandler to deal with exceptions, that will be logged at WARN or ERROR level and ignored." },
diff --git a/components/camel-smooks/src/generated/resources/META-INF/org/apache/camel/dataformat/smooks/smooks.json b/components/camel-smooks/src/generated/resources/META-INF/org/apache/camel/dataformat/smooks/smooks.json
new file mode 100644
index 0000000000000..cb0c68a58c0b4
--- /dev/null
+++ b/components/camel-smooks/src/generated/resources/META-INF/org/apache/camel/dataformat/smooks/smooks.json
@@ -0,0 +1,22 @@
+{
+ "dataformat": {
+ "kind": "dataformat",
+ "name": "smooks",
+ "title": "Smooks",
+ "description": "Transform and bind XML as well as non-XML data using Smooks.",
+ "deprecated": false,
+ "firstVersion": "4.9.0",
+ "label": "dataformat,transformation,smooks",
+ "javaType": "org.apache.camel.dataformat.smooks.SmooksDataFormat",
+ "supportLevel": "Preview",
+ "groupId": "org.apache.camel",
+ "artifactId": "camel-smooks",
+ "version": "4.9.0-SNAPSHOT",
+ "modelName": "smooks",
+ "modelJavaType": "org.apache.camel.model.dataformat.SmooksDataFormat"
+ },
+ "properties": {
+ "id": { "index": 0, "kind": "attribute", "displayName": "Id", "group": "common", "required": false, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "The id of this node" },
+ "smooksConfig": { "index": 1, "kind": "attribute", "displayName": "Smooks Config", "group": "common", "required": true, "type": "string", "javaType": "java.lang.String", "deprecated": false, "autowired": false, "secret": false, "description": "Path to the Smooks configuration file." }
+ }
+}
diff --git a/components/camel-smooks/src/generated/resources/META-INF/services/org/apache/camel/configurer/smooks-dataformat b/components/camel-smooks/src/generated/resources/META-INF/services/org/apache/camel/configurer/smooks-dataformat
new file mode 100644
index 0000000000000..cc79fd7de3a36
--- /dev/null
+++ b/components/camel-smooks/src/generated/resources/META-INF/services/org/apache/camel/configurer/smooks-dataformat
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.dataformat.smooks.SmooksDataFormatConfigurer
diff --git a/components/camel-smooks/src/generated/resources/META-INF/services/org/apache/camel/dataformat.properties b/components/camel-smooks/src/generated/resources/META-INF/services/org/apache/camel/dataformat.properties
new file mode 100644
index 0000000000000..fb35cf2007ac7
--- /dev/null
+++ b/components/camel-smooks/src/generated/resources/META-INF/services/org/apache/camel/dataformat.properties
@@ -0,0 +1,7 @@
+# Generated by camel build tools - do NOT edit this file!
+dataFormats=smooks
+groupId=org.apache.camel
+artifactId=camel-smooks
+version=4.9.0-SNAPSHOT
+projectName=Camel :: Smooks :: Parent
+projectDescription=Camel Smooks Component
diff --git a/components/camel-smooks/src/generated/resources/META-INF/services/org/apache/camel/dataformat/smooks b/components/camel-smooks/src/generated/resources/META-INF/services/org/apache/camel/dataformat/smooks
new file mode 100644
index 0000000000000..ac50e4b08b0cc
--- /dev/null
+++ b/components/camel-smooks/src/generated/resources/META-INF/services/org/apache/camel/dataformat/smooks
@@ -0,0 +1,2 @@
+# Generated by camel build tools - do NOT edit this file!
+class=org.apache.camel.dataformat.smooks.SmooksDataFormat
diff --git a/components/camel-smooks/src/main/docs/smooks-component.adoc b/components/camel-smooks/src/main/docs/smooks-component.adoc
index 1b1ff285daa4f..d16e886b26785 100644
--- a/components/camel-smooks/src/main/docs/smooks-component.adoc
+++ b/components/camel-smooks/src/main/docs/smooks-component.adoc
@@ -21,6 +21,8 @@ Common applications of Smooks include:
* enrichment: enrich fragments with data from a database or other data sources.
* Java binding: populate POJOs from a source such as CSV, EDI, XML, and other POJOs.
+Use the xref:dataformats:smooks-dataformat.adoc[Smooks Data Format] instead of this component when you are primarily interested in transformation and binding; not other Smooks features like routing.
+
Maven users will need to add the following dependency to their `pom.xml`.
[source,xml]
@@ -98,4 +100,4 @@ The Smooks component is configured with a mandatory configuration file, which is
----
-The example `` configures Smooks to export the execution result to Camel as a string. Keep in mind that exporting the result as string means that the whole result will be kept in-memory which could cause unexpected performance issues for large payloads.
+The example `` configures Smooks to export the execution result to Camel as a string. Keep in mind that exporting the result as string means that the whole result will be kept in-memory which could cause unexpected performance issues for large payloads.
\ No newline at end of file
diff --git a/components/camel-smooks/src/main/docs/smooks-dataformat.adoc b/components/camel-smooks/src/main/docs/smooks-dataformat.adoc
new file mode 100644
index 0000000000000..3f856b4869af9
--- /dev/null
+++ b/components/camel-smooks/src/main/docs/smooks-dataformat.adoc
@@ -0,0 +1,80 @@
+= Smooks DataFormat
+:doctitle: Smooks
+:shortname: smooks
+:artifactid: camel-smooks
+:description: Transform and bind XML as well as non-XML data using Smooks.
+:since: 4.9
+:supportlevel: Preview
+:tabs-sync-option:
+
+*Since Camel {since}*
+
+The Smooks Data Format uses https://www.smooks.org/[Smooks] to transform from one data format to another and back again. A configuration for a Smooks Data Format should not allocate system resources because the data format does not close those resources. Use this data format when you are primarily interested in transformation and binding; not other Smooks features like routing. The latter should be accomplished with the xref:components::smooks-component.adoc[Smooks component].
+
+Maven users will need to add the following dependency to their `pom.xml` for this data format:
+
+[source,xml]
+----
+
+ org.apache.camel
+ camel-smooks
+ x.x.x
+
+
+----
+
+== Usage
+
+Below is an example of using the Smooks Data Format to unmarshal a CSV into a `java.util.List` of `org.smooks.example.Customer` instances:
+
+[tabs]
+====
+Java::
++
+[source,java]
+----
+from("direct:unmarshal")
+ .unmarshal().smooks("csv-smooks-unmarshal-config.xml")
+ .log("Unmarshalled customers: ${body}");
+----
+
+YAML::
++
+[source,yaml]
+----
+- from:
+ uri: direct:unmarshal
+ steps:
+ - unmarshal:
+ smooks:
+ smooksConfig: csv-smooks-unmarshal-config.xml
+ - log: "Unmarshalled customers: ${body}"
+----
+====
+
+The Smooks configuration in `csv-smooks-unmarshal-config.xml` is as follows:
+
+[source,xml]
+----
+
+
+
+
+
+
+
+
+
+
+
+----
+
+== Smooks Data Format Options
+
+// dataformat options: START
+include::partial$dataformat-options.adoc[]
+// dataformat options: END
+
+include::spring-boot:partial$starter.adoc[]
diff --git a/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksEndpoint.java b/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksEndpoint.java
index f07aa830a47e6..0a854ca1702a3 100644
--- a/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksEndpoint.java
+++ b/components/camel-smooks/src/main/java/org/apache/camel/component/smooks/SmooksEndpoint.java
@@ -32,7 +32,7 @@
category = { Category.TRANSFORMATION })
public class SmooksEndpoint extends ProcessorEndpoint {
- @UriPath(description = "Smooks XML configuration file")
+ @UriPath(description = "Path to the Smooks configuration file")
@Metadata(required = true, supportFileReference = true)
private String smooksConfig;
diff --git a/components/camel-smooks/src/main/java/org/apache/camel/dataformat/smooks/SmooksDataFormat.java b/components/camel-smooks/src/main/java/org/apache/camel/dataformat/smooks/SmooksDataFormat.java
new file mode 100644
index 0000000000000..e3ff53e1235c6
--- /dev/null
+++ b/components/camel-smooks/src/main/java/org/apache/camel/dataformat/smooks/SmooksDataFormat.java
@@ -0,0 +1,153 @@
+/*
+ * 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.dataformat.smooks;
+
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.List;
+
+import org.xml.sax.SAXException;
+
+import org.apache.camel.CamelContext;
+import org.apache.camel.CamelContextAware;
+import org.apache.camel.Exchange;
+import org.apache.camel.TypeConverter;
+import org.apache.camel.component.smooks.SmooksComponent;
+import org.apache.camel.component.smooks.SmooksProcessor;
+import org.apache.camel.spi.DataFormat;
+import org.apache.camel.spi.annotations.Dataformat;
+import org.apache.camel.support.processor.MarshalProcessor;
+import org.apache.camel.support.processor.UnmarshalProcessor;
+import org.apache.camel.support.service.ServiceSupport;
+import org.smooks.Smooks;
+import org.smooks.SmooksFactory;
+import org.smooks.api.ExecutionContext;
+import org.smooks.api.SmooksException;
+import org.smooks.api.io.Sink;
+import org.smooks.engine.lookup.ExportsLookup;
+import org.smooks.io.payload.Exports;
+import org.smooks.io.sink.StringSink;
+import org.smooks.io.source.JavaSource;
+import org.smooks.io.source.StreamSource;
+
+/**
+ * SmooksDataFormat is a Camel data format which is a pluggable transformer capable of transforming from one dataformat
+ * to another and back again. This means that what is marshaled can be unmarshalled by an instance of this class.
+ *
+ *
+ * A smooks configuration for a SmooksDataFormat should not utilize Smooks features such as routing that might allocate
+ * system resources. The reason for this is that there is no functionality in the SmooksDataFormat which will close
+ * those resources. If you need to use these Smooks features please take a look at the {@link SmooksComponent} or
+ * {@link SmooksProcessor} as they hook into Camels lifecycle management and will close resources correctly.
+ *
+ */
+@Dataformat("smooks")
+public class SmooksDataFormat extends ServiceSupport implements DataFormat, CamelContextAware {
+ private Smooks smooks;
+ private CamelContext camelContext;
+ private String smooksConfig;
+
+ /**
+ * Marshals the Object 'fromBody' to an OutputStream 'toStream'
+ *
+ *
+ * The Camel framework will call this method from {@link MarshalProcessor#process(Exchange)} and it will take care
+ * of setting the Out Message's body to the bytes written to the toStream OutputStream.
+ *
+ * @param exchange The Camel {@link Exchange}.
+ * @param fromBody The object to be marshalled into the output stream.
+ * @param toStream The output stream that will be written to.
+ */
+ @Override
+ public void marshal(final Exchange exchange, final Object fromBody, final OutputStream toStream) throws Exception {
+ final ExecutionContext executionContext = smooks.createExecutionContext();
+ final TypeConverter typeConverter = exchange.getContext().getTypeConverter();
+ final JavaSource javaSource = typeConverter.mandatoryConvertTo(JavaSource.class, exchange, fromBody);
+ final StringSink stringSink = new StringSink();
+ smooks.filterSource(executionContext, javaSource, stringSink);
+
+ toStream.write(stringSink.getResult().getBytes(executionContext.getContentEncoding()));
+ }
+
+ /**
+ * Unmarshals the fromStream to an Object.
+ *
+ * The Camel framework will call this method from {@link UnmarshalProcessor#process(Exchange)} and it will take care
+ * of setting the returned Object on the Out Message's body.
+ *
+ * @param exchange The Camel {@link Exchange}.
+ * @param fromStream The InputStream that will be unmarshalled into an Object instance.
+ */
+ @Override
+ public Object unmarshal(final Exchange exchange, final InputStream fromStream) {
+ final ExecutionContext executionContext = smooks.createExecutionContext();
+ final Exports exports = smooks.getApplicationContext().getRegistry().lookup(new ExportsLookup());
+ final Sink[] sinks = exports.createSinks();
+ smooks.filterSource(executionContext, new StreamSource<>(fromStream), sinks);
+ return getResult(exports, sinks, exchange);
+ }
+
+ protected Object getResult(final Exports exports, final Sink[] sinks, final Exchange exchange) {
+ final List