Skip to content

armgit / core

Public Imported from GitHub
0

100% open-source IoT Platform - Integrate your devices, add intelligence, build custom apps

Jackson config updates (added support for JSR-310 date time types and JDK8 parameter names)

Rich Turnerfe068e5078bb
diff --git a/container/build.gradle b/container/build.gradle
index 89fa5b64e..4e2549e65 100644
--- a/container/build.gradle
+++ b/container/build.gradle
@@ -18,6 +18,8 @@ dependencies {
compile "com.fasterxml.jackson.jaxrs:jackson-jaxrs-json-provider:$jacksonVersion"
compile "com.fasterxml.jackson.datatype:jackson-datatype-jdk8:$jacksonVersion"
+ compile "com.fasterxml.jackson.datatype:jackson-datatype-jsr310:$jacksonVersion"
+ compile "com.fasterxml.jackson.module:jackson-module-parameter-names:$jacksonVersion"
compile "io.undertow:undertow-servlet:$undertowVersion"
compile "io.undertow:undertow-websockets-jsr:$undertowVersion"
diff --git a/container/src/main/java/org/openremote/container/Container.java b/container/src/main/java/org/openremote/container/Container.java
index 7f2ad6627..7c0ac0a41 100644
--- a/container/src/main/java/org/openremote/container/Container.java
+++ b/container/src/main/java/org/openremote/container/Container.java
@@ -20,12 +20,15 @@
package org.openremote.container;
import com.fasterxml.jackson.annotation.JsonAutoDetect;
+import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonInclude;
import com.fasterxml.jackson.annotation.PropertyAccessor;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.datatype.jdk8.Jdk8Module;
+import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
+import com.fasterxml.jackson.module.paramnames.ParameterNamesModule;
import org.openremote.container.concurrent.ContainerThreads;
import org.openremote.model.ModelModule;
import org.openremote.container.util.LogUtil;
@@ -67,12 +70,15 @@ public class Container {
.setSerializationInclusion(JsonInclude.Include.NON_NULL)
.configure(SerializationFeature.WRITE_NULL_MAP_VALUES, false)
.configure(SerializationFeature.WRITE_EMPTY_JSON_ARRAYS, false)
+ .configure(SerializationFeature.WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS, false)
.disable(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES)
.setVisibility(PropertyAccessor.ALL, JsonAutoDetect.Visibility.NONE)
.setVisibility(PropertyAccessor.FIELD, JsonAutoDetect.Visibility.ANY)
.setVisibility(PropertyAccessor.CREATOR, JsonAutoDetect.Visibility.ANY)
.registerModule(new ModelModule())
- .registerModule(new Jdk8Module());
+ .registerModule(new Jdk8Module())
+ .registerModule(new JavaTimeModule())
+ .registerModule(new ParameterNamesModule(JsonCreator.Mode.PROPERTIES));
protected final Map<String, String> config = new HashMap<>();
protected final boolean devMode;
diff --git a/gradle.properties b/gradle.properties
index b1ff068cf..769cf998e 100644
--- a/gradle.properties
+++ b/gradle.properties
@@ -19,7 +19,7 @@ elementoCoreVersion = 0.7.0
elemental2Version = 1.0.0-RC1
jsinteropBaseVersion = 1.0.0-RC1
gwtJacksonVersion = 0.15.4
-jacksonVersion = 2.9.6
+jacksonVersion = 2.10.0
groovyVersion = 2.4.13
groovySandboxVersion = 1.15
sqliteVersion = 3.20.0
diff --git a/model/build.gradle b/model/build.gradle
index 9af2d278d..1f1685ee9 100644
--- a/model/build.gradle
+++ b/model/build.gradle
@@ -1,9 +1,11 @@
apply plugin: "java"
+compileJava.options.compilerArgs.add '-parameters'
+compileTestJava.options.compilerArgs.add '-parameters'
+
dependencies {
compile("com.google.gwt.inject:gin:$ginVersion")
- compile "com.fasterxml.jackson.core:jackson-annotations:$jacksonVersion"
compile "com.fasterxml.jackson.core:jackson-databind:$jacksonVersion"
compile("com.google.gwt:gwt-user:$gwtVersion") {
exclude group: "javax.servlet"