From 7bb4ab68423ef710ffa92dc1fad3fc668ba6d051 Mon Sep 17 00:00:00 2001 From: Juergen Hoeller Date: Thu, 18 Aug 2016 12:31:21 +0200 Subject: [PATCH] Various @since tags (and varargs on setInterceptors) (cherry picked from commit 5222489) --- .../web/util/UriComponentsBuilder.java | 3 + .../WebMvcConfigurationSupport.java | 83 +++++++++++-------- .../config/annotation/WebMvcConfigurer.java | 1 + .../handler/AbstractHandlerMapping.java | 2 +- 4 files changed, 53 insertions(+), 36 deletions(-) diff --git a/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java b/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java index aa56a877e9d..a25b59634ac 100644 --- a/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java +++ b/spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java @@ -124,6 +124,7 @@ public class UriComponentsBuilder implements Cloneable { /** * Create a deep copy of the given UriComponentsBuilder. * @param other the other builder to copy from + * @since 4.1.3 */ protected UriComponentsBuilder(UriComponentsBuilder other) { this.scheme = other.scheme; @@ -603,6 +604,7 @@ public class UriComponentsBuilder implements Cloneable { * Add the given query parameters. * @param params the params * @return this UriComponentsBuilder + * @since 4.0 */ public UriComponentsBuilder queryParams(MultiValueMap params) { if (params != null) { @@ -632,6 +634,7 @@ public class UriComponentsBuilder implements Cloneable { * Set the query parameter values overriding all existing query values. * @param params the query parameter name * @return this UriComponentsBuilder + * @since 4.2 */ public UriComponentsBuilder replaceQueryParams(MultiValueMap params) { this.queryParams.clear(); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java index 708e507d242..fdb81aeb5a6 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java @@ -214,6 +214,10 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv this.applicationContext = applicationContext; } + /** + * Return the associated Spring {@link ApplicationContext}. + * @since 4.2 + */ public ApplicationContext getApplicationContext() { return this.applicationContext; } @@ -227,6 +231,10 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv this.servletContext = servletContext; } + /** + * Return the associated {@link javax.servlet.ServletContext}. + * @since 4.2 + */ public ServletContext getServletContext() { return this.servletContext; } @@ -267,8 +275,9 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv } /** - * Protected method for plugging in a custom sub-class of + * Protected method for plugging in a custom subclass of * {@link RequestMappingHandlerMapping}. + * @since 4.0 */ protected RequestMappingHandlerMapping createRequestMappingHandlerMapping() { return new RequestMappingHandlerMapping(); @@ -319,6 +328,32 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv protected void configurePathMatch(PathMatchConfigurer configurer) { } + /** + * Return a global {@link PathMatcher} instance for path matching + * patterns in {@link HandlerMapping}s. + * This instance can be configured using the {@link PathMatchConfigurer} + * in {@link #configurePathMatch(PathMatchConfigurer)}. + * @since 4.1 + */ + @Bean + public PathMatcher mvcPathMatcher() { + PathMatcher pathMatcher = getPathMatchConfigurer().getPathMatcher(); + return (pathMatcher != null ? pathMatcher : new AntPathMatcher()); + } + + /** + * Return a global {@link UrlPathHelper} instance for path matching + * patterns in {@link HandlerMapping}s. + * This instance can be configured using the {@link PathMatchConfigurer} + * in {@link #configurePathMatch(PathMatchConfigurer)}. + * @since 4.1 + */ + @Bean + public UrlPathHelper mvcUrlPathHelper() { + UrlPathHelper pathHelper = getPathMatchConfigurer().getUrlPathHelper(); + return (pathHelper != null ? pathHelper : new UrlPathHelper()); + } + /** * Return a {@link ContentNegotiationManager} instance to use to determine * requested {@linkplain MediaType media types} in a given request. @@ -416,8 +451,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv if (handlerMapping != null) { handlerMapping.setPathMatcher(mvcPathMatcher()); handlerMapping.setUrlPathHelper(mvcUrlPathHelper()); - handlerMapping.setInterceptors(new HandlerInterceptor[] { - new ResourceUrlProviderExposingInterceptor(mvcResourceUrlProvider())}); + handlerMapping.setInterceptors(new ResourceUrlProviderExposingInterceptor(mvcResourceUrlProvider())); handlerMapping.setCorsConfigurations(getCorsConfigurations()); } else { @@ -433,6 +467,10 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv protected void addResourceHandlers(ResourceHandlerRegistry registry) { } + /** + * A {@link ResourceUrlProvider} bean for use with the MVC dispatcher. + * @since 4.1 + */ @Bean public ResourceUrlProvider mvcResourceUrlProvider() { ResourceUrlProvider urlProvider = new ResourceUrlProvider(); @@ -507,8 +545,9 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv } /** - * Protected method for plugging in a custom sub-class of + * Protected method for plugging in a custom subclass of * {@link RequestMappingHandlerAdapter}. + * @since 4.3 */ protected RequestMappingHandlerAdapter createRequestMappingHandlerAdapter() { return new RequestMappingHandlerAdapter(); @@ -598,41 +637,12 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv return null; } - /** - * Return a global {@link PathMatcher} instance for path matching - * patterns in {@link HandlerMapping}s. - * This instance can be configured using the {@link PathMatchConfigurer} - * in {@link #configurePathMatch(PathMatchConfigurer)}. - * @since 4.1 - */ - @Bean - public PathMatcher mvcPathMatcher() { - if (getPathMatchConfigurer().getPathMatcher() != null) { - return getPathMatchConfigurer().getPathMatcher(); - } - else { - return new AntPathMatcher(); - } - } - - /** - * Return a global {@link UrlPathHelper} instance for path matching - * patterns in {@link HandlerMapping}s. - * This instance can be configured using the {@link PathMatchConfigurer} - * in {@link #configurePathMatch(PathMatchConfigurer)}. - * @since 4.1 - */ - @Bean - public UrlPathHelper mvcUrlPathHelper() { - UrlPathHelper pathHelper = getPathMatchConfigurer().getUrlPathHelper(); - return (pathHelper != null ? pathHelper : new UrlPathHelper()); - } - /** * Provide access to the shared custom argument resolvers used by the * {@link RequestMappingHandlerAdapter} and the * {@link ExceptionHandlerExceptionResolver}. This method cannot be * overridden, use {@link #addArgumentResolvers(List)} instead. + * @since 4.3 */ protected final List getArgumentResolvers() { if (this.argumentResolvers == null) { @@ -661,6 +671,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv * {@link RequestMappingHandlerAdapter} and the * {@link ExceptionHandlerExceptionResolver}. This method cannot be * overridden, use {@link #addReturnValueHandlers(List)} instead. + * @since 4.3 */ protected final List getReturnValueHandlers() { if (this.returnValueHandlers == null) { @@ -769,6 +780,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv /** * Return an instance of {@link CompositeUriComponentsContributor} for use with * {@link org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder}. + * @since 4.0 */ @Bean public CompositeUriComponentsContributor mvcUriComponentsContributor() { @@ -875,8 +887,9 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv } /** - * Protected method for plugging in a custom sub-class of + * Protected method for plugging in a custom subclass of * {@link ExceptionHandlerExceptionResolver}. + * @since 4.3 */ protected ExceptionHandlerExceptionResolver createExceptionHandlerExceptionResolver() { return new ExceptionHandlerExceptionResolver(); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurer.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurer.java index ca00aec989d..7e21c63d8a5 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurer.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurer.java @@ -123,6 +123,7 @@ public interface WebMvcConfigurer { * Configure view resolvers to translate String-based view names returned from * controllers into concrete {@link org.springframework.web.servlet.View} * implementations to perform rendering with. + * @since 4.1 */ void configureViewResolvers(ViewResolverRegistry registry); diff --git a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java index 98b7a440926..611acc36cc3 100644 --- a/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java +++ b/spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java @@ -197,7 +197,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport * @see org.springframework.web.servlet.HandlerInterceptor * @see org.springframework.web.context.request.WebRequestInterceptor */ - public void setInterceptors(Object[] interceptors) { + public void setInterceptors(Object... interceptors) { this.interceptors.addAll(Arrays.asList(interceptors)); }