From d8efa60ab727fbbd378308be1539f8bde1bf6a4b Mon Sep 17 00:00:00 2001 From: Calle Wilund Date: Wed, 24 Jul 2019 14:28:38 +0000 Subject: [PATCH] APIClient: Add jackson JSON serializer support to client object Allows java ws to deserialize json objects directly. --- .../src/main/java/com/scylladb/jmx/api/APIClient.java | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/scylla-apiclient/src/main/java/com/scylladb/jmx/api/APIClient.java b/scylla-apiclient/src/main/java/com/scylladb/jmx/api/APIClient.java index 86ae4f4..dc6903e 100644 --- a/scylla-apiclient/src/main/java/com/scylladb/jmx/api/APIClient.java +++ b/scylla-apiclient/src/main/java/com/scylladb/jmx/api/APIClient.java @@ -38,6 +38,7 @@ import javax.ws.rs.core.Response; import org.glassfish.jersey.client.ClientConfig; +import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider; import com.scylladb.jmx.utils.SnapshotDetailsTabularData; public class APIClient { @@ -78,9 +79,12 @@ public class APIClient { private static final Logger logger = Logger.getLogger(APIClient.class.getName()); private final APIConfig config; + private final ClientConfig clientConfig; public APIClient(APIConfig config) { this.config = config; + this.clientConfig = new ClientConfig(); + clientConfig.register(new JacksonJaxbJsonProvider()); } private String getBaseUrl() { @@ -88,7 +92,7 @@ public class APIClient { } public Invocation.Builder get(String path, MultivaluedMap queryParams) { - Client client = ClientBuilder.newClient(new ClientConfig()); + Client client = ClientBuilder.newClient(clientConfig); WebTarget webTarget = client.target(getBaseUrl()).path(path); if (queryParams != null) { for (Entry> qp : queryParams.entrySet()) {