List of usage examples for org.springframework.web.method ControllerAdviceBean ControllerAdviceBean
public ControllerAdviceBean(String beanName, BeanFactory beanFactory)
From source file:org.springframework.web.method.ControllerAdviceBean.java
/** * Find the names of beans annotated with * {@linkplain ControllerAdvice @ControllerAdvice} in the given * ApplicationContext and wrap them as {@code ControllerAdviceBean} instances. *///w w w . j a va 2s. c o m public static List<ControllerAdviceBean> findAnnotatedBeans(ApplicationContext applicationContext) { List<ControllerAdviceBean> beans = new ArrayList<ControllerAdviceBean>(); for (String name : BeanFactoryUtils.beanNamesForTypeIncludingAncestors(applicationContext, Object.class)) { if (applicationContext.findAnnotationOnBean(name, ControllerAdvice.class) != null) { beans.add(new ControllerAdviceBean(name, applicationContext)); } } return beans; }