Example usage for org.springframework.messaging.handler HandlerMethod getReturnType

List of usage examples for org.springframework.messaging.handler HandlerMethod getReturnType

Introduction

In this page you can find the example usage for org.springframework.messaging.handler HandlerMethod getReturnType.

Prototype

public MethodParameter getReturnType() 

Source Link

Document

Return the HandlerMethod return type.

Usage

From source file:org.springframework.messaging.handler.invocation.AbstractMethodMessageHandler.java

protected void handleMatch(T mapping, HandlerMethod handlerMethod, String lookupDestination,
        Message<?> message) {/*from  ww w .ja v a2 s. c o m*/
    if (logger.isDebugEnabled()) {
        logger.debug("Invoking " + handlerMethod.getShortLogMessage());
    }
    handlerMethod = handlerMethod.createWithResolvedBean();
    InvocableHandlerMethod invocable = new InvocableHandlerMethod(handlerMethod);
    invocable.setMessageMethodArgumentResolvers(this.argumentResolvers);
    try {
        Object returnValue = invocable.invoke(message);
        MethodParameter returnType = handlerMethod.getReturnType();
        if (void.class == returnType.getParameterType()) {
            return;
        }
        if (returnValue != null && this.returnValueHandlers.isAsyncReturnValue(returnValue, returnType)) {
            ListenableFuture<?> future = this.returnValueHandlers.toListenableFuture(returnValue, returnType);
            if (future != null) {
                future.addCallback(new ReturnValueListenableFutureCallback(invocable, message));
            }
        } else {
            this.returnValueHandlers.handleReturnValue(returnValue, returnType, message);
        }
    } catch (Exception ex) {
        processHandlerMethodException(handlerMethod, ex, message);
    } catch (Throwable ex) {
        if (logger.isErrorEnabled()) {
            logger.error("Error while processing message " + message, ex);
        }
    }
}

From source file:org.springframework.messaging.handler.invocation.reactive.InvocableHelper.java

private Mono<Void> handleReturnValue(@Nullable Object returnValue, HandlerMethod handlerMethod,
        Message<?> message) {/*  w w w  .  j a  v a2 s  .  c  om*/

    MethodParameter returnType = handlerMethod.getReturnType();
    return this.returnValueHandlers.handleReturnValue(returnValue, returnType, message);
}