Example usage for org.springframework.web.method.annotation ExceptionHandlerMethodResolver hasExceptionMappings

List of usage examples for org.springframework.web.method.annotation ExceptionHandlerMethodResolver hasExceptionMappings

Introduction

In this page you can find the example usage for org.springframework.web.method.annotation ExceptionHandlerMethodResolver hasExceptionMappings.

Prototype

public boolean hasExceptionMappings() 

Source Link

Document

Whether the contained type has any exception mappings.

Usage

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

private void initControllerAdviceCaches(@Nullable ApplicationContext applicationContext) {
    if (applicationContext == null) {
        return;/* w  w  w.  j  av  a  2 s. c o  m*/
    }
    if (logger.isInfoEnabled()) {
        logger.info("Looking for @ControllerAdvice: " + applicationContext);
    }

    List<ControllerAdviceBean> beans = ControllerAdviceBean.findAnnotatedBeans(applicationContext);
    AnnotationAwareOrderComparator.sort(beans);

    for (ControllerAdviceBean bean : beans) {
        Class<?> beanType = bean.getBeanType();
        if (beanType != null) {
            Set<Method> attrMethods = selectMethods(beanType, ATTRIBUTE_METHODS);
            if (!attrMethods.isEmpty()) {
                this.modelAttributeAdviceCache.put(bean, attrMethods);
                if (logger.isInfoEnabled()) {
                    logger.info("Detected @ModelAttribute methods in " + bean);
                }
            }
            Set<Method> binderMethods = selectMethods(beanType, BINDER_METHODS);
            if (!binderMethods.isEmpty()) {
                this.initBinderAdviceCache.put(bean, binderMethods);
                if (logger.isInfoEnabled()) {
                    logger.info("Detected @InitBinder methods in " + bean);
                }
            }
            ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(beanType);
            if (resolver.hasExceptionMappings()) {
                this.exceptionHandlerAdviceCache.put(bean, resolver);
                if (logger.isInfoEnabled()) {
                    logger.info("Detected @ExceptionHandler methods in " + bean);
                }
            }
        }
    }
}