Repository: camel Updated Branches: refs/heads/master 74deb7036 -> 8f5c4d571
CAMEL-7880: rest-dsl with custom data format must use separate instances for input and output. Project: http://git-wip-us.apache.org/repos/asf/camel/repo Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/8f5c4d57 Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/8f5c4d57 Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/8f5c4d57 Branch: refs/heads/master Commit: 8f5c4d5717e2671c370f019a40f7f13b4e16eb62 Parents: 74deb70 Author: Claus Ibsen <davscl...@apache.org> Authored: Wed Dec 3 21:02:12 2014 +0100 Committer: Claus Ibsen <davscl...@apache.org> Committed: Wed Dec 3 21:18:56 2014 +0100 ---------------------------------------------------------------------- .../camel/model/rest/RestBindingDefinition.java | 25 ++++++++++++++++---- 1 file changed, 21 insertions(+), 4 deletions(-) ---------------------------------------------------------------------- http://git-wip-us.apache.org/repos/asf/camel/blob/8f5c4d57/camel-core/src/main/java/org/apache/camel/model/rest/RestBindingDefinition.java ---------------------------------------------------------------------- diff --git a/camel-core/src/main/java/org/apache/camel/model/rest/RestBindingDefinition.java b/camel-core/src/main/java/org/apache/camel/model/rest/RestBindingDefinition.java index 3a120c4..8d0e9ff 100644 --- a/camel-core/src/main/java/org/apache/camel/model/rest/RestBindingDefinition.java +++ b/camel-core/src/main/java/org/apache/camel/model/rest/RestBindingDefinition.java @@ -84,12 +84,20 @@ public class RestBindingDefinition extends NoOutputDefinition<RestBindingDefinit } // setup json data format + DataFormat json; + DataFormat outJson; + String name = context.getRestConfiguration().getJsonDataFormat(); if (name == null) { + // this will create a new instance as we use the default name name = "json-jackson"; + json = context.resolveDataFormat(name); + outJson = context.resolveDataFormat(name); + } else { + json = context.resolveDataFormat(name); + // for out we need to make a new instance of the same class + outJson = context.getInjector().newInstance(json.getClass(), json); } - DataFormat json = context.resolveDataFormat(name); - DataFormat outJson = context.resolveDataFormat(name); // is json binding required? if (mode.contains("json") && json == null) { @@ -123,12 +131,21 @@ public class RestBindingDefinition extends NoOutputDefinition<RestBindingDefinit } // setup xml data format + // setup json data format + DataFormat jaxb; + DataFormat outJaxb; + name = context.getRestConfiguration().getXmlDataFormat(); if (name == null) { + // this will create a new instance as we use the default name name = "jaxb"; + jaxb = context.resolveDataFormat(name); + outJaxb = context.resolveDataFormat(name); + } else { + jaxb = context.resolveDataFormat(name); + // for out we need to make a new instance of the same class + outJaxb = context.getInjector().newInstance(jaxb.getClass(), json); } - DataFormat jaxb = context.resolveDataFormat(name); - DataFormat outJaxb = context.resolveDataFormat(name); // is xml binding required? if (mode.contains("xml") && jaxb == null) { throw new IllegalArgumentException("XML DataFormat " + name + " not found.");