Skip to content

Commit 1cbc353

Browse files
committed
Consistent Ordered.LOWEST_PRECEDENCE declarations for default order
(cherry picked from commit 6393e5c)
1 parent 4cf1795 commit 1cbc353

File tree

10 files changed

+75
-64
lines changed

10 files changed

+75
-64
lines changed

spring-aop/src/main/java/org/springframework/aop/framework/ProxyProcessorSupport.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -50,9 +50,9 @@ public class ProxyProcessorSupport extends ProxyConfig implements Ordered, BeanC
5050

5151

5252
/**
53-
* Set the ordering which will apply to this class's implementation
54-
* of Ordered, used when applying multiple processors.
55-
* <p>Default value is {@code Integer.MAX_VALUE}, meaning that it's non-ordered.
53+
* Set the ordering which will apply to this processor's implementation
54+
* of {@link Ordered}, used when applying multiple processors.
55+
* <p>The default value is {@code Ordered.LOWEST_PRECEDENCE}, meaning non-ordered.
5656
* @param order the ordering value
5757
*/
5858
public void setOrder(int order) {

spring-aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
4545

4646
private final Set<Class<?>> interfaces = new LinkedHashSet<Class<?>>();
4747

48-
private int order = Integer.MAX_VALUE;
48+
private int order = Ordered.LOWEST_PRECEDENCE;
4949

5050

5151
/**
@@ -118,7 +118,6 @@ public void validateInterfaces() throws IllegalArgumentException {
118118
}
119119
}
120120

121-
122121
public void setOrder(int order) {
123122
this.order = order;
124123
}
@@ -128,7 +127,6 @@ public int getOrder() {
128127
return this.order;
129128
}
130129

131-
132130
@Override
133131
public Advice getAdvice() {
134132
return this.advice;

spring-aop/src/main/java/org/springframework/aop/support/StaticMethodMatcherPointcutAdvisor.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -36,10 +36,10 @@
3636
public abstract class StaticMethodMatcherPointcutAdvisor extends StaticMethodMatcherPointcut
3737
implements PointcutAdvisor, Ordered, Serializable {
3838

39-
private int order = Integer.MAX_VALUE;
40-
4139
private Advice advice;
4240

41+
private int order = Integer.MAX_VALUE;
42+
4343

4444
/**
4545
* Create a new StaticMethodMatcherPointcutAdvisor,

spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistry.java

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2017 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -25,6 +25,7 @@
2525

2626
import org.springframework.beans.factory.BeanInitializationException;
2727
import org.springframework.context.ApplicationContext;
28+
import org.springframework.core.Ordered;
2829
import org.springframework.util.Assert;
2930
import org.springframework.web.HttpRequestHandler;
3031
import org.springframework.web.accept.ContentNegotiationManager;
@@ -62,7 +63,7 @@ public class ResourceHandlerRegistry {
6263

6364
private final List<ResourceHandlerRegistration> registrations = new ArrayList<ResourceHandlerRegistration>();
6465

65-
private int order = Integer.MAX_VALUE -1;
66+
private int order = Ordered.LOWEST_PRECEDENCE - 1;
6667

6768

6869
/**

spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,6 @@
6666
*/
6767
public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport implements HandlerMapping, Ordered {
6868

69-
private int order = Integer.MAX_VALUE; // default: same as non-Ordered
70-
7169
private Object defaultHandler;
7270

7371
private UrlPathHelper urlPathHelper = new UrlPathHelper();
@@ -82,20 +80,8 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
8280

8381
private CorsProcessor corsProcessor = new DefaultCorsProcessor();
8482

83+
private int order = Ordered.LOWEST_PRECEDENCE; // default: same as non-Ordered
8584

86-
/**
87-
* Specify the order value for this HandlerMapping bean.
88-
* <p>Default value is {@code Integer.MAX_VALUE}, meaning that it's non-ordered.
89-
* @see org.springframework.core.Ordered#getOrder()
90-
*/
91-
public final void setOrder(int order) {
92-
this.order = order;
93-
}
94-
95-
@Override
96-
public final int getOrder() {
97-
return this.order;
98-
}
9985

10086
/**
10187
* Set the default handler for this handler mapping.
@@ -235,6 +221,20 @@ public CorsProcessor getCorsProcessor() {
235221
return this.corsProcessor;
236222
}
237223

224+
/**
225+
* Specify the order value for this HandlerMapping bean.
226+
* <p>The default value is {@code Ordered.LOWEST_PRECEDENCE}, meaning non-ordered.
227+
* @see org.springframework.core.Ordered#getOrder()
228+
*/
229+
public void setOrder(int order) {
230+
this.order = order;
231+
}
232+
233+
@Override
234+
public int getOrder() {
235+
return this.order;
236+
}
237+
238238

239239
/**
240240
* Initializes the interceptors.

spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/AbstractHandlerMethodAdapter.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -45,7 +45,7 @@ public AbstractHandlerMethodAdapter() {
4545

4646
/**
4747
* Specify the order value for this HandlerAdapter bean.
48-
* <p>Default value is {@code Integer.MAX_VALUE}, meaning that it's non-ordered.
48+
* <p>The default value is {@code Ordered.LOWEST_PRECEDENCE}, meaning non-ordered.
4949
* @see org.springframework.core.Ordered#getOrder()
5050
*/
5151
public void setOrder(int order) {

spring-webmvc/src/main/java/org/springframework/web/servlet/view/BeanNameViewResolver.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -53,9 +53,14 @@
5353
*/
5454
public class BeanNameViewResolver extends WebApplicationObjectSupport implements ViewResolver, Ordered {
5555

56-
private int order = Integer.MAX_VALUE; // default: same as non-Ordered
56+
private int order = Ordered.LOWEST_PRECEDENCE; // default: same as non-Ordered
5757

5858

59+
/**
60+
* Specify the order value for this ViewResolver bean.
61+
* <p>The default value is {@code Ordered.LOWEST_PRECEDENCE}, meaning non-ordered.
62+
* @see org.springframework.core.Ordered#getOrder()
63+
*/
5964
public void setOrder(int order) {
6065
this.order = order;
6166
}

spring-webmvc/src/main/java/org/springframework/web/servlet/view/ResourceBundleViewResolver.java

Lines changed: 18 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2014 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -63,11 +63,9 @@ public class ResourceBundleViewResolver extends AbstractCachingViewResolver
6363
implements Ordered, InitializingBean, DisposableBean {
6464

6565
/** The default basename if no other basename is supplied. */
66-
public final static String DEFAULT_BASENAME = "views";
66+
public static final String DEFAULT_BASENAME = "views";
6767

6868

69-
private int order = Integer.MAX_VALUE; // default: same as non-Ordered
70-
7169
private String[] basenames = new String[] {DEFAULT_BASENAME};
7270

7371
private ClassLoader bundleClassLoader = Thread.currentThread().getContextClassLoader();
@@ -76,6 +74,8 @@ public class ResourceBundleViewResolver extends AbstractCachingViewResolver
7674

7775
private Locale[] localesToInitialize;
7876

77+
private int order = Ordered.LOWEST_PRECEDENCE; // default: same as non-Ordered
78+
7979
/* Locale -> BeanFactory */
8080
private final Map<Locale, BeanFactory> localeCache =
8181
new HashMap<Locale, BeanFactory>();
@@ -85,15 +85,6 @@ public class ResourceBundleViewResolver extends AbstractCachingViewResolver
8585
new HashMap<List<ResourceBundle>, ConfigurableApplicationContext>();
8686

8787

88-
public void setOrder(int order) {
89-
this.order = order;
90-
}
91-
92-
@Override
93-
public int getOrder() {
94-
return this.order;
95-
}
96-
9788
/**
9889
* Set a single basename, following {@link java.util.ResourceBundle} conventions.
9990
* The default is "views".
@@ -175,6 +166,20 @@ public void setLocalesToInitialize(Locale... localesToInitialize) {
175166
this.localesToInitialize = localesToInitialize;
176167
}
177168

169+
/**
170+
* Specify the order value for this ViewResolver bean.
171+
* <p>The default value is {@code Ordered.LOWEST_PRECEDENCE}, meaning non-ordered.
172+
* @see org.springframework.core.Ordered#getOrder()
173+
*/
174+
public void setOrder(int order) {
175+
this.order = order;
176+
}
177+
178+
@Override
179+
public int getOrder() {
180+
return this.order;
181+
}
182+
178183
/**
179184
* Eagerly initialize Locales if necessary.
180185
* @see #setLocalesToInitialize

spring-webmvc/src/main/java/org/springframework/web/servlet/view/UrlBasedViewResolver.java

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2016 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -128,7 +128,7 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
128128

129129
private String[] viewNames;
130130

131-
private int order = Integer.MAX_VALUE;
131+
private int order = Ordered.LOWEST_PRECEDENCE;
132132

133133

134134
/**
@@ -407,17 +407,14 @@ protected String[] getViewNames() {
407407
}
408408

409409
/**
410-
* Set the order in which this {@link org.springframework.web.servlet.ViewResolver}
411-
* is evaluated.
410+
* Specify the order value for this ViewResolver bean.
411+
* <p>The default value is {@code Ordered.LOWEST_PRECEDENCE}, meaning non-ordered.
412+
* @see org.springframework.core.Ordered#getOrder()
412413
*/
413414
public void setOrder(int order) {
414415
this.order = order;
415416
}
416417

417-
/**
418-
* Return the order in which this {@link org.springframework.web.servlet.ViewResolver}
419-
* is evaluated.
420-
*/
421418
@Override
422419
public int getOrder() {
423420
return this.order;

spring-webmvc/src/main/java/org/springframework/web/servlet/view/XmlViewResolver.java

Lines changed: 17 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2012 the original author or authors.
2+
* Copyright 2002-2018 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -57,24 +57,15 @@ public class XmlViewResolver extends AbstractCachingViewResolver
5757
implements Ordered, InitializingBean, DisposableBean {
5858

5959
/** Default if no other location is supplied */
60-
public final static String DEFAULT_LOCATION = "/WEB-INF/views.xml";
60+
public static final String DEFAULT_LOCATION = "/WEB-INF/views.xml";
6161

6262

63-
private int order = Integer.MAX_VALUE; // default: same as non-Ordered
64-
6563
private Resource location;
6664

6765
private ConfigurableApplicationContext cachedFactory;
6866

67+
private int order = Ordered.LOWEST_PRECEDENCE; // default: same as non-Ordered
6968

70-
public void setOrder(int order) {
71-
this.order = order;
72-
}
73-
74-
@Override
75-
public int getOrder() {
76-
return this.order;
77-
}
7869

7970
/**
8071
* Set the location of the XML file that defines the view beans.
@@ -85,6 +76,20 @@ public void setLocation(Resource location) {
8576
this.location = location;
8677
}
8778

79+
/**
80+
* Specify the order value for this ViewResolver bean.
81+
* <p>The default value is {@code Ordered.LOWEST_PRECEDENCE}, meaning non-ordered.
82+
* @see org.springframework.core.Ordered#getOrder()
83+
*/
84+
public void setOrder(int order) {
85+
this.order = order;
86+
}
87+
88+
@Override
89+
public int getOrder() {
90+
return this.order;
91+
}
92+
8893
/**
8994
* Pre-initialize the factory from the XML file.
9095
* Only effective if caching is enabled.

0 commit comments

Comments
 (0)