You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@camel.apache.org by ni...@apache.org on 2014/09/26 09:25:00 UTC

git commit: CAMEL-7858 Update the JsonDataFormat module for the new added option

Repository: camel
Updated Branches:
  refs/heads/master 53792cc1c -> 90981bc4f


CAMEL-7858 Update the JsonDataFormat module for the new added option


Project: http://git-wip-us.apache.org/repos/asf/camel/repo
Commit: http://git-wip-us.apache.org/repos/asf/camel/commit/90981bc4
Tree: http://git-wip-us.apache.org/repos/asf/camel/tree/90981bc4
Diff: http://git-wip-us.apache.org/repos/asf/camel/diff/90981bc4

Branch: refs/heads/master
Commit: 90981bc4f1ab814d85112985ff8ce596182d8438
Parents: 53792cc
Author: Willem Jiang <wi...@gmail.com>
Authored: Fri Sep 26 15:24:41 2014 +0800
Committer: Willem Jiang <wi...@gmail.com>
Committed: Fri Sep 26 15:24:41 2014 +0800

----------------------------------------------------------------------
 .../camel/model/dataformat/JsonDataFormat.java  |  5 +++++
 .../component/jackson/JacksonDataFormat.java    | 23 +++++++++++++++-----
 2 files changed, 22 insertions(+), 6 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/camel/blob/90981bc4/camel-core/src/main/java/org/apache/camel/model/dataformat/JsonDataFormat.java
----------------------------------------------------------------------
diff --git a/camel-core/src/main/java/org/apache/camel/model/dataformat/JsonDataFormat.java b/camel-core/src/main/java/org/apache/camel/model/dataformat/JsonDataFormat.java
index 5869d12..17e551f 100644
--- a/camel-core/src/main/java/org/apache/camel/model/dataformat/JsonDataFormat.java
+++ b/camel-core/src/main/java/org/apache/camel/model/dataformat/JsonDataFormat.java
@@ -56,6 +56,8 @@ public class JsonDataFormat extends DataFormatDefinition {
     private Class<?> collectionType;
     @XmlAttribute
     private Boolean useList;
+    @XmlAttribute
+    private Boolean enableJaxbAnnotationModule;
 
     public JsonDataFormat() {
     }
@@ -187,6 +189,9 @@ public class JsonDataFormat extends DataFormatDefinition {
         if (useList != null) {
             setProperty(camelContext, dataFormat, "useList", useList);
         }
+        if (enableJaxbAnnotationModule != null) {
+            setProperty(camelContext, dataFormat, "enableJaxbAnnotationModule", enableJaxbAnnotationModule);
+        }
     }
 
 }

http://git-wip-us.apache.org/repos/asf/camel/blob/90981bc4/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
----------------------------------------------------------------------
diff --git a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
index e567047..c56363a 100644
--- a/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
+++ b/components/camel-jackson/src/main/java/org/apache/camel/component/jackson/JacksonDataFormat.java
@@ -46,6 +46,7 @@ public class JacksonDataFormat extends ServiceSupport implements DataFormat {
     private boolean prettyPrint;
     private boolean allowJmsType;
     private boolean useList;
+    private boolean enableJaxbAnnotationModule;
 
     /**
      * Use the default Jackson {@link ObjectMapper} and {@link Map}
@@ -89,12 +90,7 @@ public class JacksonDataFormat extends ServiceSupport implements DataFormat {
         this.objectMapper = new ObjectMapper();
         this.unmarshalType = unmarshalType;
         this.jsonView = jsonView;
-
-        if (enableJaxbAnnotationModule) {
-            // Enables JAXB processing
-            JaxbAnnotationModule module = new JaxbAnnotationModule();
-            this.objectMapper.registerModule(module);
-        }
+        this.enableJaxbAnnotationModule = enableJaxbAnnotationModule;
     }
 
     /**
@@ -203,6 +199,14 @@ public class JacksonDataFormat extends ServiceSupport implements DataFormat {
         this.useList = useList;
     }
 
+    public boolean isEnableJaxbAnnotationModule() {
+        return enableJaxbAnnotationModule;
+    }
+
+    public void setEnableJaxbAnnotationModule(boolean enableJaxbAnnotationModule) {
+        this.enableJaxbAnnotationModule = enableJaxbAnnotationModule;
+    }
+
     /**
      * Uses {@link java.util.ArrayList} when unmarshalling.
      */
@@ -229,6 +233,13 @@ public class JacksonDataFormat extends ServiceSupport implements DataFormat {
 
     @Override
     protected void doStart() throws Exception {
+        
+        if (enableJaxbAnnotationModule) {
+            // Enables JAXB processing
+            JaxbAnnotationModule module = new JaxbAnnotationModule();
+            objectMapper.registerModule(module);
+        }
+        
         if (useList) {
             setCollectionType(ArrayList.class);
         }