This is an automated email from the ASF dual-hosted git repository. dmvolod pushed a commit to branch master in repository https://gitbox.apache.org/repos/asf/camel.git
commit a32d44eaae3a908306dc6a4d2cdf64744b5b440a Author: Christian Ribeaud <christian.ribe...@novartis.com> AuthorDate: Mon Jan 21 10:13:30 2019 +0100 Adapt documentation and add possibility to set the marshaller factory in 'camel-core' --- .../camel/model/dataformat/CsvDataFormat.java | 24 ++++++++++++++++++++++ .../camel-csv/src/main/docs/csv-dataformat.adoc | 4 +++- .../modules/ROOT/pages/csv-dataformat.adoc | 2 ++ .../csv/springboot/CsvDataFormatConfiguration.java | 12 +++++++++++ 4 files changed, 41 insertions(+), 1 deletion(-) diff --git a/camel-core/src/main/java/org/apache/camel/model/dataformat/CsvDataFormat.java b/camel-core/src/main/java/org/apache/camel/model/dataformat/CsvDataFormat.java index ccc10ea..36e7406 100644 --- a/camel-core/src/main/java/org/apache/camel/model/dataformat/CsvDataFormat.java +++ b/camel-core/src/main/java/org/apache/camel/model/dataformat/CsvDataFormat.java @@ -85,6 +85,8 @@ public class CsvDataFormat extends DataFormatDefinition { private Boolean trim; @XmlAttribute private Boolean trailingDelimiter; + @XmlAttribute + private String marshallerFactoryRef; // Unmarshall options @XmlAttribute @@ -197,6 +199,10 @@ public class CsvDataFormat extends DataFormatDefinition { Object recordConverter = CamelContextHelper.mandatoryLookup(camelContext, recordConverterRef); setProperty(camelContext, dataFormat, "recordConverter", recordConverter); } + if (ObjectHelper.isNotEmpty(marshallerFactoryRef)) { + Object marshallerFactory = CamelContextHelper.mandatoryLookup(camelContext, marshallerFactoryRef.trim()); + setProperty(camelContext, dataFormat, "marshallerFactory", marshallerFactory); + } } private static Character singleChar(String value, String attributeName) { @@ -206,6 +212,24 @@ public class CsvDataFormat extends DataFormatDefinition { return value.charAt(0); } + /** + * Sets the <code>CsvMarshallerFactory</code> reference. + * + * @param marshallerFactoryRef the <code>CsvMarshallerFactory</code> reference. Could be <code>null</code>. + */ + public void setMarshallerFactoryRef(String marshallerFactoryRef) { + this.marshallerFactoryRef = marshallerFactoryRef; + } + + /** + * Returns the <code>CsvMarshallerFactory</code> reference. + * + * @return the <code>CsvMarshallerFactory</code> or <code>null</code> if none has been specified. + */ + public String getMarshallerFactoryRef() { + return marshallerFactoryRef; + } + public String getFormatRef() { return formatRef; } diff --git a/components/camel-csv/src/main/docs/csv-dataformat.adoc b/components/camel-csv/src/main/docs/csv-dataformat.adoc index 7979999..3a1253d 100644 --- a/components/camel-csv/src/main/docs/csv-dataformat.adoc +++ b/components/camel-csv/src/main/docs/csv-dataformat.adoc @@ -12,7 +12,7 @@ exported/imported by Excel. ### Options // dataformat options: START -The CSV dataformat supports 28 options, which are listed below. +The CSV dataformat supports 29 options, which are listed below. @@ -42,6 +42,7 @@ The CSV dataformat supports 28 options, which are listed below. | ignoreHeaderCase | false | Boolean | Sets whether or not to ignore case when accessing header names. | trim | false | Boolean | Sets whether or not to trim leading and trailing blanks. | trailingDelimiter | false | Boolean | Sets whether or not to add a trailing delimiter. +| marshallerFactoryRef | | String | Sets the `CsvMarshallerFactory` reference. | lazyLoad | false | Boolean | Whether the unmarshalling should produce an iterator that reads the lines on the fly or if all the lines must be read at one. | useMaps | false | Boolean | Whether the unmarshalling should produce maps (HashMap)for the lines values instead of lists. It requires to have header (either defined or collected). | useOrderedMaps | false | Boolean | Whether the unmarshalling should produce ordered maps (LinkedHashMap) for the lines values instead of lists. It requires to have header (either defined or collected). @@ -89,6 +90,7 @@ The component supports 29 options, which are listed below. | *camel.dataformat.csv.trim* | Sets whether or not to trim leading and trailing blanks. | false | Boolean | *camel.dataformat.csv.use-maps* | Whether the unmarshalling should produce maps (HashMap)for the lines values instead of lists. It requires to have header (either defined or collected). | false | Boolean | *camel.dataformat.csv.use-ordered-maps* | Whether the unmarshalling should produce ordered maps (LinkedHashMap) for the lines values instead of lists. It requires to have header (either defined or collected). | false | Boolean +| *camel.dataformat.csv.marshaller-factory-ref* | Refers to a custom `CsvMarshallerFactory` to lookup from the registry to use. | | String |=== // spring-boot-auto-configure options: END ND diff --git a/docs/components/modules/ROOT/pages/csv-dataformat.adoc b/docs/components/modules/ROOT/pages/csv-dataformat.adoc index 7979999..0f8157d 100644 --- a/docs/components/modules/ROOT/pages/csv-dataformat.adoc +++ b/docs/components/modules/ROOT/pages/csv-dataformat.adoc @@ -47,6 +47,7 @@ The CSV dataformat supports 28 options, which are listed below. | useOrderedMaps | false | Boolean | Whether the unmarshalling should produce ordered maps (LinkedHashMap) for the lines values instead of lists. It requires to have header (either defined or collected). | recordConverterRef | | String | Refers to a custom CsvRecordConverter to lookup from the registry to use. | contentTypeHeader | false | Boolean | Whether the data format should set the Content-Type header with the type from the data format if the data format is capable of doing so. For example application/xml for data formats marshalling to XML, or application/json for data formats marshalling to JSon etc. +| marshallerFactory | | String | Refers to a custom `CsvMarshallerFactory` to lookup from the registry to use. |=== // dataformat options: END // spring-boot-auto-configure options: START @@ -89,6 +90,7 @@ The component supports 29 options, which are listed below. | *camel.dataformat.csv.trim* | Sets whether or not to trim leading and trailing blanks. | false | Boolean | *camel.dataformat.csv.use-maps* | Whether the unmarshalling should produce maps (HashMap)for the lines values instead of lists. It requires to have header (either defined or collected). | false | Boolean | *camel.dataformat.csv.use-ordered-maps* | Whether the unmarshalling should produce ordered maps (LinkedHashMap) for the lines values instead of lists. It requires to have header (either defined or collected). | false | Boolean +| *camel.dataformat.csv.marshaller-factory-ref* | Refers to a custom `CsvMarshallerFactory` to lookup from the registry to use. | | String |=== // spring-boot-auto-configure options: END ND diff --git a/platforms/spring-boot/components-starter/camel-csv-starter/src/main/java/org/apache/camel/dataformat/csv/springboot/CsvDataFormatConfiguration.java b/platforms/spring-boot/components-starter/camel-csv-starter/src/main/java/org/apache/camel/dataformat/csv/springboot/CsvDataFormatConfiguration.java index b2fc5b5..f8d6bce 100644 --- a/platforms/spring-boot/components-starter/camel-csv-starter/src/main/java/org/apache/camel/dataformat/csv/springboot/CsvDataFormatConfiguration.java +++ b/platforms/spring-boot/components-starter/camel-csv-starter/src/main/java/org/apache/camel/dataformat/csv/springboot/CsvDataFormatConfiguration.java @@ -132,6 +132,10 @@ public class CsvDataFormatConfiguration */ private Boolean trailingDelimiter = false; /** + * Sets the CsvMarshallerFactory reference. + */ + private String marshallerFactoryRef; + /** * Whether the unmarshalling should produce an iterator that reads the lines * on the fly or if all the lines must be read at one. */ @@ -344,6 +348,14 @@ public class CsvDataFormatConfiguration this.trailingDelimiter = trailingDelimiter; } + public String getMarshallerFactoryRef() { + return marshallerFactoryRef; + } + + public void setMarshallerFactoryRef(String marshallerFactoryRef) { + this.marshallerFactoryRef = marshallerFactoryRef; + } + public Boolean getLazyLoad() { return lazyLoad; }