org.springframework.web.reactive

Class HandlerResult

  • java.lang.Object
    • org.springframework.web.reactive.HandlerResult


  • public class HandlerResult
    extends java.lang.Object
    Represent the result of the invocation of a handler or a handler method.
    Since:
    5.0
    Author:
    Rossen Stoyanchev
    • Constructor Detail

      • HandlerResult

        public HandlerResult(java.lang.Object handler,
                             @Nullable
                             java.lang.Object returnValue,
                             MethodParameter returnType)
        Create a new HandlerResult.
        Parameters:
        handler - the handler that handled the request
        returnValue - the return value from the handler possibly null
        returnType - the return value type
      • HandlerResult

        public HandlerResult(java.lang.Object handler,
                             @Nullable
                             java.lang.Object returnValue,
                             MethodParameter returnType,
                             @Nullable
                             BindingContext context)
        Create a new HandlerResult.
        Parameters:
        handler - the handler that handled the request
        returnValue - the return value from the handler possibly null
        returnType - the return value type
        context - the binding context used for request handling
    • Method Detail

      • getHandler

        public java.lang.Object getHandler()
        Return the handler that handled the request.
      • getReturnValue

        @Nullable
        public java.lang.Object getReturnValue()
        Return the value returned from the handler, if any.
      • getReturnType

        public ResolvableType getReturnType()
        Return the type of the value returned from the handler -- e.g. the return type declared on a controller method's signature. Also see getReturnTypeSource() to obtain the underlying MethodParameter for the return type.
      • getBindingContext

        public BindingContext getBindingContext()
        Return the BindingContext used for request handling.
      • getModel

        public Model getModel()
        Return the model used for request handling. This is a shortcut for getBindingContext().getModel().
      • setExceptionHandler

        public HandlerResult setExceptionHandler(java.util.function.Function<java.lang.Throwable,reactor.core.publisher.Mono<HandlerResult>> function)
        Configure an exception handler that may be used to produce an alternative result when result handling fails. Especially for an async return value errors may occur after the invocation of the handler.
        Parameters:
        function - the error handler
        Returns:
        the current instance
      • hasExceptionHandler

        public boolean hasExceptionHandler()
        Whether there is an exception handler.
      • applyExceptionHandler

        public reactor.core.publisher.Mono<HandlerResult> applyExceptionHandler(java.lang.Throwable failure)
        Apply the exception handler and return the alternative result.
        Parameters:
        failure - the exception
        Returns:
        the new result or the same error if there is no exception handler