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

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

Introduction

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

Prototype

public HandlerMethod createWithResolvedBean() 

Source Link

Document

If the provided instance contains a bean name rather than an object instance, the bean name is resolved before a HandlerMethod is created and returned.

Usage

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

protected void handleMatch(T mapping, HandlerMethod handlerMethod, String lookupDestination,
        Message<?> message) {//w  w  w  . j ava 2 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.AbstractMethodMessageHandler.java

protected Mono<Void> handleMatch(T mapping, HandlerMethod handlerMethod, Message<?> message) {
    handlerMethod = handlerMethod.createWithResolvedBean();
    return this.invocableHelper.handleMessage(handlerMethod, message);
}