Example usage for org.springframework.messaging.handler.invocation InvocableHandlerMethod InvocableHandlerMethod

List of usage examples for org.springframework.messaging.handler.invocation InvocableHandlerMethod InvocableHandlerMethod

Introduction

In this page you can find the example usage for org.springframework.messaging.handler.invocation InvocableHandlerMethod InvocableHandlerMethod.

Prototype

public InvocableHandlerMethod(HandlerMethod handlerMethod) 

Source Link

Document

Create an instance from a HandlerMethod .

Usage

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

protected void handleMatch(T mapping, HandlerMethod handlerMethod, String lookupDestination,
        Message<?> message) {/*  w  ww  .j  a va  2  s . co 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);
        }
    }
}