camel-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From davscl...@apache.org
Subject camel git commit: CAMEL-7880: rest-dsl with custom data format must use separate instances for input and output.
Date Wed, 03 Dec 2014 20:18:24 GMT
Repository: camel
Updated Branches:
  refs/heads/camel-2.14.x d76f78c59 -> 03d040a2b


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/03d040a2
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/03d040a2
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/03d040a2

Branch: refs/heads/camel-2.14.x
Commit: 03d040a2bdeaf6b524045db0dfcb01aaab1654d3
Parents: d76f78c
Author: Claus Ibsen <davsclaus@apache.org>
Authored: Wed Dec 3 21:02:12 2014 +0100
Committer: Claus Ibsen <davsclaus@apache.org>
Committed: Wed Dec 3 21:02:27 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/03d040a2/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.");


Mime
View raw message