This is an automated email from the ASF dual-hosted git repository.
davsclaus pushed a commit to branch main
in repository https://gitbox.apache.org/repos/asf/camel.git
The following commit(s) were added to refs/heads/main by this push:
new 39e5106ee34b CAMEL-25205: camel-jackson3xml - Add support to
enable/disable features from Jackson feature enums (Adoption of CAMEL-24620 and
CAMEL-25054) (#27156)
39e5106ee34b is described below
commit 39e5106ee34b17553a1d81601baf861e94549554
Author: Benjamin Graf <[email protected]>
AuthorDate: Fri Oct 2 09:25:53 2026 +0200
CAMEL-25205: camel-jackson3xml - Add support to enable/disable features
from Jackson feature enums (Adoption of CAMEL-24620 and CAMEL-25054) (#27156)
* CAMEL-25205: camel-jackson3xml - Add support to enable/disable features
from Jackson feature enums (Adoption of CAMEL-24620 and CAMEL-25054)
* Regen
* Regen
---------
Co-authored-by: Guillaume Nodet <[email protected]>
---
.../camel/catalog/dataformats/jacksonXml.json | 4 +-
.../apache/camel/catalog/models/jacksonXml.json | 4 +-
.../apache/camel/catalog/schemas/camel-spring.xsd | 12 +-
.../apache/camel/catalog/schemas/camel-xml-io.xsd | 12 +-
.../camel/catalog/schemas/camelYamlDsl-model.json | 4 +-
.../jackson3xml/JacksonXMLDataFormat.java | 450 ++++++++++++++++-----
.../jackson3xml/ListJacksonXMLDataFormat.java | 2 +-
.../component/jackson3xml/JacksonFeaturesTest.java | 117 ++++++
.../camel/component/jacksonxml/jacksonXml.json | 4 +-
.../apache/camel/model/dataformat/jacksonXml.json | 4 +-
.../model/dataformat/JacksonXMLDataFormat.java | 10 +-
.../dsl/yaml/deserializers/ModelDeserializers.java | 4 +-
.../resources/schema/camelYamlDsl-canonical.json | 4 +-
.../resources/schema/camelYamlDsl-model.json | 4 +-
.../generated/resources/schema/camelYamlDsl.json | 4 +-
15 files changed, 502 insertions(+), 137 deletions(-)
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/jacksonXml.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/jacksonXml.json
index 637e43a44a34..0ef6602a7d38 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/jacksonXml.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/dataformats/jacksonXml.json
@@ -30,8 +30,8 @@
"enableJaxbAnnotationModule": { "index": 11, "kind": "attribute",
"displayName": "Enable Jaxb Annotation Module", "group": "advanced", "label":
"advanced", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Whether to enable the JAXB annotations
module when using Jackson. When enabled then JAXB annotations can be used by
Jackson." },
"moduleClassNames": { "index": 12, "kind": "attribute", "displayName":
"Module Class Names", "group": "advanced", "label": "advanced", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "To use custom Jackson
modules com.fasterxml.jackson.databind.Module specified as a String with FQN
class names. Multiple classes can be separated by comma." },
"moduleRefs": { "index": 13, "kind": "attribute", "displayName": "Module
Refs", "group": "advanced", "label": "advanced", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "description": "To use custom Jackson modules referred
from the Camel registry. Multiple modules can be separated by comma." },
- "enableFeatures": { "index": 14, "kind": "attribute", "displayName":
"Enable Features", "group": "common", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Set of features to enable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature, or
MapperFeature. Multiple features can be separate [...]
- "disableFeatures": { "index": 15, "kind": "attribute", "displayName":
"Disable Features", "group": "common", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Set of features to disable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature, or
MapperFeature. Multiple features can be separ [...]
+ "enableFeatures": { "index": 14, "kind": "attribute", "displayName":
"Enable Features", "group": "common", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Set of features to enable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature,
MapperFeature, DateTimeFeature, EnumFeature, JsonNo [...]
+ "disableFeatures": { "index": 15, "kind": "attribute", "displayName":
"Disable Features", "group": "common", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Set of features to disable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature,
MapperFeature, DateTimeFeature, EnumFeature, Jso [...]
"contentTypeHeader": { "index": 16, "kind": "attribute", "displayName":
"Content Type Header", "group": "common", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether the data format
should set the Content-Type header with the type from the data format. For
example application\/xml for data formats marshalling to XML, or
application\/json for data formats marshall [...]
"maxStringLength": { "index": 17, "kind": "attribute", "displayName": "Max
String Length", "group": "advanced", "label": "advanced", "required": false,
"type": "integer", "javaType": "java.lang.Integer", "deprecated": false,
"autowired": false, "secret": false, "description": "Maximum allowed string
length when deserializing (in chars or bytes, depending on input context). The
default is 20,000,000." }
}
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/jacksonXml.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/jacksonXml.json
index 9d1ee0e2e9ca..ae60295e87f8 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/jacksonXml.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/models/jacksonXml.json
@@ -27,8 +27,8 @@
"enableJaxbAnnotationModule": { "index": 11, "kind": "attribute",
"displayName": "Enable Jaxb Annotation Module", "group": "advanced", "label":
"advanced", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Whether to enable the JAXB annotations
module when using Jackson. When enabled then JAXB annotations can be used by
Jackson." },
"moduleClassNames": { "index": 12, "kind": "attribute", "displayName":
"Module Class Names", "group": "advanced", "label": "advanced", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "To use custom Jackson
modules com.fasterxml.jackson.databind.Module specified as a String with FQN
class names. Multiple classes can be separated by comma." },
"moduleRefs": { "index": 13, "kind": "attribute", "displayName": "Module
Refs", "group": "advanced", "label": "advanced", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "description": "To use custom Jackson modules referred
from the Camel registry. Multiple modules can be separated by comma." },
- "enableFeatures": { "index": 14, "kind": "attribute", "displayName":
"Enable Features", "group": "common", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Set of features to enable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature, or
MapperFeature. Multiple features can be separate [...]
- "disableFeatures": { "index": 15, "kind": "attribute", "displayName":
"Disable Features", "group": "common", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Set of features to disable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature, or
MapperFeature. Multiple features can be separ [...]
+ "enableFeatures": { "index": 14, "kind": "attribute", "displayName":
"Enable Features", "group": "common", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Set of features to enable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature,
MapperFeature, DateTimeFeature, EnumFeature, JsonNo [...]
+ "disableFeatures": { "index": 15, "kind": "attribute", "displayName":
"Disable Features", "group": "common", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Set of features to disable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature,
MapperFeature, DateTimeFeature, EnumFeature, Jso [...]
"contentTypeHeader": { "index": 16, "kind": "attribute", "displayName":
"Content Type Header", "group": "common", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether the data format
should set the Content-Type header with the type from the data format. For
example application\/xml for data formats marshalling to XML, or
application\/json for data formats marshall [...]
"maxStringLength": { "index": 17, "kind": "attribute", "displayName": "Max
String Length", "group": "advanced", "label": "advanced", "required": false,
"type": "integer", "javaType": "java.lang.Integer", "deprecated": false,
"autowired": false, "secret": false, "description": "Maximum allowed string
length when deserializing (in chars or bytes, depending on input context). The
default is 20,000,000." }
}
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 d253e483968d..aefe2726594f 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
@@ -8947,8 +8947,10 @@ To use custom Jackson modules referred from the Camel
registry. Multiple modules
<xs:documentation xml:lang="en">
<![CDATA[
Set of features to enable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
-matches a enum from SerializationFeature, DeserializationFeature, or
MapperFeature. Multiple features can be separated
-by comma.
+matches a enum from SerializationFeature, DeserializationFeature,
MapperFeature, DateTimeFeature, EnumFeature,
+JsonNodeFeature, StreamReadFeature, StreamWriteFeature, XmlReadFeature or
XmlWriteFeature. Multiple features can be
+separated by comma. When using Jackson 3, a feature can be qualified with its
enum class name (e.g.
+SerializationFeature.WRAP_ROOT_VALUE) to tell apart features with the same
name.
]]>
</xs:documentation>
</xs:annotation>
@@ -8958,8 +8960,10 @@ by comma.
<xs:documentation xml:lang="en">
<![CDATA[
Set of features to disable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name
-that matches a enum from SerializationFeature, DeserializationFeature, or
MapperFeature. Multiple features can be
-separated by comma.
+that matches a enum from SerializationFeature, DeserializationFeature,
MapperFeature, DateTimeFeature, EnumFeature,
+JsonNodeFeature, StreamReadFeature, StreamWriteFeature, XmlReadFeature or
XmlWriteFeature. Multiple features can be
+separated by comma. When using Jackson 3, a feature can be qualified with its
enum class name (e.g.
+SerializationFeature.WRAP_ROOT_VALUE) to tell apart features with the same
name.
]]>
</xs:documentation>
</xs:annotation>
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-xml-io.xsd
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-xml-io.xsd
index f67bb6ff9ca6..5b8834d0ab29 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-xml-io.xsd
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camel-xml-io.xsd
@@ -8069,8 +8069,10 @@ To use custom Jackson modules referred from the Camel
registry. Multiple modules
<xs:documentation xml:lang="en">
<![CDATA[
Set of features to enable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
-matches a enum from SerializationFeature, DeserializationFeature, or
MapperFeature. Multiple features can be separated
-by comma.
+matches a enum from SerializationFeature, DeserializationFeature,
MapperFeature, DateTimeFeature, EnumFeature,
+JsonNodeFeature, StreamReadFeature, StreamWriteFeature, XmlReadFeature or
XmlWriteFeature. Multiple features can be
+separated by comma. When using Jackson 3, a feature can be qualified with its
enum class name (e.g.
+SerializationFeature.WRAP_ROOT_VALUE) to tell apart features with the same
name.
]]>
</xs:documentation>
</xs:annotation>
@@ -8080,8 +8082,10 @@ by comma.
<xs:documentation xml:lang="en">
<![CDATA[
Set of features to disable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name
-that matches a enum from SerializationFeature, DeserializationFeature, or
MapperFeature. Multiple features can be
-separated by comma.
+that matches a enum from SerializationFeature, DeserializationFeature,
MapperFeature, DateTimeFeature, EnumFeature,
+JsonNodeFeature, StreamReadFeature, StreamWriteFeature, XmlReadFeature or
XmlWriteFeature. Multiple features can be
+separated by comma. When using Jackson 3, a feature can be qualified with its
enum class name (e.g.
+SerializationFeature.WRAP_ROOT_VALUE) to tell apart features with the same
name.
]]>
</xs:documentation>
</xs:annotation>
diff --git
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camelYamlDsl-model.json
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camelYamlDsl-model.json
index 5f661bb07177..6c97b9d7b50c 100644
---
a/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camelYamlDsl-model.json
+++
b/catalog/camel-catalog/src/generated/resources/org/apache/camel/catalog/schemas/camelYamlDsl-model.json
@@ -12204,12 +12204,12 @@
}, {
"name" : "disableFeatures",
"type" : "string",
- "description" : "Set of features to disable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature, or
MapperFeature. Multiple features can be separated by comma.",
+ "description" : "Set of features to disable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature,
MapperFeature, DateTimeFeature, EnumFeature, JsonNodeFeature,
StreamReadFeature, StreamWriteFeature, XmlReadFeature or XmlWriteFeature.
Multiple features can be separated by comma. When using Jackson 3, a feature
can be qualified with its enum class name (e.g. SerializationFeatu [...]
"title" : "Disable Features"
}, {
"name" : "enableFeatures",
"type" : "string",
- "description" : "Set of features to enable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature, or
MapperFeature. Multiple features can be separated by comma.",
+ "description" : "Set of features to enable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature,
MapperFeature, DateTimeFeature, EnumFeature, JsonNodeFeature,
StreamReadFeature, StreamWriteFeature, XmlReadFeature or XmlWriteFeature.
Multiple features can be separated by comma. When using Jackson 3, a feature
can be qualified with its enum class name (e.g. SerializationFeatur [...]
"title" : "Enable Features"
}, {
"name" : "enableJaxbAnnotationModule",
diff --git
a/components/camel-jackson3xml/src/main/java/org/apache/camel/component/jackson3xml/JacksonXMLDataFormat.java
b/components/camel-jackson3xml/src/main/java/org/apache/camel/component/jackson3xml/JacksonXMLDataFormat.java
index 9add16f8c058..5f358d160868 100644
---
a/components/camel-jackson3xml/src/main/java/org/apache/camel/component/jackson3xml/JacksonXMLDataFormat.java
+++
b/components/camel-jackson3xml/src/main/java/org/apache/camel/component/jackson3xml/JacksonXMLDataFormat.java
@@ -44,16 +44,23 @@ import org.apache.camel.util.CastUtils;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import tools.jackson.core.StreamReadConstraints;
+import tools.jackson.core.StreamReadFeature;
+import tools.jackson.core.StreamWriteFeature;
import tools.jackson.databind.DeserializationFeature;
import tools.jackson.databind.JacksonModule;
import tools.jackson.databind.JsonNode;
import tools.jackson.databind.MapperFeature;
import tools.jackson.databind.ObjectReader;
import tools.jackson.databind.SerializationFeature;
+import tools.jackson.databind.cfg.DatatypeFeature;
+import tools.jackson.databind.cfg.DateTimeFeature;
+import tools.jackson.databind.cfg.EnumFeature;
+import tools.jackson.databind.cfg.JsonNodeFeature;
import tools.jackson.databind.type.CollectionType;
import tools.jackson.dataformat.xml.XmlFactory;
import tools.jackson.dataformat.xml.XmlMapper;
import tools.jackson.dataformat.xml.XmlReadFeature;
+import tools.jackson.dataformat.xml.XmlWriteFeature;
import tools.jackson.module.jakarta.xmlbind.JakartaXmlBindAnnotationModule;
/**
@@ -132,7 +139,7 @@ public class JacksonXMLDataFormat extends ServiceSupport
}
/**
- * Use a custom Jackson mapper and and unmarshal type
+ * Use a custom Jackson mapper and unmarshal type
*
* @param mapper the custom mapper
* @param unmarshalType the custom unmarshal type
@@ -389,7 +396,7 @@ public class JacksonXMLDataFormat extends ServiceSupport
* Allows jackson to use the <tt>JMSType</tt> header as an indicator what
the classname is for unmarshaling XML
* content to POJO
* <p/>
- * By default this option is <tt>false</tt>.
+ * By default, this option is <tt>false</tt>.
*/
public void setAllowJmsType(boolean allowJmsType) {
this.allowJmsType = allowJmsType;
@@ -459,8 +466,10 @@ public class JacksonXMLDataFormat extends ServiceSupport
}
/**
- * Set of features to enable on the Jackson {@link XmlMapper}. The
features should be a name that matches a enum
- * from {@link SerializationFeature}, {@link DeserializationFeature}, or
{@link MapperFeature}.
+ * Set of features to enable on the Jackson {@link XmlMapper}. The
features should be a name that matches an enum
+ * from {@link SerializationFeature}, {@link DeserializationFeature},
{@link MapperFeature},
+ * {@link DateTimeFeature}, {@link EnumFeature}, {@link JsonNodeFeature},
{@link StreamReadFeature},
+ * {@link StreamWriteFeature}, {@link XmlReadFeature} or {@link
XmlWriteFeature}.
*/
public void setEnableFeatures(String enableFeatures) {
this.enableFeatures = enableFeatures;
@@ -471,8 +480,10 @@ public class JacksonXMLDataFormat extends ServiceSupport
}
/**
- * Set of features to disable on the Jackson {@link XmlMapper}. The
features should be a name that matches a enum
- * from {@link SerializationFeature}, {@link DeserializationFeature}, or
{@link MapperFeature}.
+ * Set of features to disable on the Jackson {@link XmlMapper}. The
features should be a name that matches an enum
+ * from {@link SerializationFeature}, {@link DeserializationFeature},
{@link MapperFeature},
+ * {@link DateTimeFeature}, {@link EnumFeature}, {@link JsonNodeFeature},
{@link StreamReadFeature},
+ * {@link StreamWriteFeature}, {@link XmlReadFeature} or {@link
XmlWriteFeature}.
*/
public void setDisableFeatures(String disableFeatures) {
this.disableFeatures = disableFeatures;
@@ -480,65 +491,129 @@ public class JacksonXMLDataFormat extends ServiceSupport
public void enableFeature(SerializationFeature feature) {
if (enableFeatures == null) {
- enableFeatures = feature.name();
+ enableFeatures = feature.getDeclaringClass().getSimpleName() + "."
+ feature.name();
} else {
- enableFeatures += "," + feature.name();
+ enableFeatures += "," +
feature.getDeclaringClass().getSimpleName() + "." + feature.name();
}
}
public void enableFeature(DeserializationFeature feature) {
if (enableFeatures == null) {
- enableFeatures = feature.name();
+ enableFeatures = feature.getDeclaringClass().getSimpleName() + "."
+ feature.name();
} else {
- enableFeatures += "," + feature.name();
+ enableFeatures += "," +
feature.getDeclaringClass().getSimpleName() + "." + feature.name();
}
}
public void enableFeature(MapperFeature feature) {
if (enableFeatures == null) {
- enableFeatures = feature.name();
+ enableFeatures = feature.getDeclaringClass().getSimpleName() + "."
+ feature.name();
} else {
- enableFeatures += "," + feature.name();
+ enableFeatures += "," +
feature.getDeclaringClass().getSimpleName() + "." + feature.name();
+ }
+ }
+
+ public void enableFeature(Enum<? extends DatatypeFeature> feature) {
+ if (enableFeatures == null) {
+ enableFeatures = feature.getDeclaringClass().getSimpleName() + "."
+ feature.name();
+ } else {
+ enableFeatures += "," +
feature.getDeclaringClass().getSimpleName() + "." + feature.name();
+ }
+ }
+
+ public void enableFeature(StreamReadFeature feature) {
+ if (enableFeatures == null) {
+ enableFeatures = feature.getDeclaringClass().getSimpleName() + "."
+ feature.name();
+ } else {
+ enableFeatures += "," +
feature.getDeclaringClass().getSimpleName() + "." + feature.name();
+ }
+ }
+
+ public void enableFeature(StreamWriteFeature feature) {
+ if (enableFeatures == null) {
+ enableFeatures = feature.getDeclaringClass().getSimpleName() + "."
+ feature.name();
+ } else {
+ enableFeatures += "," +
feature.getDeclaringClass().getSimpleName() + "." + feature.name();
}
}
public void enableFeature(XmlReadFeature feature) {
if (enableFeatures == null) {
- enableFeatures = feature.name();
+ enableFeatures = feature.getDeclaringClass().getSimpleName() + "."
+ feature.name();
} else {
- enableFeatures += "," + feature.name();
+ enableFeatures += "," +
feature.getDeclaringClass().getSimpleName() + "." + feature.name();
+ }
+ }
+
+ public void enableFeature(XmlWriteFeature feature) {
+ if (enableFeatures == null) {
+ enableFeatures = feature.getDeclaringClass().getSimpleName() + "."
+ feature.name();
+ } else {
+ enableFeatures += "," +
feature.getDeclaringClass().getSimpleName() + "." + feature.name();
}
}
public void disableFeature(SerializationFeature feature) {
if (disableFeatures == null) {
- disableFeatures = feature.name();
+ disableFeatures = feature.getDeclaringClass().getSimpleName() +
"." + feature.name();
} else {
- disableFeatures += "," + feature.name();
+ disableFeatures += "," +
feature.getDeclaringClass().getSimpleName() + "." + feature.name();
}
}
public void disableFeature(DeserializationFeature feature) {
if (disableFeatures == null) {
- disableFeatures = feature.name();
+ disableFeatures = feature.getDeclaringClass().getSimpleName() +
"." + feature.name();
} else {
- disableFeatures += "," + feature.name();
+ disableFeatures += "," +
feature.getDeclaringClass().getSimpleName() + "." + feature.name();
}
}
public void disableFeature(MapperFeature feature) {
if (disableFeatures == null) {
- disableFeatures = feature.name();
+ disableFeatures = feature.getDeclaringClass().getSimpleName() +
"." + feature.name();
+ } else {
+ disableFeatures += "," +
feature.getDeclaringClass().getSimpleName() + "." + feature.name();
+ }
+ }
+
+ public void disableFeature(Enum<? extends DatatypeFeature> feature) {
+ if (disableFeatures == null) {
+ disableFeatures = feature.getDeclaringClass().getSimpleName() +
"." + feature.name();
+ } else {
+ disableFeatures += "," +
feature.getDeclaringClass().getSimpleName() + "." + feature.name();
+ }
+ }
+
+ public void disableFeature(StreamReadFeature feature) {
+ if (disableFeatures == null) {
+ disableFeatures = feature.getDeclaringClass().getSimpleName() +
"." + feature.name();
} else {
- disableFeatures += "," + feature.name();
+ disableFeatures += "," +
feature.getDeclaringClass().getSimpleName() + "." + feature.name();
+ }
+ }
+
+ public void disableFeature(StreamWriteFeature feature) {
+ if (disableFeatures == null) {
+ disableFeatures = feature.getDeclaringClass().getSimpleName() +
"." + feature.name();
+ } else {
+ disableFeatures += "," +
feature.getDeclaringClass().getSimpleName() + "." + feature.name();
}
}
public void disableFeature(XmlReadFeature feature) {
if (disableFeatures == null) {
- disableFeatures = feature.name();
+ disableFeatures = feature.getDeclaringClass().getSimpleName() +
"." + feature.name();
} else {
- disableFeatures += "," + feature.name();
+ disableFeatures += "," +
feature.getDeclaringClass().getSimpleName() + "." + feature.name();
+ }
+ }
+
+ public void disableFeature(XmlWriteFeature feature) {
+ if (disableFeatures == null) {
+ disableFeatures = feature.getDeclaringClass().getSimpleName() +
"." + feature.name();
+ } else {
+ disableFeatures += "," +
feature.getDeclaringClass().getSimpleName() + "." + feature.name();
}
}
@@ -595,105 +670,268 @@ public class JacksonXMLDataFormat extends ServiceSupport
}
if (enableFeatures != null) {
- Iterator<?> it = ObjectHelper.createIterator(enableFeatures);
- while (it.hasNext()) {
- String enable = it.next().toString();
- // it can be different kind
- SerializationFeature sf =
getCamelContext().getTypeConverter().tryConvertTo(SerializationFeature.class,
enable);
- if (sf != null) {
- xmlMapper = xmlMapper.rebuild().enable(sf).build();
- continue;
- }
- DeserializationFeature df
- =
getCamelContext().getTypeConverter().tryConvertTo(DeserializationFeature.class,
enable);
- if (df != null) {
- xmlMapper = xmlMapper.rebuild().enable(df).build();
- continue;
- }
- MapperFeature mf =
getCamelContext().getTypeConverter().tryConvertTo(MapperFeature.class, enable);
- if (mf != null) {
- xmlMapper = xmlMapper.rebuild().enable(mf).build();
- continue;
- }
- XmlReadFeature pf
- =
getCamelContext().getTypeConverter().tryConvertTo(XmlReadFeature.class, enable);
- if (pf != null) {
- xmlMapper = xmlMapper.rebuild().enable(pf).build();
- continue;
- }
- throw new IllegalArgumentException(
- "Enable feature: " + enable
- + " cannot be converted to
an accepted enum of types
[SerializationFeature,DeserializationFeature,MapperFeature,FromXmlParser.Feature]");
- }
+ doEnableFeatures();
}
if (disableFeatures != null) {
- Iterator<?> it = ObjectHelper.createIterator(disableFeatures);
- while (it.hasNext()) {
- String disable = it.next().toString();
- // it can be different kind
- SerializationFeature sf
- =
getCamelContext().getTypeConverter().tryConvertTo(SerializationFeature.class,
disable);
- if (sf != null) {
- xmlMapper = xmlMapper.rebuild().disable(sf).build();
- continue;
- }
- DeserializationFeature df
- =
getCamelContext().getTypeConverter().tryConvertTo(DeserializationFeature.class,
disable);
- if (df != null) {
- xmlMapper = xmlMapper.rebuild().disable(df).build();
- continue;
- }
- MapperFeature mf =
getCamelContext().getTypeConverter().tryConvertTo(MapperFeature.class, disable);
- if (mf != null) {
- xmlMapper = xmlMapper.rebuild().disable(mf).build();
- continue;
- }
- XmlReadFeature pf
- =
getCamelContext().getTypeConverter().tryConvertTo(XmlReadFeature.class,
disable);
- if (pf != null) {
- xmlMapper = xmlMapper.rebuild().disable(pf).build();
- continue;
- }
- throw new IllegalArgumentException(
- "Disable feature: " + disable
- + " cannot be converted to
an accepted enum of types
[SerializationFeature,DeserializationFeature,MapperFeature,FromXmlParser.Feature]");
- }
+ doDisableFeatures();
}
if (modules != null) {
- for (JacksonModule module : modules) {
- LOG.info("Registering module: {}", module);
- xmlMapper = xmlMapper.rebuild().addModule(module).build();
- }
+ registerModules();
}
if (moduleClassNames != null) {
- Iterable<?> it = ObjectHelper.createIterable(moduleClassNames);
- for (Object o : it) {
- String name = o.toString();
- Class<JacksonModule> clazz =
camelContext.getClassResolver().resolveMandatoryClass(name,
JacksonModule.class);
- JacksonModule module =
camelContext.getInjector().newInstance(clazz);
- LOG.info("Registering module: {} -> {}", name, module);
- xmlMapper = xmlMapper.rebuild().addModule(module).build();
- }
+ registerModulesByClassNames();
}
if (moduleRefs != null) {
- Iterable<?> it = ObjectHelper.createIterable(moduleRefs);
- for (Object o : it) {
- String name = o.toString();
- if (name.startsWith("#")) {
- name = name.substring(1);
+ registerModulesByRefs();
+ }
+ if (org.apache.camel.util.ObjectHelper.isNotEmpty(timezone)) {
+ setTimezone();
+ }
+ }
+
+ private boolean trySetSerializationFeature(String featureValueName,
boolean state) {
+ SerializationFeature feature
+ =
getCamelContext().getTypeConverter().tryConvertTo(SerializationFeature.class,
featureValueName);
+ if (feature == null) {
+ return false;
+ }
+ setXmlMapper(xmlMapper.rebuild().configure(feature, state).build());
+ return true;
+ }
+
+ private boolean trySetDeserializationFeature(String featureValueName,
boolean state) {
+ DeserializationFeature feature
+ =
getCamelContext().getTypeConverter().tryConvertTo(DeserializationFeature.class,
featureValueName);
+ if (feature == null) {
+ return false;
+ }
+ setXmlMapper(xmlMapper.rebuild().configure(feature, state).build());
+ return true;
+ }
+
+ private boolean trySetMapperFeature(String featureValueName, boolean
state) {
+ MapperFeature feature =
getCamelContext().getTypeConverter().tryConvertTo(MapperFeature.class,
featureValueName);
+ if (feature == null) {
+ return false;
+ }
+ setXmlMapper(xmlMapper.rebuild().configure(feature, state).build());
+ return true;
+ }
+
+ private boolean trySetDateTimeFeature(String featureValueName, boolean
state) {
+ DateTimeFeature feature =
getCamelContext().getTypeConverter().tryConvertTo(DateTimeFeature.class,
featureValueName);
+ if (feature == null) {
+ return false;
+ }
+ setXmlMapper(xmlMapper.rebuild().configure(feature, state).build());
+ return true;
+ }
+
+ private boolean trySetEnumFeature(String featureValueName, boolean state) {
+ EnumFeature feature =
getCamelContext().getTypeConverter().tryConvertTo(EnumFeature.class,
featureValueName);
+ if (feature == null) {
+ return false;
+ }
+ setXmlMapper(xmlMapper.rebuild().configure(feature, state).build());
+ return true;
+ }
+
+ private boolean trySetJsonNodeFeature(String featureValueName, boolean
state) {
+ JsonNodeFeature feature =
getCamelContext().getTypeConverter().tryConvertTo(JsonNodeFeature.class,
featureValueName);
+ if (feature == null) {
+ return false;
+ }
+ setXmlMapper(xmlMapper.rebuild().configure(feature, state).build());
+ return true;
+ }
+
+ private boolean trySetStreamReadFeature(String featureValueName, boolean
state) {
+ StreamReadFeature feature
+ =
getCamelContext().getTypeConverter().tryConvertTo(StreamReadFeature.class,
featureValueName);
+ if (feature == null) {
+ return false;
+ }
+ setXmlMapper(xmlMapper.rebuild().configure(feature, state).build());
+ return true;
+ }
+
+ private boolean trySetStreamWriteFeature(String featureValueName, boolean
state) {
+ StreamWriteFeature feature
+ =
getCamelContext().getTypeConverter().tryConvertTo(StreamWriteFeature.class,
featureValueName);
+ if (feature == null) {
+ return false;
+ }
+ setXmlMapper(xmlMapper.rebuild().configure(feature, state).build());
+ return true;
+ }
+
+ private boolean trySetXmlReadFeature(String featureValueName, boolean
state) {
+ XmlReadFeature feature
+ =
getCamelContext().getTypeConverter().tryConvertTo(XmlReadFeature.class,
featureValueName);
+ if (feature == null) {
+ return false;
+ }
+ setXmlMapper(xmlMapper.rebuild().configure(feature, state).build());
+ return true;
+ }
+
+ private boolean trySetXmlWriteFeature(String featureValueName, boolean
state) {
+ XmlWriteFeature feature
+ =
getCamelContext().getTypeConverter().tryConvertTo(XmlWriteFeature.class,
featureValueName);
+ if (feature == null) {
+ return false;
+ }
+ setXmlMapper(xmlMapper.rebuild().configure(feature, state).build());
+ return true;
+ }
+
+ private void doEnableFeatures() {
+ Iterator<?> it = ObjectHelper.createIterator(enableFeatures);
+ while (it.hasNext()) {
+ String enable = it.next().toString();
+ long dotCount = enable.chars().filter(ch -> ch == '.').count();
+ if (dotCount > 1) {
+ throw new IllegalArgumentException("Enable feature: " + enable
+ " cannot contain more than one '.'");
+ }
+
+ String featureClassName = null;
+ String featureValueName = enable;
+
+ if (dotCount == 1) {
+ String[] parts = enable.split("\\.", 2);
+ featureClassName = parts[0];
+ featureValueName = parts[1];
+ }
+
+ if (featureClassName != null) {
+ if (!switch (featureClassName) {
+ case "SerializationFeature" ->
trySetSerializationFeature(featureValueName, true);
+ case "DeserializationFeature" ->
trySetDeserializationFeature(featureValueName, true);
+ case "MapperFeature" ->
trySetMapperFeature(featureValueName, true);
+ case "DateTimeFeature" ->
trySetDateTimeFeature(featureValueName, true);
+ case "EnumFeature" -> trySetEnumFeature(featureValueName,
true);
+ case "JsonNodeFeature" ->
trySetJsonNodeFeature(featureValueName, true);
+ case "StreamReadFeature" ->
trySetStreamReadFeature(featureValueName, true);
+ case "StreamWriteFeature" ->
trySetStreamWriteFeature(featureValueName, true);
+ case "XmlReadFeature" ->
trySetXmlReadFeature(featureValueName, true);
+ case "XmlWriteFeature" ->
trySetXmlWriteFeature(featureValueName, true);
+ default -> false;
+ }) {
+ throw new IllegalArgumentException(
+ "Enable feature: " + enable
+ + " cannot be converted
to an accepted enum of types
[SerializationFeature,DeserializationFeature,MapperFeature,DateTimeFeature,EnumFeature,JsonNodeFeature,StreamReadFeature,StreamWriteFeature,XmlReadFeature,XmlWriteFeature]");
+ }
+ } else {
+ if (!trySetSerializationFeature(featureValueName, true)
+ && !trySetDeserializationFeature(featureValueName,
true)
+ && !trySetMapperFeature(featureValueName, true)
+ && !trySetDateTimeFeature(featureValueName, true)
+ && !trySetEnumFeature(featureValueName, true)
+ && !trySetJsonNodeFeature(featureValueName, true)
+ && !trySetStreamReadFeature(featureValueName, true)
+ && !trySetStreamWriteFeature(featureValueName, true)
+ && !trySetXmlReadFeature(featureValueName, true)
+ && !trySetXmlWriteFeature(featureValueName, true)) {
+ throw new IllegalArgumentException(
+ "Enable feature: " + featureValueName
+ + " cannot be converted
to an accepted enum of types
[SerializationFeature,DeserializationFeature,MapperFeature,DateTimeFeature,EnumFeature,JsonNodeFeature,StreamReadFeature,StreamWriteFeature,XmlReadFeature,XmlWriteFeature]");
}
- JacksonModule module =
CamelContextHelper.mandatoryLookup(camelContext, name, JacksonModule.class);
- LOG.info("Registering module: {} -> {}", name, module);
- xmlMapper = xmlMapper.rebuild().addModule(module).build();
}
}
- if (org.apache.camel.util.ObjectHelper.isNotEmpty(timezone)) {
- LOG.debug("Setting timezone to XML Mapper: {}", timezone);
- xmlMapper = xmlMapper.rebuild().defaultTimeZone(timezone).build();
+ }
+
+ private void doDisableFeatures() {
+ Iterator<?> it = ObjectHelper.createIterator(disableFeatures);
+ while (it.hasNext()) {
+ String disable = it.next().toString();
+ long dotCount = disable.chars().filter(ch -> ch == '.').count();
+ if (dotCount > 1) {
+ throw new IllegalArgumentException("Disable feature: " +
disable + " cannot contain more than one '.'");
+ }
+
+ String featureClassName = null;
+ String featureValueName = disable;
+
+ if (dotCount == 1) {
+ String[] parts = disable.split("\\.", 2);
+ featureClassName = parts[0];
+ featureValueName = parts[1];
+ }
+
+ if (featureClassName != null) {
+ if (!switch (featureClassName) {
+ case "SerializationFeature" ->
trySetSerializationFeature(featureValueName, false);
+ case "DeserializationFeature" ->
trySetDeserializationFeature(featureValueName, false);
+ case "MapperFeature" ->
trySetMapperFeature(featureValueName, false);
+ case "DateTimeFeature" ->
trySetDateTimeFeature(featureValueName, false);
+ case "EnumFeature" -> trySetEnumFeature(featureValueName,
false);
+ case "JsonNodeFeature" ->
trySetJsonNodeFeature(featureValueName, false);
+ case "StreamReadFeature" ->
trySetStreamReadFeature(featureValueName, false);
+ case "StreamWriteFeature" ->
trySetStreamWriteFeature(featureValueName, false);
+ case "XmlReadFeature" ->
trySetXmlReadFeature(featureValueName, false);
+ case "XmlWriteFeature" ->
trySetXmlWriteFeature(featureValueName, false);
+ default -> false;
+ }) {
+ throw new IllegalArgumentException(
+ "Disable feature: " + disable
+ + " cannot be converted
to an accepted enum of types
[SerializationFeature,DeserializationFeature,MapperFeature,DateTimeFeature,EnumFeature,JsonNodeFeature,StreamReadFeature,StreamWriteFeature,XmlReadFeature,XmlWriteFeature]");
+ }
+ } else {
+ if (!trySetSerializationFeature(featureValueName, false)
+ && !trySetDeserializationFeature(featureValueName,
false)
+ && !trySetMapperFeature(featureValueName, false)
+ && !trySetDateTimeFeature(featureValueName, false)
+ && !trySetEnumFeature(featureValueName, false)
+ && !trySetJsonNodeFeature(featureValueName, false)
+ && !trySetStreamReadFeature(featureValueName, false)
+ && !trySetStreamWriteFeature(featureValueName, false)
+ && !trySetXmlReadFeature(featureValueName, false)
+ && !trySetXmlWriteFeature(featureValueName, false)) {
+ throw new IllegalArgumentException(
+ "Disable feature: " + featureValueName
+ + " cannot be converted
to an accepted enum of types
[SerializationFeature,DeserializationFeature,MapperFeature,DateTimeFeature,EnumFeature,JsonNodeFeature,StreamReadFeature,StreamWriteFeature,XmlReadFeature,XmlWriteFeature]");
+ }
+ }
+ }
+ }
+
+ private void registerModules() {
+ for (JacksonModule module : modules) {
+ LOG.info("Registering module: {}", module);
+ xmlMapper = xmlMapper.rebuild().addModule(module).build();
+ }
+ }
+
+ private void registerModulesByClassNames() throws ClassNotFoundException {
+ Iterable<?> it = ObjectHelper.createIterable(moduleClassNames);
+ for (Object o : it) {
+ String name = o.toString();
+ Class<JacksonModule> clazz =
camelContext.getClassResolver().resolveMandatoryClass(name,
JacksonModule.class);
+ JacksonModule module =
camelContext.getInjector().newInstance(clazz);
+ LOG.info("Registering module: {} -> {}", name, module);
+ xmlMapper = xmlMapper.rebuild().addModule(module).build();
}
}
+ private void registerModulesByRefs() {
+ Iterable<?> it = ObjectHelper.createIterable(moduleRefs);
+ for (Object o : it) {
+ String name = o.toString();
+ if (name.startsWith("#")) {
+ name = name.substring(1);
+ }
+ JacksonModule module =
CamelContextHelper.mandatoryLookup(camelContext, name, JacksonModule.class);
+ LOG.info("Registering module: {} -> {}", name, module);
+ xmlMapper = xmlMapper.rebuild().addModule(module).build();
+ }
+ }
+
+ private void setTimezone() {
+ LOG.debug("Setting timezone to XML Mapper: {}", timezone);
+ xmlMapper = xmlMapper.rebuild().defaultTimeZone(timezone).build();
+ }
+
@Override
protected void doStop() throws Exception {
// noop
diff --git
a/components/camel-jackson3xml/src/main/java/org/apache/camel/component/jackson3xml/ListJacksonXMLDataFormat.java
b/components/camel-jackson3xml/src/main/java/org/apache/camel/component/jackson3xml/ListJacksonXMLDataFormat.java
index 30284da268eb..6d900ea2ca02 100644
---
a/components/camel-jackson3xml/src/main/java/org/apache/camel/component/jackson3xml/ListJacksonXMLDataFormat.java
+++
b/components/camel-jackson3xml/src/main/java/org/apache/camel/component/jackson3xml/ListJacksonXMLDataFormat.java
@@ -19,7 +19,7 @@ package org.apache.camel.component.jackson3xml;
import tools.jackson.dataformat.xml.XmlMapper;
/**
- * A {@link org.apache.camel.component.jacksonxml.JacksonXMLDataFormat} that
is using a list
+ * A {@link org.apache.camel.component.jackson3xml.JacksonXMLDataFormat} that
is using a list
*/
public class ListJacksonXMLDataFormat extends JacksonXMLDataFormat {
diff --git
a/components/camel-jackson3xml/src/test/java/org/apache/camel/component/jackson3xml/JacksonFeaturesTest.java
b/components/camel-jackson3xml/src/test/java/org/apache/camel/component/jackson3xml/JacksonFeaturesTest.java
new file mode 100644
index 000000000000..6e6ae99f83aa
--- /dev/null
+++
b/components/camel-jackson3xml/src/test/java/org/apache/camel/component/jackson3xml/JacksonFeaturesTest.java
@@ -0,0 +1,117 @@
+/*
+ * 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.jackson3xml;
+
+import java.util.Arrays;
+
+import org.apache.camel.builder.RouteBuilder;
+import org.apache.camel.component.mock.MockEndpoint;
+import org.apache.camel.test.junit6.CamelTestSupport;
+import org.junit.jupiter.api.Test;
+import tools.jackson.core.StreamReadFeature;
+import tools.jackson.core.StreamWriteFeature;
+import tools.jackson.dataformat.xml.XmlWriteFeature;
+
+import static org.junit.jupiter.api.Assertions.assertEquals;
+import static org.junit.jupiter.api.Assertions.assertFalse;
+import static org.junit.jupiter.api.Assertions.assertThrows;
+import static org.junit.jupiter.api.Assertions.assertTrue;
+
+public class JacksonFeaturesTest extends CamelTestSupport {
+
+ @Test
+ public void testEnableWrongSyntaxOfFeature() throws Exception {
+ JacksonXMLDataFormat format = new JacksonXMLDataFormat();
+ format.setEnableFeatures("Package.Enum.FEATURE");
+ format.setCamelContext(context());
+ IllegalArgumentException ex =
assertThrows(IllegalArgumentException.class, () -> format.doStart());
+ assertEquals("Enable feature: Package.Enum.FEATURE cannot contain more
than one '.'", ex.getMessage());
+ }
+
+ @Test
+ public void testEnableWrongTypedFeatureWithClassName() throws Exception {
+ JacksonXMLDataFormat format = new JacksonXMLDataFormat();
+ format.setEnableFeatures("Enum.FEATURE");
+ format.setCamelContext(context());
+ IllegalArgumentException ex =
assertThrows(IllegalArgumentException.class, () -> format.doStart());
+ assertEquals(
+ "Enable feature: Enum.FEATURE cannot be converted to an
accepted enum of types
[SerializationFeature,DeserializationFeature,MapperFeature,DateTimeFeature,EnumFeature,JsonNodeFeature,StreamReadFeature,StreamWriteFeature,XmlReadFeature,XmlWriteFeature]",
+ ex.getMessage());
+ }
+
+ @Test
+ public void testEnableWrongTypedFeatureWithoutClassName() throws Exception
{
+ JacksonXMLDataFormat format = new JacksonXMLDataFormat();
+ format.setEnableFeatures("FEATURE");
+ format.setCamelContext(context());
+ IllegalArgumentException ex =
assertThrows(IllegalArgumentException.class, () -> format.doStart());
+ assertEquals(
+ "Enable feature: FEATURE cannot be converted to an accepted
enum of types
[SerializationFeature,DeserializationFeature,MapperFeature,DateTimeFeature,EnumFeature,JsonNodeFeature,StreamReadFeature,StreamWriteFeature,XmlReadFeature,XmlWriteFeature]",
+ ex.getMessage());
+ }
+
+ @Test
+ public void testEnableStrictDuplicateDetectionFromDifferentFeatures()
throws Exception {
+ // Initialization by implementation order (StreamReadFeature before
StreamWriteFeature)
+ JacksonXMLDataFormat format1 = new JacksonXMLDataFormat();
+ format1.setEnableFeatures("STRICT_DUPLICATE_DETECTION");
+ format1.setCamelContext(context());
+ format1.doStart();
+
assertTrue(format1.getXmlMapper().isEnabled(StreamReadFeature.STRICT_DUPLICATE_DETECTION));
+
assertFalse(format1.getXmlMapper().isEnabled(StreamWriteFeature.STRICT_DUPLICATE_DETECTION));
+
+ // Explicit declaration of implementing feature set
+ JacksonXMLDataFormat format2 = new JacksonXMLDataFormat();
+
format2.setEnableFeatures("StreamReadFeature.STRICT_DUPLICATE_DETECTION");
+ format2.setCamelContext(context());
+ format2.doStart();
+
assertTrue(format2.getXmlMapper().isEnabled(StreamReadFeature.STRICT_DUPLICATE_DETECTION));
+
assertFalse(format2.getXmlMapper().isEnabled(StreamWriteFeature.STRICT_DUPLICATE_DETECTION));
+
+ JacksonXMLDataFormat format3 = new JacksonXMLDataFormat();
+
format3.setEnableFeatures("StreamWriteFeature.STRICT_DUPLICATE_DETECTION");
+ format3.setCamelContext(context());
+ format3.doStart();
+
assertFalse(format3.getXmlMapper().isEnabled(StreamReadFeature.STRICT_DUPLICATE_DETECTION));
+
assertTrue(format3.getXmlMapper().isEnabled(StreamWriteFeature.STRICT_DUPLICATE_DETECTION));
+ }
+
+ @Test
+ public void testEnableMapperFeature() throws Exception {
+ MockEndpoint mock = getMockEndpoint("mock:result");
+ mock.expectedMessageCount(1);
+
mock.message(0).body(String.class).isEqualTo("<ArrayList><item>test</item><item/></ArrayList>");
+
+ template.send("direct:format", exchange ->
exchange.getIn().setBody(Arrays.asList("test", null)));
+
+ mock.assertIsSatisfied();
+ }
+
+ @Override
+ protected RouteBuilder createRouteBuilder() {
+ return new RouteBuilder() {
+
+ @Override
+ public void configure() {
+ JacksonXMLDataFormat formatModel = new JacksonXMLDataFormat();
+
formatModel.disableFeature(XmlWriteFeature.WRITE_NULLS_AS_XSI_NIL);
+
+ from("direct:format").marshal(formatModel).to("mock:result");
+ }
+ };
+ }
+}
diff --git
a/components/camel-jacksonxml/src/generated/resources/META-INF/org/apache/camel/component/jacksonxml/jacksonXml.json
b/components/camel-jacksonxml/src/generated/resources/META-INF/org/apache/camel/component/jacksonxml/jacksonXml.json
index 637e43a44a34..0ef6602a7d38 100644
---
a/components/camel-jacksonxml/src/generated/resources/META-INF/org/apache/camel/component/jacksonxml/jacksonXml.json
+++
b/components/camel-jacksonxml/src/generated/resources/META-INF/org/apache/camel/component/jacksonxml/jacksonXml.json
@@ -30,8 +30,8 @@
"enableJaxbAnnotationModule": { "index": 11, "kind": "attribute",
"displayName": "Enable Jaxb Annotation Module", "group": "advanced", "label":
"advanced", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Whether to enable the JAXB annotations
module when using Jackson. When enabled then JAXB annotations can be used by
Jackson." },
"moduleClassNames": { "index": 12, "kind": "attribute", "displayName":
"Module Class Names", "group": "advanced", "label": "advanced", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "To use custom Jackson
modules com.fasterxml.jackson.databind.Module specified as a String with FQN
class names. Multiple classes can be separated by comma." },
"moduleRefs": { "index": 13, "kind": "attribute", "displayName": "Module
Refs", "group": "advanced", "label": "advanced", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "description": "To use custom Jackson modules referred
from the Camel registry. Multiple modules can be separated by comma." },
- "enableFeatures": { "index": 14, "kind": "attribute", "displayName":
"Enable Features", "group": "common", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Set of features to enable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature, or
MapperFeature. Multiple features can be separate [...]
- "disableFeatures": { "index": 15, "kind": "attribute", "displayName":
"Disable Features", "group": "common", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Set of features to disable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature, or
MapperFeature. Multiple features can be separ [...]
+ "enableFeatures": { "index": 14, "kind": "attribute", "displayName":
"Enable Features", "group": "common", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Set of features to enable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature,
MapperFeature, DateTimeFeature, EnumFeature, JsonNo [...]
+ "disableFeatures": { "index": 15, "kind": "attribute", "displayName":
"Disable Features", "group": "common", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Set of features to disable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature,
MapperFeature, DateTimeFeature, EnumFeature, Jso [...]
"contentTypeHeader": { "index": 16, "kind": "attribute", "displayName":
"Content Type Header", "group": "common", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether the data format
should set the Content-Type header with the type from the data format. For
example application\/xml for data formats marshalling to XML, or
application\/json for data formats marshall [...]
"maxStringLength": { "index": 17, "kind": "attribute", "displayName": "Max
String Length", "group": "advanced", "label": "advanced", "required": false,
"type": "integer", "javaType": "java.lang.Integer", "deprecated": false,
"autowired": false, "secret": false, "description": "Maximum allowed string
length when deserializing (in chars or bytes, depending on input context). The
default is 20,000,000." }
}
diff --git
a/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/dataformat/jacksonXml.json
b/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/dataformat/jacksonXml.json
index 9d1ee0e2e9ca..ae60295e87f8 100644
---
a/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/dataformat/jacksonXml.json
+++
b/core/camel-core-model/src/generated/resources/META-INF/org/apache/camel/model/dataformat/jacksonXml.json
@@ -27,8 +27,8 @@
"enableJaxbAnnotationModule": { "index": 11, "kind": "attribute",
"displayName": "Enable Jaxb Annotation Module", "group": "advanced", "label":
"advanced", "required": false, "type": "boolean", "javaType":
"java.lang.Boolean", "deprecated": false, "autowired": false, "secret": false,
"defaultValue": false, "description": "Whether to enable the JAXB annotations
module when using Jackson. When enabled then JAXB annotations can be used by
Jackson." },
"moduleClassNames": { "index": 12, "kind": "attribute", "displayName":
"Module Class Names", "group": "advanced", "label": "advanced", "required":
false, "type": "string", "javaType": "java.lang.String", "deprecated": false,
"autowired": false, "secret": false, "description": "To use custom Jackson
modules com.fasterxml.jackson.databind.Module specified as a String with FQN
class names. Multiple classes can be separated by comma." },
"moduleRefs": { "index": 13, "kind": "attribute", "displayName": "Module
Refs", "group": "advanced", "label": "advanced", "required": false, "type":
"string", "javaType": "java.lang.String", "deprecated": false, "autowired":
false, "secret": false, "description": "To use custom Jackson modules referred
from the Camel registry. Multiple modules can be separated by comma." },
- "enableFeatures": { "index": 14, "kind": "attribute", "displayName":
"Enable Features", "group": "common", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Set of features to enable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature, or
MapperFeature. Multiple features can be separate [...]
- "disableFeatures": { "index": 15, "kind": "attribute", "displayName":
"Disable Features", "group": "common", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Set of features to disable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature, or
MapperFeature. Multiple features can be separ [...]
+ "enableFeatures": { "index": 14, "kind": "attribute", "displayName":
"Enable Features", "group": "common", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Set of features to enable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature,
MapperFeature, DateTimeFeature, EnumFeature, JsonNo [...]
+ "disableFeatures": { "index": 15, "kind": "attribute", "displayName":
"Disable Features", "group": "common", "required": false, "type": "string",
"javaType": "java.lang.String", "deprecated": false, "autowired": false,
"secret": false, "description": "Set of features to disable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature,
MapperFeature, DateTimeFeature, EnumFeature, Jso [...]
"contentTypeHeader": { "index": 16, "kind": "attribute", "displayName":
"Content Type Header", "group": "common", "required": false, "type": "boolean",
"javaType": "java.lang.Boolean", "deprecated": false, "autowired": false,
"secret": false, "defaultValue": true, "description": "Whether the data format
should set the Content-Type header with the type from the data format. For
example application\/xml for data formats marshalling to XML, or
application\/json for data formats marshall [...]
"maxStringLength": { "index": 17, "kind": "attribute", "displayName": "Max
String Length", "group": "advanced", "label": "advanced", "required": false,
"type": "integer", "javaType": "java.lang.Integer", "deprecated": false,
"autowired": false, "secret": false, "description": "Maximum allowed string
length when deserializing (in chars or bytes, depending on input context). The
default is 20,000,000." }
}
diff --git
a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JacksonXMLDataFormat.java
b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JacksonXMLDataFormat.java
index 316eab9bfb33..8e8b74ac5419 100644
---
a/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JacksonXMLDataFormat.java
+++
b/core/camel-core-model/src/main/java/org/apache/camel/model/dataformat/JacksonXMLDataFormat.java
@@ -95,13 +95,15 @@ public class JacksonXMLDataFormat extends
DataFormatDefinition implements Conten
private String moduleRefs;
@XmlAttribute
@Metadata(description = "Set of features to enable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper."
- + " The features should be a name that matches a
enum from SerializationFeature, DeserializationFeature, or MapperFeature."
- + " Multiple features can be separated by comma.")
+ + " The features should be a name that matches a
enum from SerializationFeature, DeserializationFeature, MapperFeature,
DateTimeFeature, EnumFeature, JsonNodeFeature, StreamReadFeature,
StreamWriteFeature, XmlReadFeature or XmlWriteFeature."
+ + " Multiple features can be separated by comma."
+ + " When using Jackson 3, a feature can be
qualified with its enum class name (e.g. SerializationFeature.WRAP_ROOT_VALUE)
to tell apart features with the same name.")
private String enableFeatures;
@XmlAttribute
@Metadata(description = "Set of features to disable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper."
- + " The features should be a name that matches a
enum from SerializationFeature, DeserializationFeature, or MapperFeature."
- + " Multiple features can be separated by comma.")
+ + " The features should be a name that matches a
enum from SerializationFeature, DeserializationFeature, MapperFeature,
DateTimeFeature, EnumFeature, JsonNodeFeature, StreamReadFeature,
StreamWriteFeature, XmlReadFeature or XmlWriteFeature."
+ + " Multiple features can be separated by comma."
+ + " When using Jackson 3, a feature can be
qualified with its enum class name (e.g. SerializationFeature.WRAP_ROOT_VALUE)
to tell apart features with the same name.")
private String disableFeatures;
@XmlAttribute
@Metadata(javaType = "java.lang.Boolean", defaultValue = "true",
diff --git
a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
index 6601855fc940..1c02a88975a5 100644
---
a/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
+++
b/dsl/camel-yaml-dsl/camel-yaml-dsl-deserializers/src/generated/java/org/apache/camel/dsl/yaml/deserializers/ModelDeserializers.java
@@ -7509,8 +7509,8 @@ public final class ModelDeserializers extends
YamlDeserializerSupport {
@YamlProperty(name = "allowUnmarshallType", type =
"boolean", defaultValue = "false", description = "Whether to allow Jackson to
use the CamelJacksonUnmarshalType header during unmarshalling. Should only be
enabled when desired.", displayName = "Allow Unmarshall Type"),
@YamlProperty(name = "collectionType", type = "string",
description = "Refers to a custom collection type to lookup in the registry to
use. This option should rarely be used, but allows using different collection
types than java.util.Collection based as default.", displayName = "Collection
Type"),
@YamlProperty(name = "contentTypeHeader", type =
"boolean", defaultValue = "true", description = "Whether the data format should
set the Content-Type header with the type from the data format. For example
application/xml for data formats marshalling to XML, or application/json for
data formats marshalling to JSON", displayName = "Content Type Header"),
- @YamlProperty(name = "disableFeatures", type = "string",
description = "Set of features to disable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature, or
MapperFeature. Multiple features can be separated by comma.", displayName =
"Disable Features"),
- @YamlProperty(name = "enableFeatures", type = "string",
description = "Set of features to enable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature, or
MapperFeature. Multiple features can be separated by comma.", displayName =
"Enable Features"),
+ @YamlProperty(name = "disableFeatures", type = "string",
description = "Set of features to disable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature,
MapperFeature, DateTimeFeature, EnumFeature, JsonNodeFeature,
StreamReadFeature, StreamWriteFeature, XmlReadFeature or XmlWriteFeature.
Multiple features can be separated by comma. When using Jackson 3, a feature
[...]
+ @YamlProperty(name = "enableFeatures", type = "string",
description = "Set of features to enable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature,
MapperFeature, DateTimeFeature, EnumFeature, JsonNodeFeature,
StreamReadFeature, StreamWriteFeature, XmlReadFeature or XmlWriteFeature.
Multiple features can be separated by comma. When using Jackson 3, a feature c
[...]
@YamlProperty(name = "enableJaxbAnnotationModule", type =
"boolean", defaultValue = "false", description = "Whether to enable the JAXB
annotations module when using Jackson. When enabled then JAXB annotations can
be used by Jackson.", displayName = "Enable Jaxb Annotation Module"),
@YamlProperty(name = "id", type = "string", description =
"The id of this node", displayName = "Id"),
@YamlProperty(name = "include", type = "string",
description = "If you want to marshal a POJO to JSON, and the POJO has some
fields with null values. And you want to skip these null values, you can set
this option to NON_NULL.", displayName = "Include"),
diff --git
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-canonical.json
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-canonical.json
index fb088be1f633..1471a70060e4 100644
---
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-canonical.json
+++
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-canonical.json
@@ -7684,12 +7684,12 @@
"disableFeatures" : {
"type" : "string",
"title" : "Disable Features",
- "description" : "Set of features to disable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature, or
MapperFeature. Multiple features can be separated by comma."
+ "description" : "Set of features to disable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature,
MapperFeature, DateTimeFeature, EnumFeature, JsonNodeFeature,
StreamReadFeature, StreamWriteFeature, XmlReadFeature or XmlWriteFeature.
Multiple features can be separated by comma. When using Jackson 3, a feature
can be qualified with its enum class name (e.g. SerializationF [...]
},
"enableFeatures" : {
"type" : "string",
"title" : "Enable Features",
- "description" : "Set of features to enable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature, or
MapperFeature. Multiple features can be separated by comma."
+ "description" : "Set of features to enable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature,
MapperFeature, DateTimeFeature, EnumFeature, JsonNodeFeature,
StreamReadFeature, StreamWriteFeature, XmlReadFeature or XmlWriteFeature.
Multiple features can be separated by comma. When using Jackson 3, a feature
can be qualified with its enum class name (e.g. SerializationFe [...]
},
"enableJaxbAnnotationModule" : {
"type" : "boolean",
diff --git
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-model.json
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-model.json
index 5f661bb07177..6c97b9d7b50c 100644
---
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-model.json
+++
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl-model.json
@@ -12204,12 +12204,12 @@
}, {
"name" : "disableFeatures",
"type" : "string",
- "description" : "Set of features to disable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature, or
MapperFeature. Multiple features can be separated by comma.",
+ "description" : "Set of features to disable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature,
MapperFeature, DateTimeFeature, EnumFeature, JsonNodeFeature,
StreamReadFeature, StreamWriteFeature, XmlReadFeature or XmlWriteFeature.
Multiple features can be separated by comma. When using Jackson 3, a feature
can be qualified with its enum class name (e.g. SerializationFeatu [...]
"title" : "Disable Features"
}, {
"name" : "enableFeatures",
"type" : "string",
- "description" : "Set of features to enable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature, or
MapperFeature. Multiple features can be separated by comma.",
+ "description" : "Set of features to enable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature,
MapperFeature, DateTimeFeature, EnumFeature, JsonNodeFeature,
StreamReadFeature, StreamWriteFeature, XmlReadFeature or XmlWriteFeature.
Multiple features can be separated by comma. When using Jackson 3, a feature
can be qualified with its enum class name (e.g. SerializationFeatur [...]
"title" : "Enable Features"
}, {
"name" : "enableJaxbAnnotationModule",
diff --git
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
index 2a2ff1970e27..c9c3a74c717b 100644
---
a/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
+++
b/dsl/camel-yaml-dsl/camel-yaml-dsl/src/generated/resources/schema/camelYamlDsl.json
@@ -9871,12 +9871,12 @@
"disableFeatures" : {
"type" : "string",
"title" : "Disable Features",
- "description" : "Set of features to disable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature, or
MapperFeature. Multiple features can be separated by comma."
+ "description" : "Set of features to disable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature,
MapperFeature, DateTimeFeature, EnumFeature, JsonNodeFeature,
StreamReadFeature, StreamWriteFeature, XmlReadFeature or XmlWriteFeature.
Multiple features can be separated by comma. When using Jackson 3, a feature
can be qualified with its enum class name (e.g. SerializationF [...]
},
"enableFeatures" : {
"type" : "string",
"title" : "Enable Features",
- "description" : "Set of features to enable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature, or
MapperFeature. Multiple features can be separated by comma."
+ "description" : "Set of features to enable on the Jackson
com.fasterxml.jackson.databind.ObjectMapper. The features should be a name that
matches a enum from SerializationFeature, DeserializationFeature,
MapperFeature, DateTimeFeature, EnumFeature, JsonNodeFeature,
StreamReadFeature, StreamWriteFeature, XmlReadFeature or XmlWriteFeature.
Multiple features can be separated by comma. When using Jackson 3, a feature
can be qualified with its enum class name (e.g. SerializationFe [...]
},
"enableJaxbAnnotationModule" : {
"type" : "boolean",