Compare commits
38 Commits
v2.0.2-jer
...
v2.0.4
Author | SHA1 | Date | |
---|---|---|---|
cd278bcc81 | |||
b64c408029 | |||
9a9a958913 | |||
37e8b63179 | |||
255a9c8e85 | |||
ec6e7cc15d | |||
2451c634b7 | |||
bcb7d4a7ed | |||
ed00346e71 | |||
c001576b65 | |||
6cb7afd9f1 | |||
5df5388bd2 | |||
5cda622082 | |||
e1191abaaa | |||
67ea4b72b3 | |||
a574154c20 | |||
b1b19d8cb0 | |||
160766e0ef | |||
e167ac43cc | |||
a28fc13161 | |||
52c7e3cf6d | |||
bd7413bb48 | |||
75c518801f | |||
b3bc04467b | |||
88c8657a34 | |||
28b2478a08 | |||
dc63abc272 | |||
dd5d0f504a | |||
34d03a91e5 | |||
2584b8d668 | |||
a756b05f6c | |||
853b4e66cf | |||
f2032df0f3 | |||
8d3f4559bd | |||
3f476bba5c | |||
6292dde23b | |||
659f71c72c | |||
52f77dddbb |
2
pom.xml
2
pom.xml
@@ -6,7 +6,7 @@
|
||||
|
||||
<groupId>com.inteligr8</groupId>
|
||||
<artifactId>common-rest-client</artifactId>
|
||||
<version>2.0-SNAPSHOT</version>
|
||||
<version>2.0.4</version>
|
||||
<packaging>jar</packaging>
|
||||
|
||||
<name>ReST API Client for Java</name>
|
||||
|
@@ -18,9 +18,10 @@ import javax.ws.rs.client.ClientBuilder;
|
||||
import javax.ws.rs.client.WebTarget;
|
||||
|
||||
import com.fasterxml.jackson.databind.DeserializationFeature;
|
||||
import com.fasterxml.jackson.databind.ObjectMapper;
|
||||
import com.fasterxml.jackson.databind.SerializationFeature;
|
||||
import com.fasterxml.jackson.datatype.jsr310.JavaTimeModule;
|
||||
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.
|
||||
@@ -66,7 +67,15 @@ public abstract class Client {
|
||||
* @return A pre-configured JAX-RS client (no URL) with the specified authorization.
|
||||
*/
|
||||
public final javax.ws.rs.client.Client buildClient(AuthorizationFilter authFilter) {
|
||||
JacksonJsonProvider provider = new JacksonJaxbJsonProvider();
|
||||
ObjectMapper om = new ObjectMapper();
|
||||
om.registerModules(new JavaTimeModule());
|
||||
this.getConfig().configureJacksonMapper(om);
|
||||
|
||||
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())
|
||||
provider.enable(SerializationFeature.WRAP_ROOT_VALUE);
|
||||
@@ -83,6 +92,8 @@ public abstract class Client {
|
||||
clientBuilder.register(authFilter);
|
||||
this.buildClient(clientBuilder);
|
||||
|
||||
this.getConfig().configureClient(clientBuilder);
|
||||
|
||||
return clientBuilder.build();
|
||||
}
|
||||
|
||||
|
@@ -16,6 +16,11 @@ package com.inteligr8.rs;
|
||||
|
||||
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
|
||||
* their default authentication and authorization.
|
||||
@@ -129,6 +134,18 @@ public interface ClientConfiguration {
|
||||
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) {
|
||||
}
|
||||
|
||||
}
|
||||
|
Reference in New Issue
Block a user