falcon-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From ajayyad...@apache.org
Subject falcon git commit: FALCON-1317 Inconsistent JSON serialization. Contributed by Ajay Yadava
Date Wed, 22 Jul 2015 08:21:31 GMT
Repository: falcon
Updated Branches:
  refs/heads/master 281e9e34b -> 0ff87bce8


FALCON-1317 Inconsistent JSON serialization. Contributed by Ajay Yadava


Project: http://git-wip-us.apache.org/repos/asf/falcon/repo
Commit: http://git-wip-us.apache.org/repos/asf/falcon/commit/0ff87bce
Tree: http://git-wip-us.apache.org/repos/asf/falcon/tree/0ff87bce
Diff: http://git-wip-us.apache.org/repos/asf/falcon/diff/0ff87bce

Branch: refs/heads/master
Commit: 0ff87bce85e1be6c36b18b7a435e5c30dbda6c90
Parents: 281e9e3
Author: Ajay Yadava <ajaynsit@gmail.com>
Authored: Wed Jul 22 12:33:16 2015 +0530
Committer: Ajay Yadava <ajaynsit@gmail.com>
Committed: Wed Jul 22 12:33:16 2015 +0530

----------------------------------------------------------------------
 CHANGES.txt                                     |  2 +
 hadoop-dependencies/pom.xml                     | 14 +++++++
 pom.xml                                         |  4 +-
 .../resource/provider/JAXBContextResolver.java  | 44 ++++++--------------
 prism/src/main/webapp/WEB-INF/web.xml           |  5 +++
 .../src/main/webapp/WEB-INF/distributed/web.xml |  4 ++
 webapp/src/main/webapp/WEB-INF/embedded/web.xml |  4 ++
 7 files changed, 43 insertions(+), 34 deletions(-)
----------------------------------------------------------------------


http://git-wip-us.apache.org/repos/asf/falcon/blob/0ff87bce/CHANGES.txt
----------------------------------------------------------------------
diff --git a/CHANGES.txt b/CHANGES.txt
index 0c8e31a..58a26ae 100755
--- a/CHANGES.txt
+++ b/CHANGES.txt
@@ -9,6 +9,8 @@ Trunk (Unreleased)
     FALCON-796 Enable users to triage data processing issues through falcon (Ajay Yadava)
     
   IMPROVEMENTS
+    FALCON-1317 Inconsistent JSON serialization(Ajay Yadava)
+
     FALCON-1320 Adding equals() and hashCode() method in LineageGraphResult.Edge(Pragya Mittal
via Ajay Yadava)
 
     FALCON-1139 Validation issues in Falcon UI(Pallavi Rao via Ajay Yadava)

http://git-wip-us.apache.org/repos/asf/falcon/blob/0ff87bce/hadoop-dependencies/pom.xml
----------------------------------------------------------------------
diff --git a/hadoop-dependencies/pom.xml b/hadoop-dependencies/pom.xml
index b647077..653ac95 100644
--- a/hadoop-dependencies/pom.xml
+++ b/hadoop-dependencies/pom.xml
@@ -36,6 +36,20 @@
             <activation>
                 <activeByDefault>true</activeByDefault>
             </activation>
+            <dependencyManagement>
+                <dependencies>
+                    <dependency>
+                        <groupId>org.codehaus.jackson</groupId>
+                        <artifactId>jackson-core-asl</artifactId>
+                        <version>1.8.3</version>
+                    </dependency>
+                    <dependency>
+                        <groupId>org.codehaus.jackson</groupId>
+                        <artifactId>jackson-mapper-asl</artifactId>
+                        <version>1.8.3</version>
+                    </dependency>
+                </dependencies>
+            </dependencyManagement>
             <dependencies>
                 <dependency>
                     <groupId>org.apache.hadoop</groupId>

http://git-wip-us.apache.org/repos/asf/falcon/blob/0ff87bce/pom.xml
----------------------------------------------------------------------
diff --git a/pom.xml b/pom.xml
index 31997e8..2900bc4 100644
--- a/pom.xml
+++ b/pom.xml
@@ -502,13 +502,13 @@
             <dependency>
                 <groupId>org.codehaus.jackson</groupId>
                 <artifactId>jackson-core-asl</artifactId>
-                <version>1.5.2</version>
+                <version>1.8.3</version>
             </dependency>
 
             <dependency>
                 <groupId>org.codehaus.jackson</groupId>
                 <artifactId>jackson-mapper-asl</artifactId>
-                <version>1.5.2</version>
+                <version>1.8.3</version>
             </dependency>
 
             <dependency>

http://git-wip-us.apache.org/repos/asf/falcon/blob/0ff87bce/prism/src/main/java/org/apache/falcon/resource/provider/JAXBContextResolver.java
----------------------------------------------------------------------
diff --git a/prism/src/main/java/org/apache/falcon/resource/provider/JAXBContextResolver.java
b/prism/src/main/java/org/apache/falcon/resource/provider/JAXBContextResolver.java
index 4469e02..ee5e132 100644
--- a/prism/src/main/java/org/apache/falcon/resource/provider/JAXBContextResolver.java
+++ b/prism/src/main/java/org/apache/falcon/resource/provider/JAXBContextResolver.java
@@ -18,54 +18,34 @@
 
 package org.apache.falcon.resource.provider;
 
-import com.sun.jersey.api.json.JSONConfiguration;
-import com.sun.jersey.api.json.JSONJAXBContext;
-import org.apache.falcon.resource.APIResult;
-import org.apache.falcon.resource.InstancesResult;
-import org.apache.falcon.resource.InstancesSummaryResult;
-import org.apache.falcon.resource.InstancesSummaryResult.InstanceSummary;
+import org.codehaus.jackson.map.ObjectMapper;
 
 import javax.ws.rs.Produces;
 import javax.ws.rs.core.MediaType;
 import javax.ws.rs.ext.ContextResolver;
 import javax.ws.rs.ext.Provider;
-import javax.xml.bind.JAXBContext;
-import javax.xml.bind.JAXBException;
 
 /**
  * An implementation of Context Resolver for JAXB.
  */
 @Provider
 @Produces(MediaType.APPLICATION_JSON)
-public class JAXBContextResolver implements ContextResolver<JAXBContext> {
+public class JAXBContextResolver implements ContextResolver<ObjectMapper> {
 
-    private static JAXBContext context;
-    private static Class<?>[] types = {
-        InstancesResult.class,
-        APIResult.class,
-        InstancesResult.Instance.class,
-        InstancesResult.WorkflowStatus.class,
-        InstancesSummaryResult.class,
-        InstanceSummary.class,
-    };
+    private final ObjectMapper defaultObjectMapper;
 
-    static {
-        try {
-            context = new JSONJAXBContext(JSONConfiguration.natural().build(), types);
-        } catch (JAXBException e) {
-            throw new RuntimeException(e);
-        }
-    }
 
     public JAXBContextResolver() {
+        defaultObjectMapper = createDefaultMapper();
+    }
+
+    private static ObjectMapper createDefaultMapper() {
+        final ObjectMapper result = new ObjectMapper();
+        // you can customize it here e.g. result.enable(SerializationFeature.INDENT_OUTPUT);
+        return result;
     }
 
-    public JAXBContext getContext(Class<?> objectType) {
-        for (Class<?> type : types) {
-            if (type == objectType) {
-                return context;
-            }
-        }
-        return null;
+    public  ObjectMapper getContext(Class<?> objectType) {
+        return defaultObjectMapper;
     }
 }

http://git-wip-us.apache.org/repos/asf/falcon/blob/0ff87bce/prism/src/main/webapp/WEB-INF/web.xml
----------------------------------------------------------------------
diff --git a/prism/src/main/webapp/WEB-INF/web.xml b/prism/src/main/webapp/WEB-INF/web.xml
index 551bf56..4719834 100644
--- a/prism/src/main/webapp/WEB-INF/web.xml
+++ b/prism/src/main/webapp/WEB-INF/web.xml
@@ -72,6 +72,11 @@
                 org.apache.falcon.resource.admin,org.apache.falcon.resource.provider,org.apache.falcon.resource.proxy,org.apache.falcon.resource.metadata
             </param-value>
         </init-param>
+        <init-param>
+            <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
+            <param-value>true</param-value>
+        </init-param>
+
         <load-on-startup>1</load-on-startup>
     </servlet>
 

http://git-wip-us.apache.org/repos/asf/falcon/blob/0ff87bce/webapp/src/main/webapp/WEB-INF/distributed/web.xml
----------------------------------------------------------------------
diff --git a/webapp/src/main/webapp/WEB-INF/distributed/web.xml b/webapp/src/main/webapp/WEB-INF/distributed/web.xml
index 31d78a2..619fd2f 100644
--- a/webapp/src/main/webapp/WEB-INF/distributed/web.xml
+++ b/webapp/src/main/webapp/WEB-INF/distributed/web.xml
@@ -108,6 +108,10 @@
                 org.apache.falcon.resource.provider.JAXBContextResolver,org.apache.falcon.resource.ConfigSyncService
             </param-value>
         </init-param>
+        <init-param>
+            <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
+            <param-value>true</param-value>
+        </init-param>
         <load-on-startup>1</load-on-startup>
     </servlet>
 

http://git-wip-us.apache.org/repos/asf/falcon/blob/0ff87bce/webapp/src/main/webapp/WEB-INF/embedded/web.xml
----------------------------------------------------------------------
diff --git a/webapp/src/main/webapp/WEB-INF/embedded/web.xml b/webapp/src/main/webapp/WEB-INF/embedded/web.xml
index fa2db39..8fccf6b 100644
--- a/webapp/src/main/webapp/WEB-INF/embedded/web.xml
+++ b/webapp/src/main/webapp/WEB-INF/embedded/web.xml
@@ -72,6 +72,10 @@
                 org.apache.falcon.resource.admin,org.apache.falcon.resource.provider,org.apache.falcon.resource.proxy,org.apache.falcon.resource.metadata
             </param-value>
         </init-param>
+        <init-param>
+            <param-name>com.sun.jersey.api.json.POJOMappingFeature</param-name>
+            <param-value>true</param-value>
+        </init-param>
         <load-on-startup>1</load-on-startup>
     </servlet>
 


Mime
View raw message