提交 d3ea2420 编写于 作者: J Juergen Hoeller

Polishing

上级 40cd277b
......@@ -153,14 +153,13 @@ import org.springframework.web.util.UrlPathHelper;
* libraries available on the classpath.
* </ul>
*
* @see EnableWebMvc
* @see WebMvcConfigurer
* @see WebMvcConfigurerAdapter
*
* @author Rossen Stoyanchev
* @author Brian Clozel
* @author Sebastien Deleuze
* @since 3.1
* @see EnableWebMvc
* @see WebMvcConfigurer
* @see WebMvcConfigurerAdapter
*/
public class WebMvcConfigurationSupport implements ApplicationContextAware, ServletContextAware {
......@@ -181,34 +180,34 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
ClassUtils.isPresent("com.google.gson.Gson", WebMvcConfigurationSupport.class.getClassLoader());
private ServletContext servletContext;
private ApplicationContext applicationContext;
private ServletContext servletContext;
private List<Object> interceptors;
private PathMatchConfigurer pathMatchConfigurer;
private ContentNegotiationManager contentNegotiationManager;
private List<HttpMessageConverter<?>> messageConverters;
private PathMatchConfigurer pathMatchConfigurer;
/**
* Set the {@link javax.servlet.ServletContext}, e.g. for resource handling,
* looking up file extensions, etc.
* Set the Spring {@link ApplicationContext}, e.g. for resource loading.
*/
@Override
public void setServletContext(ServletContext servletContext) {
this.servletContext = servletContext;
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
}
/**
* Set the Spring {@link ApplicationContext}, e.g. for resource loading.
* Set the {@link javax.servlet.ServletContext}, e.g. for resource handling,
* looking up file extensions, etc.
*/
@Override
public void setApplicationContext(ApplicationContext applicationContext) {
this.applicationContext = applicationContext;
public void setServletContext(ServletContext servletContext) {
this.servletContext = servletContext;
}
......@@ -239,23 +238,8 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
if (configurer.getUrlPathHelper() != null) {
handlerMapping.setUrlPathHelper(configurer.getUrlPathHelper());
}
return handlerMapping;
}
protected PathMatchConfigurer getPathMatchConfigurer() {
if (this.pathMatchConfigurer == null) {
this.pathMatchConfigurer = new PathMatchConfigurer();
configurePathMatch(this.pathMatchConfigurer);
}
return this.pathMatchConfigurer;
}
/**
* Override this method to configure path matching options.
* @see PathMatchConfigurer
* @since 4.0.3
*/
public void configurePathMatch(PathMatchConfigurer configurer) {
return handlerMapping;
}
/**
......@@ -282,6 +266,27 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
protected void addInterceptors(InterceptorRegistry registry) {
}
/**
* Callback for building the {@link PathMatchConfigurer}.
* Delegates to {@link #configurePathMatch}.
* @since 4.1
*/
protected PathMatchConfigurer getPathMatchConfigurer() {
if (this.pathMatchConfigurer == null) {
this.pathMatchConfigurer = new PathMatchConfigurer();
configurePathMatch(this.pathMatchConfigurer);
}
return this.pathMatchConfigurer;
}
/**
* Override this method to configure path matching options.
* @see PathMatchConfigurer
* @since 4.0.3
*/
public void configurePathMatch(PathMatchConfigurer configurer) {
}
/**
* Return a {@link ContentNegotiationManager} instance to use to determine
* requested {@linkplain MediaType media types} in a given request.
......@@ -295,8 +300,8 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
try {
this.contentNegotiationManager = configurer.getContentNegotiationManager();
}
catch (Exception e) {
throw new BeanInitializationException("Could not create ContentNegotiationManager", e);
catch (Exception ex) {
throw new BeanInitializationException("Could not create ContentNegotiationManager", ex);
}
}
return this.contentNegotiationManager;
......@@ -680,7 +685,6 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
public void configureAsyncSupport(AsyncSupportConfigurer configurer) {
}
/**
* Return an instance of {@link CompositeUriComponentsContributor} for use with
* {@link org.springframework.web.servlet.mvc.method.annotation.MvcUriComponentsBuilder}.
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册