Example usage for org.springframework.web.reactive.result.method.annotation InitBinderBindingContext InitBinderBindingContext

List of usage examples for org.springframework.web.reactive.result.method.annotation InitBinderBindingContext InitBinderBindingContext

Introduction

In this page you can find the example usage for org.springframework.web.reactive.result.method.annotation InitBinderBindingContext InitBinderBindingContext.

Prototype

InitBinderBindingContext(@Nullable WebBindingInitializer initializer,
            List<SyncInvocableHandlerMethod> binderMethods) 

Source Link

Usage

From source file:org.springframework.web.reactive.result.method.annotation.RequestMappingHandlerAdapter.java

@Override
public Mono<HandlerResult> handle(ServerWebExchange exchange, Object handler) {
    HandlerMethod handlerMethod = (HandlerMethod) handler;
    Assert.state(this.methodResolver != null && this.modelInitializer != null, "Not initialized");

    InitBinderBindingContext bindingContext = new InitBinderBindingContext(getWebBindingInitializer(),
            this.methodResolver.getInitBinderMethods(handlerMethod));

    InvocableHandlerMethod invocableMethod = this.methodResolver.getRequestMappingMethod(handlerMethod);

    Function<Throwable, Mono<HandlerResult>> exceptionHandler = ex -> handleException(ex, handlerMethod,
            bindingContext, exchange);//from w  ww .  j  a v a 2s .co  m

    return this.modelInitializer.initModel(handlerMethod, bindingContext, exchange)
            .then(Mono.defer(() -> invocableMethod.invoke(exchange, bindingContext)))
            .doOnNext(result -> result.setExceptionHandler(exceptionHandler))
            .doOnNext(result -> bindingContext.saveModel()).onErrorResume(exceptionHandler);
}