added basic java.time support

This commit is contained in:
Brian Long 2021-12-21 17:12:33 -05:00
parent 23c76c4bcf
commit 2c4f4f7285
3 changed files with 34 additions and 1 deletions

View File

@ -34,6 +34,11 @@
<artifactId>jackson-jaxrs-json-provider</artifactId>
<version>2.12.2</version>
</dependency>
<dependency>
<groupId>com.fasterxml.jackson.datatype</groupId>
<artifactId>jackson-datatype-jsr310</artifactId>
<version>2.12.2</version>
</dependency>
<dependency>
<groupId>org.slf4j</groupId>
<artifactId>slf4j-api</artifactId>

View File

@ -3,7 +3,10 @@ package com.inteligr8.rs;
import javax.ws.rs.client.ClientBuilder;
import javax.ws.rs.client.WebTarget;
import com.fasterxml.jackson.databind.DeserializationFeature;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
/**
* A class that provides pre-configured JAX-RS Client &amp; WebTarget objects.
@ -26,8 +29,15 @@ public abstract class Client {
* @return A pre-configured JAX-RS client (no URL) with the specified authorization.
*/
public javax.ws.rs.client.Client getClient(AuthorizationFilter authFilter) {
JacksonJsonProvider provider = new JacksonJaxbJsonProvider();
if (this.getConfig().isWrapRootValueEnabled())
provider.enable(SerializationFeature.WRAP_ROOT_VALUE);
if (this.getConfig().isUnwrapRootValueEnabled())
provider.enable(DeserializationFeature.UNWRAP_ROOT_VALUE);
ClientBuilder clientBuilder = ClientBuilder.newBuilder()
.register(new JacksonJaxbJsonProvider());
.register(provider);
if (authFilter == null)
authFilter = this.getConfig().createAuthorizationFilter();

View File

@ -99,6 +99,24 @@ public interface ClientConfiguration {
return null;
}
/**
* @return true to enable Jackson UNWRAP_ROOT_VALUE feature; false otherwise.
*/
default boolean isUnwrapRootValueEnabled() {
return false;
}
/**
* @return true to enable Jackson WRAP_ROOT_VALUE feature; false otherwise.
*/
default boolean isWrapRootValueEnabled() {
return false;
}
/**
* This method creates an authorization filter based on the configuration
* available. A configuration element is considered to not be available