From 9e43e5a72b77ba4701dfd320bf6cefaffaaa3823 Mon Sep 17 00:00:00 2001 From: Jim Hahn Date: Fri, 22 Feb 2019 16:30:07 -0500 Subject: Log which gson style is being used Different gson providers may be used for REST APIs. Updated the code to identify which was being used. Change-Id: I8ffbda7409142ec728e217a87c9bcba3c34b814b Issue-ID: POLICY-1428 Signed-off-by: Jim Hahn --- .../java/org/onap/policy/common/gson/GsonMessageBodyHandler.java | 6 ++++++ gson/src/main/java/org/onap/policy/common/gson/JacksonHandler.java | 4 ++-- 2 files changed, 8 insertions(+), 2 deletions(-) (limited to 'gson/src') diff --git a/gson/src/main/java/org/onap/policy/common/gson/GsonMessageBodyHandler.java b/gson/src/main/java/org/onap/policy/common/gson/GsonMessageBodyHandler.java index 6906696f..fc8e23ef 100644 --- a/gson/src/main/java/org/onap/policy/common/gson/GsonMessageBodyHandler.java +++ b/gson/src/main/java/org/onap/policy/common/gson/GsonMessageBodyHandler.java @@ -36,6 +36,8 @@ import javax.ws.rs.core.MultivaluedMap; import javax.ws.rs.ext.MessageBodyReader; import javax.ws.rs.ext.MessageBodyWriter; import javax.ws.rs.ext.Provider; +import org.slf4j.Logger; +import org.slf4j.LoggerFactory; /** * Provider that serializes and de-serializes JSON via gson. @@ -45,6 +47,8 @@ import javax.ws.rs.ext.Provider; @Produces(MediaType.WILDCARD) public class GsonMessageBodyHandler implements MessageBodyReader, MessageBodyWriter { + public static final Logger logger = LoggerFactory.getLogger(GsonMessageBodyHandler.class); + /** * Object to be used to serialize and de-serialize. */ @@ -55,6 +59,8 @@ public class GsonMessageBodyHandler implements MessageBodyReader, Messag */ public GsonMessageBodyHandler() { this(new Gson()); + + logger.info("Using GSON for REST calls"); } /** diff --git a/gson/src/main/java/org/onap/policy/common/gson/JacksonHandler.java b/gson/src/main/java/org/onap/policy/common/gson/JacksonHandler.java index a1c54afa..b2648b0b 100644 --- a/gson/src/main/java/org/onap/policy/common/gson/JacksonHandler.java +++ b/gson/src/main/java/org/onap/policy/common/gson/JacksonHandler.java @@ -37,6 +37,8 @@ public class JacksonHandler extends GsonMessageBodyHandler { */ public JacksonHandler() { this(new GsonBuilder()); + + logger.info("Using GSON with Jackson behaviors for REST calls"); } /** @@ -49,8 +51,6 @@ public class JacksonHandler extends GsonMessageBodyHandler { .registerTypeAdapterFactory(new JacksonMethodAdapterFactory()) .setExclusionStrategies(new JacksonExclusionStrategy()) .create()); - - logger.info("Using GSON for REST calls"); } } -- cgit 1.2.3-korg