gradle config correction

This commit is contained in:
Michal Zeman
2020-07-26 10:23:14 +02:00
parent 090975ec26
commit e26a0f962a
6 changed files with 38 additions and 39 deletions

View File

@@ -2,7 +2,7 @@ package com.mz.reactor.ddd.reactorddd.application;
import com.fasterxml.jackson.databind.ObjectMapper;
import com.fasterxml.jackson.databind.SerializationFeature;
import com.mz.reactor.ddd.common.components.http.HttpHandlerFunctions;
import com.mz.reactor.ddd.common.components.http.HttpHandlers;
import com.mz.reactor.ddd.reactorddd.account.http.AccountHandler;
import com.mz.reactor.ddd.reactorddd.transaction.api.TransactionHandler;
import org.apache.commons.logging.Log;
@@ -42,7 +42,7 @@ public class BankAccountAppConfiguration {
.contentType(MediaType.APPLICATION_JSON_UTF8)
.body(Mono.just("Tick"), String.class))
.onError(Throwable.class,
(throwable, serverRequest) -> HttpHandlerFunctions.FN.onError(throwable, serverRequest, error -> log.error("Error: ", error)))
(throwable, serverRequest) -> HttpHandlers.onError(throwable, serverRequest, error -> log.error("Error: ", error)))
.build();
}

View File

@@ -1,32 +1,10 @@
buildscript {
ext {
springBootVersion = '2.1.7.RELEASE'
springDependencyMavagementVersion = '1.0.8.RELEASE'
reactorVersion = '3.3.0.RELEASE'
immutablesVersion = '2.7.5'
jacksonVersion = '2.10.1'
}
repositories {
mavenCentral()
}
dependencies {
classpath "org.springframework.boot:spring-boot-gradle-plugin:$springBootVersion"
}
}
plugins {
id 'io.spring.dependency-management' version "$springDependencyMavagementVersion"
id 'org.springframework.boot' version "${springframeworkBootVersion}" apply false
id 'io.spring.dependency-management' version "${springDependencyManagementVersion}"
id 'java'
id 'java-library'
}
allprojects {
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'io.spring.dependency-management'
repositories {
jcenter()
@@ -38,23 +16,29 @@ allprojects {
maven { url 'https://repo.spring.io/snapshot' }
}
dependencyManagement {
imports { mavenBom("org.springframework.boot:spring-boot-dependencies:${springBootVersion}") }
}
}
subprojects {
apply plugin: 'java'
apply plugin: 'java-library'
apply plugin: 'io.spring.dependency-management'
group = 'com.mz.reactor.ddd'
version = '0.0.1-SNAPSHOT'
sourceCompatibility = '11'
dependencyManagement {
imports {
mavenBom org.springframework.boot.gradle.plugin.SpringBootPlugin.BOM_COORDINATES
}
}
dependencies {
implementation group: 'com.google.guava', name: 'guava', version: '28.1-jre'
implementation 'io.projectreactor.tools:blockhound:1.0.0.RC1'
annotationProcessor "org.immutables:value:$immutablesVersion"
implementation "org.immutables:value:$immutablesVersion"
annotationProcessor "org.immutables:value:${immutablesVersion}"
implementation "org.immutables:value:${immutablesVersion}"
implementation "com.fasterxml.jackson.core:jackson-core"
implementation "com.fasterxml.jackson.core:jackson-databind"
implementation "com.fasterxml.jackson.datatype:jackson-datatype-jdk8"

View File

@@ -8,6 +8,7 @@ import org.springframework.web.reactive.function.server.ServerResponse;
import reactor.core.publisher.Mono;
import reactor.core.scheduler.Scheduler;
import static com.mz.reactor.ddd.common.components.http.HttpHandlers.deserializeJsonString;
import static org.springframework.web.reactive.function.BodyInserters.fromObject;
public interface HttpHandler {
@@ -18,12 +19,12 @@ public interface HttpHandler {
default <T> Mono<T> bodyToMono(ServerRequest request, Class<T> clazz, Scheduler scheduler) {
return request.bodyToMono(String.class)
.flatMap(HttpHandlerFunctions.FN.deserializeJsonString(clazz, scheduler, mapper()));
.flatMap(deserializeJsonString(clazz, scheduler, mapper()));
}
default <T> Mono<T> bodyToMono(ServerRequest request, Class<T> clazz) {
return request.bodyToMono(String.class)
.flatMap(HttpHandlerFunctions.FN.deserializeJsonString(clazz, mapper()));
.flatMap(deserializeJsonString(clazz, mapper()));
}
default <T> Mono<ServerResponse> mapToResponse(T result) {

View File

@@ -15,9 +15,9 @@ import java.util.function.Function;
import static org.springframework.web.reactive.function.BodyInserters.fromObject;
public enum HttpHandlerFunctions {
FN;
public final class HttpHandlers {
private HttpHandlers() {}
// private final ObjectMapper mapper;
//
// HttpHandlerFunctions() {
@@ -26,7 +26,7 @@ public enum HttpHandlerFunctions {
// mapper.registerModule(new Jdk8Module());
// }
public <T> Function<String, Mono<T>> deserializeJsonString(
public static <T> Function<String, Mono<T>> deserializeJsonString(
@Nonnull Class<T> clazz,
@Nonnull Scheduler scheduler,
@Nonnull ObjectMapper mapper
@@ -34,11 +34,11 @@ public enum HttpHandlerFunctions {
return value -> Mono.fromCallable(() -> mapper.readValue(value, clazz)).subscribeOn(scheduler);
}
public <T> Function<String, Mono<T>> deserializeJsonString(@Nonnull Class<T> clazz, @Nonnull ObjectMapper mapper) {
public static <T> Function<String, Mono<T>> deserializeJsonString(@Nonnull Class<T> clazz, @Nonnull ObjectMapper mapper) {
return value -> Mono.fromCallable(() -> mapper.readValue(value, clazz)).subscribeOn(Schedulers.elastic());
}
public <E extends Throwable> Mono<ServerResponse> onError(E e, ServerRequest req, Consumer<E> logger) {
public static <E extends Throwable> Mono<ServerResponse> onError(E e, ServerRequest req, Consumer<E> logger) {
return Mono.fromCallable(() -> {
logger.accept(e);
return ErrorMessage.builder().error(e.getMessage()).build();

5
gradle.properties Normal file
View File

@@ -0,0 +1,5 @@
springDependencyManagementVersion = 1.0.9.RELEASE
springframeworkBootVersion=2.3.2.RELEASE
reactorVersion = 3.3.0.RELEASE
immutablesVersion = 2.7.5
jacksonVersion = 2.10.1

View File

@@ -1,3 +1,12 @@
pluginManagement {
repositories {
maven { url 'https://repo.spring.io/milestone' }
maven { url 'https://repo.spring.io/snapshot' }
gradlePluginPortal()
mavenCentral()
}
}
rootProject.name = 'reactor-ddd'
include 'common-api'
include 'shared-dependencies'