Browse Source

Consistent Ordered.LOWEST_PRECEDENCE declarations for default order

pull/1771/merge
Juergen Hoeller 8 years ago
parent
commit
6393e5ce0c
  1. 8
      spring-aop/src/main/java/org/springframework/aop/framework/ProxyProcessorSupport.java
  2. 4
      spring-aop/src/main/java/org/springframework/aop/support/DefaultIntroductionAdvisor.java
  3. 6
      spring-aop/src/main/java/org/springframework/aop/support/StaticMethodMatcherPointcutAdvisor.java
  4. 5
      spring-webflux/src/main/java/org/springframework/web/reactive/config/ResourceHandlerRegistry.java
  5. 33
      spring-webflux/src/main/java/org/springframework/web/reactive/handler/AbstractHandlerMapping.java
  6. 10
      spring-webflux/src/main/java/org/springframework/web/reactive/result/view/ViewResolverSupport.java
  7. 5
      spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/ResourceHandlerRegistry.java
  8. 30
      spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java
  9. 4
      spring-webmvc/src/main/java/org/springframework/web/servlet/mvc/method/AbstractHandlerMethodAdapter.java
  10. 9
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/BeanNameViewResolver.java
  11. 27
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/ResourceBundleViewResolver.java
  12. 13
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/UrlBasedViewResolver.java
  13. 27
      spring-webmvc/src/main/java/org/springframework/web/servlet/view/XmlViewResolver.java

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -52,9 +52,9 @@ public class ProxyProcessorSupport extends ProxyConfig implements Ordered, BeanC
/** /**
* Set the ordering which will apply to this class's implementation * Set the ordering which will apply to this processor's implementation
* of Ordered, used when applying multiple processors. * of {@link Ordered}, used when applying multiple processors.
* <p>Default value is {@code Integer.MAX_VALUE}, meaning that it's non-ordered. * <p>The default value is {@code Ordered.LOWEST_PRECEDENCE}, meaning non-ordered.
* @param order the ordering value * @param order the ordering value
*/ */
public void setOrder(int order) { public void setOrder(int order) {

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

@ -46,7 +46,7 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
private final Set<Class<?>> interfaces = new LinkedHashSet<>(); private final Set<Class<?>> interfaces = new LinkedHashSet<>();
private int order = Integer.MAX_VALUE; private int order = Ordered.LOWEST_PRECEDENCE;
/** /**
@ -119,7 +119,6 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
} }
} }
public void setOrder(int order) { public void setOrder(int order) {
this.order = order; this.order = order;
} }
@ -129,7 +128,6 @@ public class DefaultIntroductionAdvisor implements IntroductionAdvisor, ClassFil
return this.order; return this.order;
} }
@Override @Override
public Advice getAdvice() { public Advice getAdvice() {
return this.advice; return this.advice;

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -36,10 +36,10 @@ import org.springframework.util.Assert;
public abstract class StaticMethodMatcherPointcutAdvisor extends StaticMethodMatcherPointcut public abstract class StaticMethodMatcherPointcutAdvisor extends StaticMethodMatcherPointcut
implements PointcutAdvisor, Ordered, Serializable { implements PointcutAdvisor, Ordered, Serializable {
private int order = Integer.MAX_VALUE;
private Advice advice = EMPTY_ADVICE; private Advice advice = EMPTY_ADVICE;
private int order = Ordered.LOWEST_PRECEDENCE;
/** /**
* Create a new StaticMethodMatcherPointcutAdvisor, * Create a new StaticMethodMatcherPointcutAdvisor,

5
spring-webflux/src/main/java/org/springframework/web/reactive/config/ResourceHandlerRegistry.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -23,6 +23,7 @@ import java.util.List;
import java.util.Map; import java.util.Map;
import org.springframework.beans.factory.BeanInitializationException; import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.core.Ordered;
import org.springframework.core.io.ResourceLoader; import org.springframework.core.io.ResourceLoader;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.web.reactive.handler.AbstractUrlHandlerMapping; import org.springframework.web.reactive.handler.AbstractUrlHandlerMapping;
@ -56,7 +57,7 @@ public class ResourceHandlerRegistry {
private final List<ResourceHandlerRegistration> registrations = new ArrayList<>(); private final List<ResourceHandlerRegistration> registrations = new ArrayList<>();
private int order = Integer.MAX_VALUE -1; private int order = Ordered.LOWEST_PRECEDENCE -1;
/** /**

33
spring-webflux/src/main/java/org/springframework/web/reactive/handler/AbstractHandlerMapping.java

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -49,33 +49,20 @@ public abstract class AbstractHandlerMapping extends ApplicationObjectSupport im
private static final WebHandler REQUEST_HANDLED_HANDLER = exchange -> Mono.empty(); private static final WebHandler REQUEST_HANDLED_HANDLER = exchange -> Mono.empty();
private int order = Integer.MAX_VALUE; // default: same as non-Ordered
private final PathPatternParser patternParser; private final PathPatternParser patternParser;
private final UrlBasedCorsConfigurationSource globalCorsConfigSource; private final UrlBasedCorsConfigurationSource globalCorsConfigSource;
private CorsProcessor corsProcessor = new DefaultCorsProcessor(); private CorsProcessor corsProcessor = new DefaultCorsProcessor();
private int order = Ordered.LOWEST_PRECEDENCE; // default: same as non-Ordered
public AbstractHandlerMapping() { public AbstractHandlerMapping() {
this.patternParser = new PathPatternParser(); this.patternParser = new PathPatternParser();
this.globalCorsConfigSource = new UrlBasedCorsConfigurationSource(this.patternParser); this.globalCorsConfigSource = new UrlBasedCorsConfigurationSource(this.patternParser);
} }
/**
* Specify the order value for this HandlerMapping bean.
* <p>Default value is {@code Integer.MAX_VALUE}, meaning that it's non-ordered.
* @see org.springframework.core.Ordered#getOrder()
*/
public final void setOrder(int order) {
this.order = order;
}
@Override
public final int getOrder() {
return this.order;
}
/** /**
* Shortcut method for setting the same property on the underlying pattern * Shortcut method for setting the same property on the underlying pattern
@ -140,6 +127,20 @@ public abstract class AbstractHandlerMapping extends ApplicationObjectSupport im
return this.corsProcessor; return this.corsProcessor;
} }
/**
* Specify the order value for this HandlerMapping bean.
* <p>The default value is {@code Ordered.LOWEST_PRECEDENCE}, meaning non-ordered.
* @see org.springframework.core.Ordered#getOrder()
*/
public void setOrder(int order) {
this.order = order;
}
@Override
public int getOrder() {
return this.order;
}
@Override @Override
public Mono<Object> getHandler(ServerWebExchange exchange) { public Mono<Object> getHandler(ServerWebExchange exchange) {

10
spring-webflux/src/main/java/org/springframework/web/reactive/result/view/ViewResolverSupport.java

@ -41,7 +41,7 @@ public abstract class ViewResolverSupport implements Ordered {
private Charset defaultCharset = StandardCharsets.UTF_8; private Charset defaultCharset = StandardCharsets.UTF_8;
private int order = Integer.MAX_VALUE; private int order = Ordered.LOWEST_PRECEDENCE;
public ViewResolverSupport() { public ViewResolverSupport() {
@ -84,17 +84,15 @@ public abstract class ViewResolverSupport implements Ordered {
return this.defaultCharset; return this.defaultCharset;
} }
/** /**
* Set the order in which this {@link ViewResolver} is evaluated. * Specify the order value for this ViewResolver bean.
* <p>The default value is {@code Ordered.LOWEST_PRECEDENCE}, meaning non-ordered.
* @see org.springframework.core.Ordered#getOrder()
*/ */
public void setOrder(int order) { public void setOrder(int order) {
this.order = order; this.order = order;
} }
/**
* Return the order in which this {@link ViewResolver} is evaluated.
*/
@Override @Override
public int getOrder() { public int getOrder() {
return this.order; return this.order;

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -25,6 +25,7 @@ import javax.servlet.ServletContext;
import org.springframework.beans.factory.BeanInitializationException; import org.springframework.beans.factory.BeanInitializationException;
import org.springframework.context.ApplicationContext; import org.springframework.context.ApplicationContext;
import org.springframework.core.Ordered;
import org.springframework.lang.Nullable; import org.springframework.lang.Nullable;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.web.HttpRequestHandler; import org.springframework.web.HttpRequestHandler;
@ -65,7 +66,7 @@ public class ResourceHandlerRegistry {
private final List<ResourceHandlerRegistration> registrations = new ArrayList<>(); private final List<ResourceHandlerRegistration> registrations = new ArrayList<>();
private int order = Integer.MAX_VALUE -1; private int order = Ordered.LOWEST_PRECEDENCE - 1;
/** /**

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

@ -67,8 +67,6 @@ import org.springframework.web.util.UrlPathHelper;
*/ */
public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport implements HandlerMapping, Ordered { public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport implements HandlerMapping, Ordered {
private int order = Integer.MAX_VALUE; // default: same as non-Ordered
@Nullable @Nullable
private Object defaultHandler; private Object defaultHandler;
@ -84,20 +82,8 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
private CorsProcessor corsProcessor = new DefaultCorsProcessor(); private CorsProcessor corsProcessor = new DefaultCorsProcessor();
private int order = Ordered.LOWEST_PRECEDENCE; // default: same as non-Ordered
/**
* Specify the order value for this HandlerMapping bean.
* <p>Default value is {@code Integer.MAX_VALUE}, meaning that it's non-ordered.
* @see org.springframework.core.Ordered#getOrder()
*/
public final void setOrder(int order) {
this.order = order;
}
@Override
public final int getOrder() {
return this.order;
}
/** /**
* Set the default handler for this handler mapping. * Set the default handler for this handler mapping.
@ -231,6 +217,20 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
return this.corsProcessor; return this.corsProcessor;
} }
/**
* Specify the order value for this HandlerMapping bean.
* <p>The default value is {@code Ordered.LOWEST_PRECEDENCE}, meaning non-ordered.
* @see org.springframework.core.Ordered#getOrder()
*/
public void setOrder(int order) {
this.order = order;
}
@Override
public int getOrder() {
return this.order;
}
/** /**
* Initializes the interceptors. * Initializes the interceptors.

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2014 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -46,7 +46,7 @@ public abstract class AbstractHandlerMethodAdapter extends WebContentGenerator i
/** /**
* Specify the order value for this HandlerAdapter bean. * Specify the order value for this HandlerAdapter bean.
* <p>Default value is {@code Integer.MAX_VALUE}, meaning that it's non-ordered. * <p>The default value is {@code Ordered.LOWEST_PRECEDENCE}, meaning non-ordered.
* @see org.springframework.core.Ordered#getOrder() * @see org.springframework.core.Ordered#getOrder()
*/ */
public void setOrder(int order) { public void setOrder(int order) {

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -54,9 +54,14 @@ import org.springframework.web.servlet.ViewResolver;
*/ */
public class BeanNameViewResolver extends WebApplicationObjectSupport implements ViewResolver, Ordered { public class BeanNameViewResolver extends WebApplicationObjectSupport implements ViewResolver, Ordered {
private int order = Integer.MAX_VALUE; // default: same as non-Ordered private int order = Ordered.LOWEST_PRECEDENCE; // default: same as non-Ordered
/**
* Specify the order value for this ViewResolver bean.
* <p>The default value is {@code Ordered.LOWEST_PRECEDENCE}, meaning non-ordered.
* @see org.springframework.core.Ordered#getOrder()
*/
public void setOrder(int order) { public void setOrder(int order) {
this.order = order; this.order = order;
} }

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2016 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -67,8 +67,6 @@ public class ResourceBundleViewResolver extends AbstractCachingViewResolver
public static final String DEFAULT_BASENAME = "views"; public static final String DEFAULT_BASENAME = "views";
private int order = Integer.MAX_VALUE; // default: same as non-Ordered
private String[] basenames = new String[] {DEFAULT_BASENAME}; private String[] basenames = new String[] {DEFAULT_BASENAME};
private ClassLoader bundleClassLoader = Thread.currentThread().getContextClassLoader(); private ClassLoader bundleClassLoader = Thread.currentThread().getContextClassLoader();
@ -85,15 +83,8 @@ public class ResourceBundleViewResolver extends AbstractCachingViewResolver
/* List of ResourceBundle -> BeanFactory */ /* List of ResourceBundle -> BeanFactory */
private final Map<List<ResourceBundle>, ConfigurableApplicationContext> bundleCache = new HashMap<>(); private final Map<List<ResourceBundle>, ConfigurableApplicationContext> bundleCache = new HashMap<>();
private int order = Ordered.LOWEST_PRECEDENCE; // default: same as non-Ordered
public void setOrder(int order) {
this.order = order;
}
@Override
public int getOrder() {
return this.order;
}
/** /**
* Set a single basename, following {@link java.util.ResourceBundle} conventions. * Set a single basename, following {@link java.util.ResourceBundle} conventions.
@ -176,6 +167,20 @@ public class ResourceBundleViewResolver extends AbstractCachingViewResolver
this.localesToInitialize = localesToInitialize; this.localesToInitialize = localesToInitialize;
} }
/**
* Specify the order value for this ViewResolver bean.
* <p>The default value is {@code Ordered.LOWEST_PRECEDENCE}, meaning non-ordered.
* @see org.springframework.core.Ordered#getOrder()
*/
public void setOrder(int order) {
this.order = order;
}
@Override
public int getOrder() {
return this.order;
}
/** /**
* Eagerly initialize Locales if necessary. * Eagerly initialize Locales if necessary.
* @see #setLocalesToInitialize * @see #setLocalesToInitialize

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -137,7 +137,7 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
@Nullable @Nullable
private String[] viewNames; private String[] viewNames;
private int order = Integer.MAX_VALUE; private int order = Ordered.LOWEST_PRECEDENCE;
/** /**
@ -423,17 +423,14 @@ public class UrlBasedViewResolver extends AbstractCachingViewResolver implements
} }
/** /**
* Set the order in which this {@link org.springframework.web.servlet.ViewResolver} * Specify the order value for this ViewResolver bean.
* is evaluated. * <p>The default value is {@code Ordered.LOWEST_PRECEDENCE}, meaning non-ordered.
* @see org.springframework.core.Ordered#getOrder()
*/ */
public void setOrder(int order) { public void setOrder(int order) {
this.order = order; this.order = order;
} }
/**
* Return the order in which this {@link org.springframework.web.servlet.ViewResolver}
* is evaluated.
*/
@Override @Override
public int getOrder() { public int getOrder() {
return this.order; return this.order;

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2017 the original author or authors. * Copyright 2002-2018 the original author or authors.
* *
* Licensed under the Apache License, Version 2.0 (the "License"); * Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License. * you may not use this file except in compliance with the License.
@ -62,23 +62,14 @@ public class XmlViewResolver extends AbstractCachingViewResolver
public static final String DEFAULT_LOCATION = "/WEB-INF/views.xml"; public static final String DEFAULT_LOCATION = "/WEB-INF/views.xml";
private int order = Integer.MAX_VALUE; // default: same as non-Ordered
@Nullable @Nullable
private Resource location; private Resource location;
@Nullable @Nullable
private ConfigurableApplicationContext cachedFactory; private ConfigurableApplicationContext cachedFactory;
private int order = Ordered.LOWEST_PRECEDENCE; // default: same as non-Ordered
public void setOrder(int order) {
this.order = order;
}
@Override
public int getOrder() {
return this.order;
}
/** /**
* Set the location of the XML file that defines the view beans. * Set the location of the XML file that defines the view beans.
@ -89,6 +80,20 @@ public class XmlViewResolver extends AbstractCachingViewResolver
this.location = location; this.location = location;
} }
/**
* Specify the order value for this ViewResolver bean.
* <p>The default value is {@code Ordered.LOWEST_PRECEDENCE}, meaning non-ordered.
* @see org.springframework.core.Ordered#getOrder()
*/
public void setOrder(int order) {
this.order = order;
}
@Override
public int getOrder() {
return this.order;
}
/** /**
* Pre-initialize the factory from the XML file. * Pre-initialize the factory from the XML file.
* Only effective if caching is enabled. * Only effective if caching is enabled.

Loading…
Cancel
Save