Java Code Examples for org.springframework.web.method.ControllerAdviceBean

The following examples show how to use org.springframework.web.method.ControllerAdviceBean. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
@SuppressWarnings("unchecked")
private <A> List<A> getMatchingAdvice(MethodParameter parameter, Class<? extends A> adviceType) {
	List<Object> availableAdvice = getAdvice(adviceType);
	if (CollectionUtils.isEmpty(availableAdvice)) {
		return Collections.emptyList();
	}
	List<A> result = new ArrayList<>(availableAdvice.size());
	for (Object advice : availableAdvice) {
		if (advice instanceof ControllerAdviceBean) {
			ControllerAdviceBean adviceBean = (ControllerAdviceBean) advice;
			if (!adviceBean.isApplicableToBeanType(parameter.getContainingClass())) {
				continue;
			}
			advice = adviceBean.resolveBean();
		}
		if (adviceType.isAssignableFrom(advice.getClass())) {
			result.add((A) advice);
		}
	}
	return result;
}
 
Example 2
Source Project: Milkomeda   Source File: SpringMvcPolyfill.java    License: MIT License 6 votes vote down vote up
/**
 * 动态添加异常切面
 * @param handlerExceptionResolver  HandlerExceptionResolver
 * @param beanFactory               BeanFactory
 * @param beanName                  异常拦截处理器bean名
 */
public static void addDynamicExceptionAdvice(HandlerExceptionResolver handlerExceptionResolver, BeanFactory beanFactory, String beanName) {
    if (handlerExceptionResolver instanceof HandlerExceptionResolverComposite) {
        List<HandlerExceptionResolver> exceptionResolvers = ((HandlerExceptionResolverComposite) handlerExceptionResolver).getExceptionResolvers();
        for (HandlerExceptionResolver exceptionResolver : exceptionResolvers) {
            if (exceptionResolver instanceof ExceptionHandlerExceptionResolver) {
                // TODO <mark> 由于使用底层API, 这个exceptionHandlerAdviceCache属性在未来版本中可能会改
                Map<ControllerAdviceBean, ExceptionHandlerMethodResolver> resolverMap = ReflectUtil.invokeFieldPath(exceptionResolver, "exceptionHandlerAdviceCache");
                if (resolverMap == null) {
                    resolverMap = new HashMap<>(2);
                }
                // 仿Spring MVC源码创建advice
                ControllerAdviceBean adviceBean = new ControllerAdviceBean(beanName, ApplicationContextHolder.get(), null);
                Class<?> beanType = adviceBean.getBeanType();
                if (beanType == null) {
                    throw new IllegalStateException("SpringMvcPolyfill find unresolvable type for ControllerAdviceBean: " + adviceBean);
                }
                ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(beanType);
                if (resolver.hasExceptionMappings()) {
                    resolverMap.put(adviceBean, resolver);
                }
                break;
            }
        }
    }
}
 
Example 3
@SuppressWarnings("unchecked")
private <A> List<A> getMatchingAdvice(MethodParameter parameter, Class<? extends A> adviceType) {
	List<Object> availableAdvice = getAdvice(adviceType);
	if (CollectionUtils.isEmpty(availableAdvice)) {
		return Collections.emptyList();
	}
	List<A> result = new ArrayList<>(availableAdvice.size());
	for (Object advice : availableAdvice) {
		if (advice instanceof ControllerAdviceBean) {
			ControllerAdviceBean adviceBean = (ControllerAdviceBean) advice;
			if (!adviceBean.isApplicableToBeanType(parameter.getContainingClass())) {
				continue;
			}
			advice = adviceBean.resolveBean();
		}
		if (adviceType.isAssignableFrom(advice.getClass())) {
			result.add((A) advice);
		}
	}
	return result;
}
 
Example 4
@SuppressWarnings("unchecked")
private <A> List<A> getMatchingAdvice(MethodParameter parameter, Class<? extends A> adviceType) {
	List<Object> availableAdvice = getAdvice(adviceType);
	if (CollectionUtils.isEmpty(availableAdvice)) {
		return Collections.emptyList();
	}
	List<A> result = new ArrayList<A>(availableAdvice.size());
	for (Object advice : availableAdvice) {
		if (advice instanceof ControllerAdviceBean) {
			ControllerAdviceBean adviceBean = (ControllerAdviceBean) advice;
			if (!adviceBean.isApplicableToBeanType(parameter.getContainingClass())) {
				continue;
			}
			advice = adviceBean.resolveBean();
		}
		if (adviceType.isAssignableFrom(advice.getClass())) {
			result.add((A) advice);
		}
	}
	return result;
}
 
Example 5
@SuppressWarnings("unchecked")
private <A> List<A> getMatchingAdvice(MethodParameter parameter, Class<? extends A> adviceType) {
	List<Object> availableAdvice = getAdvice(adviceType);
	if (CollectionUtils.isEmpty(availableAdvice)) {
		return Collections.emptyList();
	}
	List<A> result = new ArrayList<A>(availableAdvice.size());
	for (Object advice : availableAdvice) {
		if (advice instanceof ControllerAdviceBean) {
			ControllerAdviceBean adviceBean = (ControllerAdviceBean) advice;
			if (!adviceBean.isApplicableToBeanType(parameter.getContainingClass())) {
				continue;
			}
			advice = adviceBean.resolveBean();
		}
		if (adviceType.isAssignableFrom(advice.getClass())) {
			result.add((A) advice);
		}
	}
	return result;
}
 
Example 6
private void initExceptionHandlerAdviceCache() {
	if (getApplicationContext() == null) {
		return;
	}
	if (logger.isDebugEnabled()) {
		logger.debug("Looking for exception mappings: " + getApplicationContext());
	}

	List<ControllerAdviceBean> adviceBeans = ControllerAdviceBean.findAnnotatedBeans(getApplicationContext());
	AnnotationAwareOrderComparator.sort(adviceBeans);

	for (ControllerAdviceBean adviceBean : adviceBeans) {
		ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(adviceBean.getBeanType());
		if (resolver.hasExceptionMappings()) {
			this.exceptionHandlerAdviceCache.put(adviceBean, resolver);
			logger.info("Detected @ExceptionHandler methods in " + adviceBean);
		}
		if (ResponseBodyAdvice.class.isAssignableFrom(adviceBean.getBeanType())) {
			this.responseBodyAdvice.add(adviceBean);
			logger.info("Detected ResponseBodyAdvice implementation in " + adviceBean);
		}
	}
}
 
Example 7
Source Project: spring-analysis-note   Source File: ControllerMethodResolver.java    License: MIT License 5 votes vote down vote up
private void initControllerAdviceCaches(ApplicationContext applicationContext) {
	List<ControllerAdviceBean> beans = ControllerAdviceBean.findAnnotatedBeans(applicationContext);
	AnnotationAwareOrderComparator.sort(beans);

	for (ControllerAdviceBean bean : beans) {
		Class<?> beanType = bean.getBeanType();
		if (beanType != null) {
			Set<Method> attrMethods = MethodIntrospector.selectMethods(beanType, MODEL_ATTRIBUTE_METHODS);
			if (!attrMethods.isEmpty()) {
				this.modelAttributeAdviceCache.put(bean, attrMethods);
			}
			Set<Method> binderMethods = MethodIntrospector.selectMethods(beanType, INIT_BINDER_METHODS);
			if (!binderMethods.isEmpty()) {
				this.initBinderAdviceCache.put(bean, binderMethods);
			}
			ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(beanType);
			if (resolver.hasExceptionMappings()) {
				this.exceptionHandlerAdviceCache.put(bean, resolver);
			}
		}
	}

	if (logger.isDebugEnabled()) {
		int modelSize = this.modelAttributeAdviceCache.size();
		int binderSize = this.initBinderAdviceCache.size();
		int handlerSize = this.exceptionHandlerAdviceCache.size();
		if (modelSize == 0 && binderSize == 0 && handlerSize == 0) {
			logger.debug("ControllerAdvice beans: none");
		}
		else {
			logger.debug("ControllerAdvice beans: " + modelSize + " @ModelAttribute, " + binderSize +
					" @InitBinder, " + handlerSize + " @ExceptionHandler");
		}
	}
}
 
Example 8
Source Project: spring-analysis-note   Source File: ControllerMethodResolver.java    License: MIT License 5 votes vote down vote up
/**
 * Find an {@code @ExceptionHandler} method in {@code @ControllerAdvice}
 * components or in the controller of the given {@code @RequestMapping} method.
 */
@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;
}
 
Example 9
@SuppressWarnings("unchecked")
static <T> List<T> getAdviceByType(@Nullable List<Object> requestResponseBodyAdvice, Class<T> adviceType) {
	if (requestResponseBodyAdvice != null) {
		List<T> result = new ArrayList<>();
		for (Object advice : requestResponseBodyAdvice) {
			Class<?> beanType = (advice instanceof ControllerAdviceBean ?
					((ControllerAdviceBean) advice).getBeanType() : advice.getClass());
			if (beanType != null && adviceType.isAssignableFrom(beanType)) {
				result.add((T) advice);
			}
		}
		return result;
	}
	return Collections.emptyList();
}
 
Example 10
private void initExceptionHandlerAdviceCache() {
	if (getApplicationContext() == null) {
		return;
	}

	List<ControllerAdviceBean> adviceBeans = ControllerAdviceBean.findAnnotatedBeans(getApplicationContext());
	AnnotationAwareOrderComparator.sort(adviceBeans);

	for (ControllerAdviceBean adviceBean : adviceBeans) {
		Class<?> beanType = adviceBean.getBeanType();
		if (beanType == null) {
			throw new IllegalStateException("Unresolvable type for ControllerAdviceBean: " + adviceBean);
		}
		ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(beanType);
		if (resolver.hasExceptionMappings()) {
			this.exceptionHandlerAdviceCache.put(adviceBean, resolver);
		}
		if (ResponseBodyAdvice.class.isAssignableFrom(beanType)) {
			this.responseBodyAdvice.add(adviceBean);
		}
	}

	if (logger.isDebugEnabled()) {
		int handlerSize = this.exceptionHandlerAdviceCache.size();
		int adviceSize = this.responseBodyAdvice.size();
		if (handlerSize == 0 && adviceSize == 0) {
			logger.debug("ControllerAdvice beans: none");
		}
		else {
			logger.debug("ControllerAdvice beans: " +
					handlerSize + " @ExceptionHandler, " + adviceSize + " ResponseBodyAdvice");
		}
	}
}
 
Example 11
@Test
public void controllerAdvice() {
	Object adviceBean = new ControllerAdviceBean(new MyControllerAdvice());
	RequestResponseBodyAdviceChain chain = new RequestResponseBodyAdviceChain(Collections.singletonList(adviceBean));

	String actual = (String) chain.beforeBodyWrite(this.body, this.returnType, this.contentType,
			this.converterType, this.request, this.response);

	assertEquals("body-MyControllerAdvice", actual);
}
 
Example 12
@Test
public void controllerAdviceNotApplicable() {
	Object adviceBean = new ControllerAdviceBean(new TargetedControllerAdvice());
	RequestResponseBodyAdviceChain chain = new RequestResponseBodyAdviceChain(Collections.singletonList(adviceBean));

	String actual = (String) chain.beforeBodyWrite(this.body, this.returnType, this.contentType,
			this.converterType, this.request, this.response);

	assertEquals(this.body, actual);
}
 
Example 13
private void initControllerAdviceCache() {
	ApplicationContext context = getApplicationContext();
	if (context == null) {
		return;
	}
	if (logger.isTraceEnabled()) {
		logger.trace("Looking for @MessageExceptionHandler mappings: " + context);
	}
	List<ControllerAdviceBean> beans = ControllerAdviceBean.findAnnotatedBeans(context);
	AnnotationAwareOrderComparator.sort(beans);
	initMessagingAdviceCache(MessagingControllerAdviceBean.createFromList(beans));
}
 
Example 14
public static List<MessagingAdviceBean> createFromList(List<ControllerAdviceBean> beans) {
	List<MessagingAdviceBean> result = new ArrayList<>(beans.size());
	for (ControllerAdviceBean bean : beans) {
		result.add(new MessagingControllerAdviceBean(bean));
	}
	return result;
}
 
Example 15
Source Project: springdoc-openapi   Source File: GenericResponseBuilder.java    License: Apache License 2.0 5 votes vote down vote up
/**
 * Gets generic map response.
 *
 * @param beanType the bean type
 * @return the generic map response
 */
private Map<String, ApiResponse> getGenericMapResponse(Class<?> beanType) {
	return controllerAdviceInfos.stream()
			.filter(controllerAdviceInfo -> new ControllerAdviceBean(controllerAdviceInfo.getControllerAdvice()).isApplicableToBeanType(beanType))
			.map(ControllerAdviceInfo::getApiResponseMap)
			.collect(LinkedHashMap::new, Map::putAll, Map::putAll);
}
 
Example 16
Source Project: java-technology-stack   Source File: ControllerMethodResolver.java    License: MIT License 5 votes vote down vote up
private void initControllerAdviceCaches(ApplicationContext applicationContext) {
	List<ControllerAdviceBean> beans = ControllerAdviceBean.findAnnotatedBeans(applicationContext);
	AnnotationAwareOrderComparator.sort(beans);

	for (ControllerAdviceBean bean : beans) {
		Class<?> beanType = bean.getBeanType();
		if (beanType != null) {
			Set<Method> attrMethods = MethodIntrospector.selectMethods(beanType, MODEL_ATTRIBUTE_METHODS);
			if (!attrMethods.isEmpty()) {
				this.modelAttributeAdviceCache.put(bean, attrMethods);
			}
			Set<Method> binderMethods = MethodIntrospector.selectMethods(beanType, INIT_BINDER_METHODS);
			if (!binderMethods.isEmpty()) {
				this.initBinderAdviceCache.put(bean, binderMethods);
			}
			ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(beanType);
			if (resolver.hasExceptionMappings()) {
				this.exceptionHandlerAdviceCache.put(bean, resolver);
			}
		}
	}

	if (logger.isDebugEnabled()) {
		int modelSize = this.modelAttributeAdviceCache.size();
		int binderSize = this.initBinderAdviceCache.size();
		int handlerSize = this.exceptionHandlerAdviceCache.size();
		if (modelSize == 0 && binderSize == 0 && handlerSize == 0) {
			logger.debug("ControllerAdvice beans: none");
		}
		else {
			logger.debug("ControllerAdvice beans: " + modelSize + " @ModelAttribute, " + binderSize +
					" @InitBinder, " + handlerSize + " @ExceptionHandler");
		}
	}
}
 
Example 17
Source Project: java-technology-stack   Source File: ControllerMethodResolver.java    License: MIT License 5 votes vote down vote up
/**
 * Find an {@code @ExceptionHandler} method in {@code @ControllerAdvice}
 * components or in the controller of the given {@code @RequestMapping} method.
 */
@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;
}
 
Example 18
@SuppressWarnings("unchecked")
static <T> List<T> getAdviceByType(@Nullable List<Object> requestResponseBodyAdvice, Class<T> adviceType) {
	if (requestResponseBodyAdvice != null) {
		List<T> result = new ArrayList<>();
		for (Object advice : requestResponseBodyAdvice) {
			Class<?> beanType = (advice instanceof ControllerAdviceBean ?
					((ControllerAdviceBean) advice).getBeanType() : advice.getClass());
			if (beanType != null && adviceType.isAssignableFrom(beanType)) {
				result.add((T) advice);
			}
		}
		return result;
	}
	return Collections.emptyList();
}
 
Example 19
private void initExceptionHandlerAdviceCache() {
	if (getApplicationContext() == null) {
		return;
	}

	List<ControllerAdviceBean> adviceBeans = ControllerAdviceBean.findAnnotatedBeans(getApplicationContext());
	AnnotationAwareOrderComparator.sort(adviceBeans);

	for (ControllerAdviceBean adviceBean : adviceBeans) {
		Class<?> beanType = adviceBean.getBeanType();
		if (beanType == null) {
			throw new IllegalStateException("Unresolvable type for ControllerAdviceBean: " + adviceBean);
		}
		ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(beanType);
		if (resolver.hasExceptionMappings()) {
			this.exceptionHandlerAdviceCache.put(adviceBean, resolver);
		}
		if (ResponseBodyAdvice.class.isAssignableFrom(beanType)) {
			this.responseBodyAdvice.add(adviceBean);
		}
	}

	if (logger.isDebugEnabled()) {
		int handlerSize = this.exceptionHandlerAdviceCache.size();
		int adviceSize = this.responseBodyAdvice.size();
		if (handlerSize == 0 && adviceSize == 0) {
			logger.debug("ControllerAdvice beans: none");
		}
		else {
			logger.debug("ControllerAdvice beans: " +
					handlerSize + " @ExceptionHandler, " + adviceSize + " ResponseBodyAdvice");
		}
	}
}
 
Example 20
@Test
public void controllerAdvice() {
	Object adviceBean = new ControllerAdviceBean(new MyControllerAdvice());
	RequestResponseBodyAdviceChain chain = new RequestResponseBodyAdviceChain(Collections.singletonList(adviceBean));

	String actual = (String) chain.beforeBodyWrite(this.body, this.returnType, this.contentType,
			this.converterType, this.request, this.response);

	assertEquals("body-MyControllerAdvice", actual);
}
 
Example 21
@Test
public void controllerAdviceNotApplicable() {
	Object adviceBean = new ControllerAdviceBean(new TargetedControllerAdvice());
	RequestResponseBodyAdviceChain chain = new RequestResponseBodyAdviceChain(Collections.singletonList(adviceBean));

	String actual = (String) chain.beforeBodyWrite(this.body, this.returnType, this.contentType,
			this.converterType, this.request, this.response);

	assertEquals(this.body, actual);
}
 
Example 22
private void initControllerAdviceCache() {
	ApplicationContext context = getApplicationContext();
	if (context == null) {
		return;
	}
	if (logger.isTraceEnabled()) {
		logger.trace("Looking for @MessageExceptionHandler mappings: " + context);
	}
	List<ControllerAdviceBean> beans = ControllerAdviceBean.findAnnotatedBeans(context);
	AnnotationAwareOrderComparator.sort(beans);
	initMessagingAdviceCache(MessagingControllerAdviceBean.createFromList(beans));
}
 
Example 23
public static List<MessagingAdviceBean> createFromList(List<ControllerAdviceBean> beans) {
	List<MessagingAdviceBean> result = new ArrayList<>(beans.size());
	for (ControllerAdviceBean bean : beans) {
		result.add(new MessagingControllerAdviceBean(bean));
	}
	return result;
}
 
Example 24
private void initAdvice(List<Object> requestResponseBodyAdvice) {
	if (requestResponseBodyAdvice == null) {
		return;
	}
	for (Object advice : requestResponseBodyAdvice) {
		Class<?> beanType = (advice instanceof ControllerAdviceBean ?
				((ControllerAdviceBean) advice).getBeanType() : advice.getClass());
		if (RequestBodyAdvice.class.isAssignableFrom(beanType)) {
			this.requestBodyAdvice.add(advice);
		}
		else if (ResponseBodyAdvice.class.isAssignableFrom(beanType)) {
			this.responseBodyAdvice.add(advice);
		}
	}
}
 
Example 25
private void initExceptionHandlerAdviceCache() {
	if (getApplicationContext() == null) {
		return;
	}
	if (logger.isDebugEnabled()) {
		logger.debug("Looking for exception mappings: " + getApplicationContext());
	}

	List<ControllerAdviceBean> adviceBeans = ControllerAdviceBean.findAnnotatedBeans(getApplicationContext());
	AnnotationAwareOrderComparator.sort(adviceBeans);

	for (ControllerAdviceBean adviceBean : adviceBeans) {
		ExceptionHandlerMethodResolver resolver = new ExceptionHandlerMethodResolver(adviceBean.getBeanType());
		if (resolver.hasExceptionMappings()) {
			this.exceptionHandlerAdviceCache.put(adviceBean, resolver);
			if (logger.isInfoEnabled()) {
				logger.info("Detected @ExceptionHandler methods in " + adviceBean);
			}
		}
		if (ResponseBodyAdvice.class.isAssignableFrom(adviceBean.getBeanType())) {
			this.responseBodyAdvice.add(adviceBean);
			if (logger.isInfoEnabled()) {
				logger.info("Detected ResponseBodyAdvice implementation in " + adviceBean);
			}
		}
	}
}
 
Example 26
private void initAdvice(List<Object> requestResponseBodyAdvice) {
	if (requestResponseBodyAdvice == null) {
		return;
	}
	for (Object advice : requestResponseBodyAdvice) {
		Class<?> beanType = (advice instanceof ControllerAdviceBean ?
				((ControllerAdviceBean) advice).getBeanType() : advice.getClass());
		if (RequestBodyAdvice.class.isAssignableFrom(beanType)) {
			this.requestBodyAdvice.add(advice);
		}
		else if (ResponseBodyAdvice.class.isAssignableFrom(beanType)) {
			this.responseBodyAdvice.add(advice);
		}
	}
}
 
Example 27
@Test
public void controllerAdvice() {

	Object adviceBean = new ControllerAdviceBean(new MyControllerAdvice());
	RequestResponseBodyAdviceChain chain = new RequestResponseBodyAdviceChain(Arrays.asList(adviceBean));

	String actual = (String) chain.beforeBodyWrite(this.body, this.returnType, this.contentType,
			this.converterType, this.request, this.response);

	assertEquals("body-MyControllerAdvice", actual);
}
 
Example 28
@Test
public void controllerAdviceNotApplicable() {

	Object adviceBean = new ControllerAdviceBean(new TargetedControllerAdvice());
	RequestResponseBodyAdviceChain chain = new RequestResponseBodyAdviceChain(Arrays.asList(adviceBean));

	String actual = (String) chain.beforeBodyWrite(this.body, this.returnType, this.contentType,
			this.converterType, this.request, this.response);

	assertEquals(this.body, actual);
}
 
Example 29
private void initControllerAdviceCache() {
	if (getApplicationContext() == null) {
		return;
	}
	if (logger.isDebugEnabled()) {
		logger.debug("Looking for @MessageExceptionHandler mappings: " + getApplicationContext());
	}
	List<ControllerAdviceBean> controllerAdvice = ControllerAdviceBean.findAnnotatedBeans(getApplicationContext());
	AnnotationAwareOrderComparator.sort(controllerAdvice);
	initMessagingAdviceCache(MessagingControllerAdviceBean.createFromList(controllerAdvice));
}
 
Example 30
public static List<MessagingAdviceBean> createFromList(List<ControllerAdviceBean> controllerAdvice) {
	List<MessagingAdviceBean> messagingAdvice = new ArrayList<MessagingAdviceBean>(controllerAdvice.size());
	for (ControllerAdviceBean bean : controllerAdvice) {
		messagingAdvice.add(new MessagingControllerAdviceBean(bean));
	}
	return messagingAdvice;
}