Browse Source

Various @since tags (and varargs on setInterceptors)

pull/1155/head
Juergen Hoeller 9 years ago
parent
commit
aac0e632ae
  1. 3
      spring-web/src/main/java/org/springframework/web/util/UriComponentsBuilder.java
  2. 73
      spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurationSupport.java
  3. 1
      spring-webmvc/src/main/java/org/springframework/web/servlet/config/annotation/WebMvcConfigurer.java
  4. 18
      spring-webmvc/src/main/java/org/springframework/web/servlet/handler/AbstractHandlerMapping.java

3
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. * Create a deep copy of the given UriComponentsBuilder.
* @param other the other builder to copy from * @param other the other builder to copy from
* @since 4.1.3
*/ */
protected UriComponentsBuilder(UriComponentsBuilder other) { protected UriComponentsBuilder(UriComponentsBuilder other) {
this.scheme = other.scheme; this.scheme = other.scheme;
@ -603,6 +604,7 @@ public class UriComponentsBuilder implements Cloneable {
* Add the given query parameters. * Add the given query parameters.
* @param params the params * @param params the params
* @return this UriComponentsBuilder * @return this UriComponentsBuilder
* @since 4.0
*/ */
public UriComponentsBuilder queryParams(MultiValueMap<String, String> params) { public UriComponentsBuilder queryParams(MultiValueMap<String, String> params) {
if (params != null) { if (params != null) {
@ -632,6 +634,7 @@ public class UriComponentsBuilder implements Cloneable {
* Set the query parameter values overriding all existing query values. * Set the query parameter values overriding all existing query values.
* @param params the query parameter name * @param params the query parameter name
* @return this UriComponentsBuilder * @return this UriComponentsBuilder
* @since 4.2
*/ */
public UriComponentsBuilder replaceQueryParams(MultiValueMap<String, String> params) { public UriComponentsBuilder replaceQueryParams(MultiValueMap<String, String> params) {
this.queryParams.clear(); this.queryParams.clear();

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

@ -213,6 +213,10 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
this.applicationContext = applicationContext; this.applicationContext = applicationContext;
} }
/**
* Return the associated Spring {@link ApplicationContext}.
* @since 4.2
*/
public ApplicationContext getApplicationContext() { public ApplicationContext getApplicationContext() {
return this.applicationContext; return this.applicationContext;
} }
@ -226,6 +230,10 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
this.servletContext = servletContext; this.servletContext = servletContext;
} }
/**
* Return the associated {@link javax.servlet.ServletContext}.
* @since 4.2
*/
public ServletContext getServletContext() { public ServletContext getServletContext() {
return this.servletContext; return this.servletContext;
} }
@ -268,6 +276,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
/** /**
* Protected method for plugging in a custom subclass of * Protected method for plugging in a custom subclass of
* {@link RequestMappingHandlerMapping}. * {@link RequestMappingHandlerMapping}.
* @since 4.0
*/ */
protected RequestMappingHandlerMapping createRequestMappingHandlerMapping() { protected RequestMappingHandlerMapping createRequestMappingHandlerMapping() {
return new RequestMappingHandlerMapping(); return new RequestMappingHandlerMapping();
@ -318,6 +327,32 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
public void configurePathMatch(PathMatchConfigurer configurer) { public 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 * Return a {@link ContentNegotiationManager} instance to use to determine
* requested {@linkplain MediaType media types} in a given request. * requested {@linkplain MediaType media types} in a given request.
@ -414,8 +449,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
if (handlerMapping != null) { if (handlerMapping != null) {
handlerMapping.setPathMatcher(mvcPathMatcher()); handlerMapping.setPathMatcher(mvcPathMatcher());
handlerMapping.setUrlPathHelper(mvcUrlPathHelper()); handlerMapping.setUrlPathHelper(mvcUrlPathHelper());
handlerMapping.setInterceptors(new HandlerInterceptor[] { handlerMapping.setInterceptors(new ResourceUrlProviderExposingInterceptor(mvcResourceUrlProvider()));
new ResourceUrlProviderExposingInterceptor(mvcResourceUrlProvider())});
handlerMapping.setCorsConfigurations(getCorsConfigurations()); handlerMapping.setCorsConfigurations(getCorsConfigurations());
} }
else { else {
@ -431,6 +465,10 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
protected void addResourceHandlers(ResourceHandlerRegistry registry) { protected void addResourceHandlers(ResourceHandlerRegistry registry) {
} }
/**
* A {@link ResourceUrlProvider} bean for use with the MVC dispatcher.
* @since 4.1
*/
@Bean @Bean
public ResourceUrlProvider mvcResourceUrlProvider() { public ResourceUrlProvider mvcResourceUrlProvider() {
ResourceUrlProvider urlProvider = new ResourceUrlProvider(); ResourceUrlProvider urlProvider = new ResourceUrlProvider();
@ -596,36 +634,6 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
return null; 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());
}
/** /**
* Add custom {@link HandlerMethodArgumentResolver}s to use in addition to * Add custom {@link HandlerMethodArgumentResolver}s to use in addition to
* the ones registered by default. * the ones registered by default.
@ -739,6 +747,7 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
/** /**
* Return an instance of {@link CompositeUriComponentsContributor} for use with * Return an instance of {@link CompositeUriComponentsContributor} for use with
* {@link org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder}. * {@link org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder}.
* @since 4.0
*/ */
@Bean @Bean
public CompositeUriComponentsContributor mvcUriComponentsContributor() { public CompositeUriComponentsContributor mvcUriComponentsContributor() {

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

@ -149,6 +149,7 @@ public interface WebMvcConfigurer {
* Configure view resolvers to translate String-based view names returned from * Configure view resolvers to translate String-based view names returned from
* controllers into concrete {@link org.springframework.web.servlet.View} * controllers into concrete {@link org.springframework.web.servlet.View}
* implementations to perform rendering with. * implementations to perform rendering with.
* @since 4.1
*/ */
void configureViewResolvers(ViewResolverRegistry registry); void configureViewResolvers(ViewResolverRegistry registry);

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

@ -1,5 +1,5 @@
/* /*
* Copyright 2002-2015 the original author or authors. * Copyright 2002-2016 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.
@ -27,21 +27,21 @@ import javax.servlet.http.HttpServletResponse;
import org.springframework.beans.BeansException; import org.springframework.beans.BeansException;
import org.springframework.beans.factory.BeanFactoryUtils; import org.springframework.beans.factory.BeanFactoryUtils;
import org.springframework.core.Ordered; import org.springframework.core.Ordered;
import org.springframework.web.HttpRequestHandler;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.cors.CorsProcessor;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.util.AntPathMatcher; import org.springframework.util.AntPathMatcher;
import org.springframework.util.Assert; import org.springframework.util.Assert;
import org.springframework.util.PathMatcher; import org.springframework.util.PathMatcher;
import org.springframework.web.HttpRequestHandler;
import org.springframework.web.context.request.WebRequestInterceptor; import org.springframework.web.context.request.WebRequestInterceptor;
import org.springframework.web.context.support.WebApplicationObjectSupport; import org.springframework.web.context.support.WebApplicationObjectSupport;
import org.springframework.web.cors.CorsConfiguration;
import org.springframework.web.cors.CorsConfigurationSource;
import org.springframework.web.cors.CorsProcessor;
import org.springframework.web.cors.CorsUtils;
import org.springframework.web.cors.DefaultCorsProcessor;
import org.springframework.web.cors.UrlBasedCorsConfigurationSource;
import org.springframework.web.servlet.HandlerExecutionChain; import org.springframework.web.servlet.HandlerExecutionChain;
import org.springframework.web.servlet.HandlerInterceptor; import org.springframework.web.servlet.HandlerInterceptor;
import org.springframework.web.servlet.HandlerMapping; import org.springframework.web.servlet.HandlerMapping;
import org.springframework.web.cors.DefaultCorsProcessor;
import org.springframework.web.cors.CorsUtils;
import org.springframework.web.util.UrlPathHelper; import org.springframework.web.util.UrlPathHelper;
/** /**
@ -197,7 +197,7 @@ public abstract class AbstractHandlerMapping extends WebApplicationObjectSupport
* @see org.springframework.web.servlet.HandlerInterceptor * @see org.springframework.web.servlet.HandlerInterceptor
* @see org.springframework.web.context.request.WebRequestInterceptor * @see org.springframework.web.context.request.WebRequestInterceptor
*/ */
public void setInterceptors(Object[] interceptors) { public void setInterceptors(Object... interceptors) {
this.interceptors.addAll(Arrays.asList(interceptors)); this.interceptors.addAll(Arrays.asList(interceptors));
} }

Loading…
Cancel
Save