This is an automated email from the ASF dual-hosted git repository. davsclaus pushed a commit to branch dataformat in repository https://gitbox.apache.org/repos/asf/camel.git
commit 27b6ad0d4cba9f0ca88948b9ca42eb3e76793ac2 Author: Claus Ibsen <claus.ib...@gmail.com> AuthorDate: Mon Apr 22 08:37:55 2019 +0200 CAMEL-13439: Resolving data formats is a bit cumbersome. So lets initialize dataformats that has been setup via XML DSL or added as model, then they are ready to be used. Avoid using RouteContext as it was not needed and helps with modularization. Add some missing dataformats in the DSL. --- .../impl/transformer/DataFormatTransformer.java | 22 ++++++++-------------- 1 file changed, 8 insertions(+), 14 deletions(-) diff --git a/core/camel-core/src/main/java/org/apache/camel/impl/transformer/DataFormatTransformer.java b/core/camel-core/src/main/java/org/apache/camel/impl/transformer/DataFormatTransformer.java index 7e9b409..0e4cca5 100644 --- a/core/camel-core/src/main/java/org/apache/camel/impl/transformer/DataFormatTransformer.java +++ b/core/camel-core/src/main/java/org/apache/camel/impl/transformer/DataFormatTransformer.java @@ -94,19 +94,6 @@ public class DataFormatTransformer extends Transformer { } private DataFormat getDataFormat(Exchange exchange) throws Exception { - // TODO: Move this to doStart and remove this method - if (this.dataFormat == null) { - if (this.dataFormatType != null) { - this.dataFormat = this.dataFormatType.getDataFormat(exchange.getContext()); - } else if (this.dataFormatRef != null) { - this.dataFormat = exchange.getContext().resolveDataFormat(this.dataFormatRef); - } -// this.dataFormat = DataFormatDefinition.getDataFormat( -// exchange.getContext(), this.dataFormatType, this.dataFormatRef); - if (this.dataFormat != null && !getCamelContext().hasService(this.dataFormat)) { - getCamelContext().addService(this.dataFormat, false); - } - } return this.dataFormat; } @@ -144,7 +131,14 @@ public class DataFormatTransformer extends Transformer { @Override public void doStart() throws Exception { - // no-op + if (this.dataFormat == null) { + if (this.dataFormatRef != null) { + this.dataFormat = getCamelContext().resolveDataFormat(this.dataFormatRef); + } else if (this.dataFormatType != null) { + this.dataFormat = dataFormatType.getDataFormat(getCamelContext()); + getCamelContext().addService(this.dataFormat, false); + } + } } @Override