Merge branch 'develop' into stable
This commit is contained in:
commit
b64c408029
@ -22,7 +22,6 @@ import com.fasterxml.jackson.databind.ObjectMapper;
|
|||||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||||
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
||||||
import com.fasterxml.jackson.jaxrs.json.JacksonJsonProvider;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A class that provides pre-configured JAX-RS Client & WebTarget objects.
|
* A class that provides pre-configured JAX-RS Client & WebTarget objects.
|
||||||
@ -70,8 +69,13 @@ public abstract class Client {
|
|||||||
public final javax.ws.rs.client.Client buildClient(AuthorizationFilter authFilter) {
|
public final javax.ws.rs.client.Client buildClient(AuthorizationFilter authFilter) {
|
||||||
ObjectMapper om = new ObjectMapper();
|
ObjectMapper om = new ObjectMapper();
|
||||||
om.registerModules(new JavaTimeModule());
|
om.registerModules(new JavaTimeModule());
|
||||||
|
this.getConfig().configureJacksonMapper(om);
|
||||||
|
|
||||||
JacksonJsonProvider provider = new JacksonJaxbJsonProvider(om, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS);
|
JacksonJaxbJsonProvider provider = new JacksonJaxbJsonProvider(om, JacksonJaxbJsonProvider.DEFAULT_ANNOTATIONS);
|
||||||
|
provider.enable(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_AS_NULL);
|
||||||
|
provider.disable(DeserializationFeature.READ_UNKNOWN_ENUM_VALUES_USING_DEFAULT_VALUE);
|
||||||
|
|
||||||
|
this.getConfig().configureJacksonProvider(provider);
|
||||||
|
|
||||||
if (this.getConfig().isWrapRootValueEnabled())
|
if (this.getConfig().isWrapRootValueEnabled())
|
||||||
provider.enable(SerializationFeature.WRAP_ROOT_VALUE);
|
provider.enable(SerializationFeature.WRAP_ROOT_VALUE);
|
||||||
@ -88,6 +92,8 @@ public abstract class Client {
|
|||||||
clientBuilder.register(authFilter);
|
clientBuilder.register(authFilter);
|
||||||
this.buildClient(clientBuilder);
|
this.buildClient(clientBuilder);
|
||||||
|
|
||||||
|
this.getConfig().configureClient(clientBuilder);
|
||||||
|
|
||||||
return clientBuilder.build();
|
return clientBuilder.build();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -16,6 +16,11 @@ package com.inteligr8.rs;
|
|||||||
|
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
|
|
||||||
|
import javax.ws.rs.client.ClientBuilder;
|
||||||
|
|
||||||
|
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||||
|
import com.fasterxml.jackson.jaxrs.json.JacksonJaxbJsonProvider;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface defines the configurable parameters of the clients; primarily
|
* This interface defines the configurable parameters of the clients; primarily
|
||||||
* their default authentication and authorization.
|
* their default authentication and authorization.
|
||||||
@ -129,6 +134,18 @@ public interface ClientConfiguration {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param mapper A Jackson object mapper to configure.
|
||||||
|
*/
|
||||||
|
default void configureJacksonMapper(ObjectMapper mapper) {
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @param provider A Jackson JAX-RS provider to configure.
|
||||||
|
*/
|
||||||
|
default void configureJacksonProvider(JacksonJaxbJsonProvider provider) {
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -170,4 +187,12 @@ public interface ClientConfiguration {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A Jackson provider, logging filter, and authentication filter are already registered.
|
||||||
|
*
|
||||||
|
* @param clientBuilder A JAX-RS client builder to configure.
|
||||||
|
*/
|
||||||
|
default void configureClient(ClientBuilder clientBuilder) {
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user