use of com.fasterxml.jackson.module.kotlin.KotlinModule in project kork by spinnaker.
the class Front50PluginsConfiguration method pluginFront50Service.
@Bean
public static Front50Service pluginFront50Service(Environment environment, PluginOkHttpClientProvider pluginsOkHttpClientProvider, Map<String, PluginRepositoryProperties> pluginRepositoriesConfig) {
PluginRepositoryProperties front50RepositoryProps = pluginRepositoriesConfig.get(PluginsConfigurationProperties.FRONT5O_REPOSITORY);
URL front50Url = getFront50Url(environment, front50RepositoryProps);
KotlinModule kotlinModule = new KotlinModule.Builder().build();
ObjectMapper objectMapper = new ObjectMapper().registerModule(kotlinModule).configure(DeserializationFeature.FAIL_ON_UNKNOWN_PROPERTIES, false).configure(SerializationFeature.INDENT_OUTPUT, true).setSerializationInclusion(JsonInclude.Include.NON_NULL);
return new Retrofit.Builder().addConverterFactory(JacksonConverterFactory.create(objectMapper)).baseUrl(front50Url).client(pluginsOkHttpClientProvider.getOkHttpClient()).build().create(Front50Service.class);
}
use of com.fasterxml.jackson.module.kotlin.KotlinModule in project ontrack by nemerosa.
the class ObjectMapperFactory method create.
public static ObjectMapper create() {
ObjectMapper mapper = new ObjectMapper();
// Support for JDK 8 times
jdkTime(mapper);
// Support for Kotlin
mapper.registerModule(new KotlinModule());
// OK
return mapper;
}
use of com.fasterxml.jackson.module.kotlin.KotlinModule in project kork by spinnaker.
the class HttpClientSdkConfiguration method httpClientSdkFactory.
@Bean
public static SdkFactory httpClientSdkFactory(List<OkHttp3ClientFactory> okHttpClientFactories, Environment environment, Provider<Registry> registry) {
OkHttpClientConfigurationProperties okHttpClientProperties = Binder.get(environment).bind("ok-http-client", Bindable.of(OkHttpClientConfigurationProperties.class)).orElse(new OkHttpClientConfigurationProperties());
OkHttpMetricsInterceptorProperties okHttpMetricsInterceptorProperties = Binder.get(environment).bind("ok-http-client.interceptor", Bindable.of(OkHttpMetricsInterceptorProperties.class)).orElse(new OkHttpMetricsInterceptorProperties());
List<OkHttp3ClientFactory> factories = new ArrayList<>(okHttpClientFactories);
OkHttp3MetricsInterceptor okHttp3MetricsInterceptor = new OkHttp3MetricsInterceptor(registry, okHttpMetricsInterceptorProperties);
factories.add(new DefaultOkHttp3ClientFactory(okHttp3MetricsInterceptor));
OkHttp3ClientConfiguration config = new OkHttp3ClientConfiguration(okHttpClientProperties, okHttp3MetricsInterceptor);
KotlinModule kotlinModule = new KotlinModule.Builder().build();
// TODO(rz): It'd be nice to make this customizable, but I'm not sure how to do that without
// bringing Jackson into the Plugin SDK (quite undesirable).
ObjectMapper objectMapper = new ObjectMapper();
objectMapper.registerModule(new Jdk8Module());
objectMapper.registerModule(new JavaTimeModule());
objectMapper.registerModule(kotlinModule);
objectMapper.disable(READ_DATE_TIMESTAMPS_AS_NANOSECONDS);
objectMapper.disable(WRITE_DATE_TIMESTAMPS_AS_NANOSECONDS);
objectMapper.disable(FAIL_ON_UNKNOWN_PROPERTIES);
objectMapper.disable(FAIL_ON_EMPTY_BEANS);
objectMapper.setSerializationInclusion(NON_NULL);
return new HttpClientSdkFactory(new CompositeOkHttpClientFactory(factories), environment, objectMapper, config);
}
Aggregations