SchedulingConfigurer and JmsListenerConfigurer respect @Order
Issue: SPR-16090
This commit is contained in:
@@ -31,7 +31,6 @@ import org.springframework.aop.framework.autoproxy.AutoProxyUtils;
|
||||
import org.springframework.aop.scope.ScopedObject;
|
||||
import org.springframework.aop.scope.ScopedProxyUtils;
|
||||
import org.springframework.aop.support.AopUtils;
|
||||
import org.springframework.beans.BeansException;
|
||||
import org.springframework.beans.factory.BeanInitializationException;
|
||||
import org.springframework.beans.factory.SmartInitializingSingleton;
|
||||
import org.springframework.context.ApplicationContext;
|
||||
@@ -65,7 +64,7 @@ public class EventListenerMethodProcessor implements SmartInitializingSingleton,
|
||||
|
||||
|
||||
@Override
|
||||
public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
|
||||
public void setApplicationContext(ApplicationContext applicationContext) {
|
||||
Assert.isTrue(applicationContext instanceof ConfigurableApplicationContext,
|
||||
"ApplicationContext does not implement ConfigurableApplicationContext");
|
||||
this.applicationContext = (ConfigurableApplicationContext) applicationContext;
|
||||
@@ -119,9 +118,9 @@ public class EventListenerMethodProcessor implements SmartInitializingSingleton,
|
||||
*/
|
||||
protected List<EventListenerFactory> getEventListenerFactories() {
|
||||
Map<String, EventListenerFactory> beans = this.applicationContext.getBeansOfType(EventListenerFactory.class);
|
||||
List<EventListenerFactory> allFactories = new ArrayList<EventListenerFactory>(beans.values());
|
||||
AnnotationAwareOrderComparator.sort(allFactories);
|
||||
return allFactories;
|
||||
List<EventListenerFactory> factories = new ArrayList<EventListenerFactory>(beans.values());
|
||||
AnnotationAwareOrderComparator.sort(factories);
|
||||
return factories;
|
||||
}
|
||||
|
||||
protected void processBean(final List<EventListenerFactory> factories, final String beanName, final Class<?> targetType) {
|
||||
|
||||
@@ -17,10 +17,12 @@
|
||||
package org.springframework.scheduling.annotation;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.IdentityHashMap;
|
||||
import java.util.LinkedHashSet;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TimeZone;
|
||||
@@ -53,6 +55,7 @@ import org.springframework.context.event.ContextRefreshedEvent;
|
||||
import org.springframework.core.MethodIntrospector;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.scheduling.TaskScheduler;
|
||||
import org.springframework.scheduling.Trigger;
|
||||
import org.springframework.scheduling.config.CronTask;
|
||||
@@ -207,9 +210,11 @@ public class ScheduledAnnotationBeanPostProcessor
|
||||
}
|
||||
|
||||
if (this.beanFactory instanceof ListableBeanFactory) {
|
||||
Map<String, SchedulingConfigurer> configurers =
|
||||
Map<String, SchedulingConfigurer> beans =
|
||||
((ListableBeanFactory) this.beanFactory).getBeansOfType(SchedulingConfigurer.class);
|
||||
for (SchedulingConfigurer configurer : configurers.values()) {
|
||||
List<SchedulingConfigurer> configurers = new ArrayList<SchedulingConfigurer>(beans.values());
|
||||
AnnotationAwareOrderComparator.sort(configurers);
|
||||
for (SchedulingConfigurer configurer : configurers) {
|
||||
configurer.configureTasks(this.registrar);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -17,7 +17,9 @@
|
||||
package org.springframework.jms.annotation;
|
||||
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
@@ -41,6 +43,7 @@ import org.springframework.beans.factory.support.RootBeanDefinition;
|
||||
import org.springframework.core.MethodIntrospector;
|
||||
import org.springframework.core.Ordered;
|
||||
import org.springframework.core.annotation.AnnotatedElementUtils;
|
||||
import org.springframework.core.annotation.AnnotationAwareOrderComparator;
|
||||
import org.springframework.jms.config.JmsListenerConfigUtils;
|
||||
import org.springframework.jms.config.JmsListenerContainerFactory;
|
||||
import org.springframework.jms.config.JmsListenerEndpointRegistrar;
|
||||
@@ -166,9 +169,11 @@ public class JmsListenerAnnotationBeanPostProcessor
|
||||
|
||||
if (this.beanFactory instanceof ListableBeanFactory) {
|
||||
// Apply JmsListenerConfigurer beans from the BeanFactory, if any
|
||||
Map<String, JmsListenerConfigurer> instances =
|
||||
Map<String, JmsListenerConfigurer> beans =
|
||||
((ListableBeanFactory) this.beanFactory).getBeansOfType(JmsListenerConfigurer.class);
|
||||
for (JmsListenerConfigurer configurer : instances.values()) {
|
||||
List<JmsListenerConfigurer> configurers = new ArrayList<JmsListenerConfigurer>(beans.values());
|
||||
AnnotationAwareOrderComparator.sort(configurers);
|
||||
for (JmsListenerConfigurer configurer : configurers) {
|
||||
configurer.configureJmsListeners(this.registrar);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2016 the original author or authors.
|
||||
* Copyright 2002-2017 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -148,13 +148,13 @@ public class ResourceUrlProvider implements ApplicationListener<ContextRefreshed
|
||||
protected void detectResourceHandlers(ApplicationContext appContext) {
|
||||
logger.debug("Looking for resource handler mappings");
|
||||
|
||||
Map<String, SimpleUrlHandlerMapping> map = appContext.getBeansOfType(SimpleUrlHandlerMapping.class);
|
||||
List<SimpleUrlHandlerMapping> handlerMappings = new ArrayList<SimpleUrlHandlerMapping>(map.values());
|
||||
AnnotationAwareOrderComparator.sort(handlerMappings);
|
||||
Map<String, SimpleUrlHandlerMapping> beans = appContext.getBeansOfType(SimpleUrlHandlerMapping.class);
|
||||
List<SimpleUrlHandlerMapping> mappings = new ArrayList<SimpleUrlHandlerMapping>(beans.values());
|
||||
AnnotationAwareOrderComparator.sort(mappings);
|
||||
|
||||
for (SimpleUrlHandlerMapping hm : handlerMappings) {
|
||||
for (String pattern : hm.getHandlerMap().keySet()) {
|
||||
Object handler = hm.getHandlerMap().get(pattern);
|
||||
for (SimpleUrlHandlerMapping mapping : mappings) {
|
||||
for (String pattern : mapping.getHandlerMap().keySet()) {
|
||||
Object handler = mapping.getHandlerMap().get(pattern);
|
||||
if (handler instanceof ResourceHttpRequestHandler) {
|
||||
ResourceHttpRequestHandler resourceHandler = (ResourceHttpRequestHandler) handler;
|
||||
if (logger.isDebugEnabled()) {
|
||||
|
||||
Reference in New Issue
Block a user