Skip to content

Commit e214ee5

Browse files
committed
Backport of WebMvcConfigurationSupport javadoc revision
1 parent 93ef169 commit e214ee5

File tree

1 file changed

+63
-74
lines changed

1 file changed

+63
-74
lines changed

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

Lines changed: 63 additions & 74 deletions
Original file line numberDiff line numberDiff line change
@@ -107,7 +107,7 @@
107107
* subclass and {@link Bean @Bean} to overridden {@link Bean @Bean} methods.
108108
* For more details see the javadoc of {@link EnableWebMvc @EnableWebMvc}.
109109
*
110-
* <p>This class registers the following {@link HandlerMapping}s:</p>
110+
* <p>This class registers the following {@link HandlerMapping HandlerMappings}:</p>
111111
* <ul>
112112
* <li>{@link RequestMappingHandlerMapping}
113113
* ordered at 0 for mapping requests to annotated controller methods.
@@ -121,14 +121,14 @@
121121
* ordered at {@code Integer.MAX_VALUE} to forward requests to the default servlet.
122122
* </ul>
123123
*
124-
* <p>Registers these {@link HandlerAdapter}s:
124+
* <p>Registers these {@link HandlerAdapter HandlerAdapters}:
125125
* <ul>
126126
* <li>{@link RequestMappingHandlerAdapter}
127127
* for processing requests with annotated controller methods.
128128
* <li>{@link HttpRequestHandlerAdapter}
129-
* for processing requests with {@link HttpRequestHandler}s.
129+
* for processing requests with {@link HttpRequestHandler HttpRequestHandlers}.
130130
* <li>{@link SimpleControllerHandlerAdapter}
131-
* for processing requests with interface-based {@link Controller}s.
131+
* for processing requests with interface-based {@link Controller Controllers}.
132132
* </ul>
133133
*
134134
* <p>Registers a {@link HandlerExceptionResolverComposite} with this chain of
@@ -159,7 +159,7 @@
159159
* <li>a {@link DefaultFormattingConversionService}
160160
* <li>a {@link org.springframework.validation.beanvalidation.OptionalValidatorFactoryBean}
161161
* if a JSR-303 implementation is available on the classpath
162-
* <li>a range of {@link HttpMessageConverter}s depending on the third-party
162+
* <li>a range of {@link HttpMessageConverter HttpMessageConverters} depending on the third-party
163163
* libraries available on the classpath.
164164
* </ul>
165165
*
@@ -172,7 +172,7 @@
172172
*/
173173
public class WebMvcConfigurationSupport implements ApplicationContextAware, ServletContextAware {
174174

175-
private static boolean romePresent =
175+
private static final boolean romePresent =
176176
ClassUtils.isPresent("com.rometools.rome.feed.WireFeed",
177177
WebMvcConfigurationSupport.class.getClassLoader());
178178

@@ -284,15 +284,16 @@ public RequestMappingHandlerMapping requestMappingHandlerMapping() {
284284
mapping.setCorsConfigurations(getCorsConfigurations());
285285

286286
PathMatchConfigurer configurer = getPathMatchConfigurer();
287+
287288
Boolean useSuffixPatternMatch = configurer.isUseSuffixPatternMatch();
288-
Boolean useRegisteredSuffixPatternMatch = configurer.isUseRegisteredSuffixPatternMatch();
289-
Boolean useTrailingSlashMatch = configurer.isUseTrailingSlashMatch();
290289
if (useSuffixPatternMatch != null) {
291290
mapping.setUseSuffixPatternMatch(useSuffixPatternMatch);
292291
}
292+
Boolean useRegisteredSuffixPatternMatch = configurer.isUseRegisteredSuffixPatternMatch();
293293
if (useRegisteredSuffixPatternMatch != null) {
294294
mapping.setUseRegisteredSuffixPatternMatch(useRegisteredSuffixPatternMatch);
295295
}
296+
Boolean useTrailingSlashMatch = configurer.isUseTrailingSlashMatch();
296297
if (useTrailingSlashMatch != null) {
297298
mapping.setUseTrailingSlashMatch(useTrailingSlashMatch);
298299
}
@@ -301,7 +302,6 @@ public RequestMappingHandlerMapping requestMappingHandlerMapping() {
301302
if (pathHelper != null) {
302303
mapping.setUrlPathHelper(pathHelper);
303304
}
304-
305305
PathMatcher pathMatcher = configurer.getPathMatcher();
306306
if (pathMatcher != null) {
307307
mapping.setPathMatcher(pathMatcher);
@@ -321,8 +321,8 @@ protected RequestMappingHandlerMapping createRequestMappingHandlerMapping() {
321321

322322
/**
323323
* Provide access to the shared handler interceptors used to configure
324-
* {@link HandlerMapping} instances with. This method cannot be overridden,
325-
* use {@link #addInterceptors(InterceptorRegistry)} instead.
324+
* {@link HandlerMapping} instances with.
325+
* <p>This method cannot be overridden; use {@link #addInterceptors} instead.
326326
*/
327327
protected final Object[] getInterceptors() {
328328
if (this.interceptors == null) {
@@ -358,15 +358,15 @@ protected PathMatchConfigurer getPathMatchConfigurer() {
358358

359359
/**
360360
* Override this method to configure path matching options.
361-
* @see PathMatchConfigurer
362361
* @since 4.0.3
362+
* @see PathMatchConfigurer
363363
*/
364364
protected void configurePathMatch(PathMatchConfigurer configurer) {
365365
}
366366

367367
/**
368368
* Return a global {@link PathMatcher} instance for path matching
369-
* patterns in {@link HandlerMapping}s.
369+
* patterns in {@link HandlerMapping HandlerMappings}.
370370
* This instance can be configured using the {@link PathMatchConfigurer}
371371
* in {@link #configurePathMatch(PathMatchConfigurer)}.
372372
* @since 4.1
@@ -379,7 +379,7 @@ public PathMatcher mvcPathMatcher() {
379379

380380
/**
381381
* Return a global {@link UrlPathHelper} instance for path matching
382-
* patterns in {@link HandlerMapping}s.
382+
* patterns in {@link HandlerMapping HandlerMappings}.
383383
* This instance can be configured using the {@link PathMatchConfigurer}
384384
* in {@link #configurePathMatch(PathMatchConfigurer)}.
385385
* @since 4.1
@@ -682,9 +682,8 @@ protected Validator getValidator() {
682682

683683
/**
684684
* Provide access to the shared custom argument resolvers used by the
685-
* {@link RequestMappingHandlerAdapter} and the
686-
* {@link ExceptionHandlerExceptionResolver}. This method cannot be
687-
* overridden, use {@link #addArgumentResolvers(List)} instead.
685+
* {@link RequestMappingHandlerAdapter} and the {@link ExceptionHandlerExceptionResolver}.
686+
* <p>This method cannot be overridden; use {@link #addArgumentResolvers} instead.
688687
* @since 4.3
689688
*/
690689
protected final List<HandlerMethodArgumentResolver> getArgumentResolvers() {
@@ -696,24 +695,21 @@ protected final List<HandlerMethodArgumentResolver> getArgumentResolvers() {
696695
}
697696

698697
/**
699-
* Add custom {@link HandlerMethodArgumentResolver}s to use in addition to
700-
* the ones registered by default.
701-
* <p>Custom argument resolvers are invoked before built-in resolvers
702-
* except for those that rely on the presence of annotations (e.g.
703-
* {@code @RequestParameter}, {@code @PathVariable}, etc.).
704-
* The latter can be customized by configuring the
698+
* Add custom {@link HandlerMethodArgumentResolver HandlerMethodArgumentResolvers}
699+
* to use in addition to the ones registered by default.
700+
* <p>Custom argument resolvers are invoked before built-in resolvers except for
701+
* those that rely on the presence of annotations (e.g. {@code @RequestParameter},
702+
* {@code @PathVariable}, etc). The latter can be customized by configuring the
705703
* {@link RequestMappingHandlerAdapter} directly.
706-
* @param argumentResolvers the list of custom converters;
707-
* initially an empty list.
704+
* @param argumentResolvers the list of custom converters (initially an empty list)
708705
*/
709706
protected void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers) {
710707
}
711708

712709
/**
713710
* Provide access to the shared return value handlers used by the
714-
* {@link RequestMappingHandlerAdapter} and the
715-
* {@link ExceptionHandlerExceptionResolver}. This method cannot be
716-
* overridden, use {@link #addReturnValueHandlers(List)} instead.
711+
* {@link RequestMappingHandlerAdapter} and the {@link ExceptionHandlerExceptionResolver}.
712+
* <p>This method cannot be overridden; use {@link #addReturnValueHandlers} instead.
717713
* @since 4.3
718714
*/
719715
protected final List<HandlerMethodReturnValueHandler> getReturnValueHandlers() {
@@ -725,27 +721,23 @@ protected final List<HandlerMethodReturnValueHandler> getReturnValueHandlers() {
725721
}
726722

727723
/**
728-
* Add custom {@link HandlerMethodReturnValueHandler}s in addition to the
729-
* ones registered by default.
730-
* <p>Custom return value handlers are invoked before built-in ones except
731-
* for those that rely on the presence of annotations (e.g.
732-
* {@code @ResponseBody}, {@code @ModelAttribute}, etc.).
733-
* The latter can be customized by configuring the
724+
* Add custom {@link HandlerMethodReturnValueHandler HandlerMethodReturnValueHandlers}
725+
* in addition to the ones registered by default.
726+
* <p>Custom return value handlers are invoked before built-in ones except for
727+
* those that rely on the presence of annotations (e.g. {@code @ResponseBody},
728+
* {@code @ModelAttribute}, etc). The latter can be customized by configuring the
734729
* {@link RequestMappingHandlerAdapter} directly.
735-
* @param returnValueHandlers the list of custom handlers;
736-
* initially an empty list.
730+
* @param returnValueHandlers the list of custom handlers (initially an empty list)
737731
*/
738732
protected void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers) {
739733
}
740734

741735
/**
742-
* Provides access to the shared {@link HttpMessageConverter}s used by the
743-
* {@link RequestMappingHandlerAdapter} and the
736+
* Provides access to the shared {@link HttpMessageConverter HttpMessageConverters}
737+
* used by the {@link RequestMappingHandlerAdapter} and the
744738
* {@link ExceptionHandlerExceptionResolver}.
745-
* This method cannot be overridden.
746-
* Use {@link #configureMessageConverters(List)} instead.
747-
* Also see {@link #addDefaultHttpMessageConverters(List)} that can be
748-
* used to add default message converters.
739+
* <p>This method cannot be overridden; use {@link #configureMessageConverters} instead.
740+
* Also see {@link #addDefaultHttpMessageConverters} for adding default message converters.
749741
*/
750742
protected final List<HttpMessageConverter<?>> getMessageConverters() {
751743
if (this.messageConverters == null) {
@@ -760,32 +752,30 @@ protected final List<HttpMessageConverter<?>> getMessageConverters() {
760752
}
761753

762754
/**
763-
* Override this method to add custom {@link HttpMessageConverter}s to use
764-
* with the {@link RequestMappingHandlerAdapter} and the
765-
* {@link ExceptionHandlerExceptionResolver}. Adding converters to the
766-
* list turns off the default converters that would otherwise be registered
767-
* by default. Also see {@link #addDefaultHttpMessageConverters(List)} that
768-
* can be used to add default message converters.
769-
* @param converters a list to add message converters to;
770-
* initially an empty list.
755+
* Override this method to add custom {@link HttpMessageConverter HttpMessageConverters}
756+
* to use with the {@link RequestMappingHandlerAdapter} and the
757+
* {@link ExceptionHandlerExceptionResolver}.
758+
* <p>Adding converters to the list turns off the default converters that would
759+
* otherwise be registered by default. Also see {@link #addDefaultHttpMessageConverters}
760+
* for adding default message converters.
761+
* @param converters a list to add message converters to (initially an empty list)
771762
*/
772763
protected void configureMessageConverters(List<HttpMessageConverter<?>> converters) {
773764
}
774765

775766
/**
776-
* Override this method to extend or modify the list of converters after it
777-
* has been configured. This may be useful for example to allow default
778-
* converters to be registered and then insert a custom converter through
779-
* this method.
780-
* @param converters the list of configured converters to extend.
767+
* Override this method to extend or modify the list of converters after it has
768+
* been configured. This may be useful for example to allow default converters
769+
* to be registered and then insert a custom converter through this method.
770+
* @param converters the list of configured converters to extend
781771
* @since 4.1.3
782772
*/
783773
protected void extendMessageConverters(List<HttpMessageConverter<?>> converters) {
784774
}
785775

786776
/**
787777
* Adds a set of default HttpMessageConverter instances to the given list.
788-
* Subclasses can call this method from {@link #configureMessageConverters(List)}.
778+
* Subclasses can call this method from {@link #configureMessageConverters}.
789779
* @param messageConverters the list to add the default message converters to
790780
*/
791781
protected final void addDefaultHttpMessageConverters(List<HttpMessageConverter<?>> messageConverters) {
@@ -875,14 +865,12 @@ public SimpleControllerHandlerAdapter simpleControllerHandlerAdapter() {
875865
}
876866

877867
/**
878-
* Returns a {@link HandlerExceptionResolverComposite} containing a list
879-
* of exception resolvers obtained either through
880-
* {@link #configureHandlerExceptionResolvers(List)} or through
881-
* {@link #addDefaultHandlerExceptionResolvers(List)}.
882-
* <p><strong>Note:</strong> This method cannot be made final due to CGLib
883-
* constraints. Rather than overriding it, consider overriding
884-
* {@link #configureHandlerExceptionResolvers(List)}, which allows
885-
* providing a list of resolvers.
868+
* Returns a {@link HandlerExceptionResolverComposite} containing a list of exception
869+
* resolvers obtained either through {@link #configureHandlerExceptionResolvers} or
870+
* through {@link #addDefaultHandlerExceptionResolvers}.
871+
* <p><strong>Note:</strong> This method cannot be made final due to CGLIB constraints.
872+
* Rather than overriding it, consider overriding {@link #configureHandlerExceptionResolvers}
873+
* which allows for providing a list of resolvers.
886874
*/
887875
@Bean
888876
public HandlerExceptionResolver handlerExceptionResolver() {
@@ -900,29 +888,29 @@ public HandlerExceptionResolver handlerExceptionResolver() {
900888

901889
/**
902890
* Override this method to configure the list of
903-
* {@link HandlerExceptionResolver}s to use. Adding resolvers to the list
904-
* turns off the default resolvers that would otherwise be registered by
905-
* default. Also see {@link #addDefaultHandlerExceptionResolvers(List)}
891+
* {@link HandlerExceptionResolver HandlerExceptionResolvers} to use.
892+
* <p>Adding resolvers to the list turns off the default resolvers that would otherwise
893+
* be registered by default. Also see {@link #addDefaultHandlerExceptionResolvers}
906894
* that can be used to add the default exception resolvers.
907-
* @param exceptionResolvers a list to add exception resolvers to;
908-
* initially an empty list.
895+
* @param exceptionResolvers a list to add exception resolvers to (initially an empty list)
909896
*/
910897
protected void configureHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) {
911898
}
912899

913900
/**
914901
* Override this method to extend or modify the list of
915-
* {@link HandlerExceptionResolver}s after it has been configured. This may
916-
* be useful for example to allow default resolvers to be registered and then
917-
* insert a custom one through this method.
902+
* {@link HandlerExceptionResolver HandlerExceptionResolvers} after it has been configured.
903+
* <p>This may be useful for example to allow default resolvers to be registered
904+
* and then insert a custom one through this method.
918905
* @param exceptionResolvers the list of configured resolvers to extend.
919906
* @since 4.3
920907
*/
921908
protected void extendHandlerExceptionResolvers(List<HandlerExceptionResolver> exceptionResolvers) {
922909
}
923910

924911
/**
925-
* A method available to subclasses for adding default {@link HandlerExceptionResolver}s.
912+
* A method available to subclasses for adding default
913+
* {@link HandlerExceptionResolver HandlerExceptionResolvers}.
926914
* <p>Adds the following exception resolvers:
927915
* <ul>
928916
* <li>{@link ExceptionHandlerExceptionResolver} for handling exceptions through
@@ -1031,7 +1019,8 @@ protected final Map<String, CorsConfiguration> getCorsConfigurations() {
10311019
protected void addCorsMappings(CorsRegistry registry) {
10321020
}
10331021

1034-
@Bean @Lazy
1022+
@Bean
1023+
@Lazy
10351024
public HandlerMappingIntrospector mvcHandlerMappingIntrospector() {
10361025
return new HandlerMappingIntrospector();
10371026
}

0 commit comments

Comments
 (0)