Example usage for org.springframework.web.reactive.result.method InvocableHandlerMethod InvocableHandlerMethod

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

Introduction

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

Prototype

public InvocableHandlerMethod(Object bean, Method method) 

Source Link

Document

Create an instance from a bean instance and a method.

Usage

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

private InvocableHandlerMethod createAttributeMethod(Object bean, Method method) {
    InvocableHandlerMethod invocable = new InvocableHandlerMethod(bean, method);
    invocable.setArgumentResolvers(this.modelAttributeResolvers);
    return invocable;
}

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

/**
 * Find an {@code @ExceptionHandler} method in {@code @ControllerAdvice}
 * components or in the controller of the given {@code @RequestMapping} method.
 *//*www. ja  v  a  2 s.  c o m*/
@Nullable
public InvocableHandlerMethod getExceptionHandlerMethod(Throwable ex, HandlerMethod handlerMethod) {

    Class<?> handlerType = handlerMethod.getBeanType();

    // Controller-local first...
    Object targetBean = handlerMethod.getBean();
    Method targetMethod = this.exceptionHandlerCache
            .computeIfAbsent(handlerType, ExceptionHandlerMethodResolver::new).resolveMethodByThrowable(ex);

    if (targetMethod == null) {
        // Global exception handlers...
        for (ControllerAdviceBean advice : this.exceptionHandlerAdviceCache.keySet()) {
            if (advice.isApplicableToBeanType(handlerType)) {
                targetBean = advice.resolveBean();
                targetMethod = this.exceptionHandlerAdviceCache.get(advice).resolveMethodByThrowable(ex);
                if (targetMethod != null) {
                    break;
                }
            }
        }
    }

    if (targetMethod == null) {
        return null;
    }

    InvocableHandlerMethod invocable = new InvocableHandlerMethod(targetBean, targetMethod);
    invocable.setArgumentResolvers(this.exceptionHandlerResolvers);
    return invocable;
}