Browse files

Updates jackson to com.fasterxml.jackson 2.1.1

  • Loading branch information...
1 parent d607c29 commit 3a64c19b5cfed82cb68a942e148166e5ae77406a @sagemintblue sagemintblue committed Apr 3, 2013
View
12 common/pom.xml
@@ -38,12 +38,16 @@
<!-- serialization -->
<dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-core-asl</artifactId>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
</dependency>
<dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-mapper-asl</artifactId>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>
View
10 common/src/main/java/com/twitter/ambrose/model/DAGNode.java
@@ -20,11 +20,11 @@
import java.util.HashSet;
import java.util.List;
-import org.codehaus.jackson.annotate.JsonCreator;
-import org.codehaus.jackson.annotate.JsonIgnore;
-import org.codehaus.jackson.annotate.JsonProperty;
-import org.codehaus.jackson.map.annotate.JsonSerialize;
-import org.codehaus.jackson.type.TypeReference;
+import com.fasterxml.jackson.annotation.JsonCreator;
+import com.fasterxml.jackson.annotation.JsonIgnore;
+import com.fasterxml.jackson.annotation.JsonProperty;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.twitter.ambrose.util.JSONUtil;
View
3 common/src/main/java/com/twitter/ambrose/model/Event.java
@@ -16,13 +16,14 @@
package com.twitter.ambrose.model;
import com.twitter.ambrose.util.JSONUtil;
-import org.codehaus.jackson.type.TypeReference;
import java.io.IOException;
import java.util.List;
import java.util.Map;
import java.util.concurrent.atomic.AtomicInteger;
+import com.fasterxml.jackson.core.type.TypeReference;
+
/**
* Class that represents a Event of a given Type. Each one of these created will have
* a unique id that increments up for each object. eventIds will always be >= 0.
View
35 common/src/main/java/com/twitter/ambrose/util/JSONUtil.java
@@ -15,11 +15,6 @@
*/
package com.twitter.ambrose.util;
-import org.codehaus.jackson.map.DeserializationConfig;
-import org.codehaus.jackson.map.ObjectMapper;
-import org.codehaus.jackson.map.SerializationConfig;
-import org.codehaus.jackson.type.TypeReference;
-
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -29,25 +24,34 @@
import java.nio.channels.FileChannel;
import java.nio.charset.Charset;
+import com.fasterxml.jackson.core.type.TypeReference;
+import com.fasterxml.jackson.databind.DeserializationFeature;
+import com.fasterxml.jackson.databind.ObjectMapper;
+import com.fasterxml.jackson.databind.SerializationFeature;
+
+
/**
* Helper method for dealing with JSON in a common way.
*
* @author billg
*/
public class JSONUtil {
+ private static final ObjectMapper mapper = new ObjectMapper();
+ static {
+ mapper.enable(SerializationFeature.INDENT_OUTPUT);
+ mapper.disable(SerializationFeature.FAIL_ON_EMPTY_BEANS);
+ mapper.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES);
+ }
/**
* Writes object to the writer as JSON using Jackson and adds a new-line before flushing.
+ *
* @param writer the writer to write the JSON to
* @param object the object to write as JSON
* @throws IOException if the object can't be serialized as JSON or written to the writer
*/
public static void writeJson(Writer writer, Object object) throws IOException {
- ObjectMapper om = new ObjectMapper();
- om.configure(SerializationConfig.Feature.INDENT_OUTPUT, true);
- om.configure(SerializationConfig.Feature.FAIL_ON_EMPTY_BEANS, false);
-
- writer.write(om.writeValueAsString(object));
+ mapper.writeValue(writer, object);
writer.write("\n");
writer.flush();
}
@@ -57,11 +61,7 @@ public static void writeJson(String fileName, Object object) throws IOException
}
public static Object readJson(String json, TypeReference<?> type) throws IOException {
- ObjectMapper om = new ObjectMapper();
- om.getDeserializationConfig().set(DeserializationConfig.Feature.FAIL_ON_UNKNOWN_PROPERTIES, false);
-
- // not currently setting successors, only successorNames
- return om.readValue(json, type);
+ return mapper.readValue(json, type);
}
public static String readFile(String path) throws IOException {
@@ -70,11 +70,8 @@ public static String readFile(String path) throws IOException {
FileChannel fc = stream.getChannel();
MappedByteBuffer bb = fc.map(FileChannel.MapMode.READ_ONLY, 0, fc.size());
return Charset.defaultCharset().decode(bb).toString();
- }
- finally {
+ } finally {
stream.close();
}
}
-
-
}
View
18 pom.xml
@@ -65,6 +65,7 @@
<properties>
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
<slf4j.version>1.6.4</slf4j.version>
+ <fasterxml.jackson.version>2.1.1</fasterxml.jackson.version>
<apache.pig.version>0.11.0</apache.pig.version>
<apache.hadoop.version>0.22.0</apache.hadoop.version>
<mortbay.jetty.version>6.1.25</mortbay.jetty.version>
@@ -117,14 +118,19 @@
<!-- serialization -->
<dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-core-asl</artifactId>
- <version>1.8.2</version>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-core</artifactId>
+ <version>${fasterxml.jackson.version}</version>
</dependency>
<dependency>
- <groupId>org.codehaus.jackson</groupId>
- <artifactId>jackson-mapper-asl</artifactId>
- <version>1.8.2</version>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-annotations</artifactId>
+ <version>${fasterxml.jackson.version}</version>
+ </dependency>
+ <dependency>
+ <groupId>com.fasterxml.jackson.core</groupId>
+ <artifactId>jackson-databind</artifactId>
+ <version>${fasterxml.jackson.version}</version>
</dependency>
<dependency>
<groupId>com.thoughtworks.xstream</groupId>

0 comments on commit 3a64c19

Please sign in to comment.