Polishing contribution

Closes gh-27723
This commit is contained in:
Rossen Stoyanchev
2021-11-24 13:03:12 +00:00
parent ce0aed216b
commit 829bed03af
2 changed files with 35 additions and 19 deletions

View File

@@ -187,7 +187,6 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
@Override
@SuppressWarnings("deprecation")
public void afterPropertiesSet() {
this.config = new RequestMappingInfo.BuilderConfiguration();
this.config.setTrailingSlashMatch(useTrailingSlashMatch());
this.config.setContentNegotiationManager(getContentNegotiationManager());
@@ -247,17 +246,19 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
}
/**
* Get the configuration to build {@link RequestMappingInfo}
* instances. This is useful for programmatic registration of
* additional mappings following the same configuration as {@link
* #createRequestMappingInfo(RequestMapping, RequestCondition)}.
*
* @return builder configuration to be supplied into {@link RequestMappingInfo.Builder#options}.
* Obtain a {@link RequestMappingInfo.BuilderConfiguration} that can reflects
* the internal configuration of this {@code HandlerMapping} and can be used
* to set {@link RequestMappingInfo.Builder#options(RequestMappingInfo.BuilderConfiguration)}.
* <p>This is useful for programmatic registration of request mappings via
* {@link #registerHandlerMethod(Object, Method, RequestMappingInfo)}.
* @return the builder configuration that reflects the internal state
* @since 5.3.14
*/
public RequestMappingInfo.BuilderConfiguration getRequestMappingInfoBuilderConfiguration() {
public RequestMappingInfo.BuilderConfiguration getBuilderConfiguration() {
return this.config;
}
/**
* {@inheritDoc}
* <p>Expects a handler to have either a type-level @{@link Controller}
@@ -401,6 +402,19 @@ public class RequestMappingHandlerMapping extends RequestMappingInfoHandlerMappi
updateConsumesCondition(mapping, method);
}
/**
* {@inheritDoc}
* <p><strong>Note:</strong> To create the {@link RequestMappingInfo},
* please use {@link #getBuilderConfiguration()} and set the options on
* {@link RequestMappingInfo.Builder#options(RequestMappingInfo.BuilderConfiguration)}
* to match how this {@code HandlerMapping} is configured. This
* is important for example to ensure use of
* {@link org.springframework.web.util.pattern.PathPattern} or
* {@link org.springframework.util.PathMatcher} based matching.
* @param handler the bean name of the handler or the handler instance
* @param method the method to register
* @param mapping the mapping conditions associated with the handler method
*/
@Override
protected void registerHandlerMethod(Object handler, Method method, RequestMappingInfo mapping) {
super.registerHandlerMethod(handler, method, mapping);