Skip to content

Commit

Permalink
Add getter for RequestMappingInfo.BuilderConfiguration
Browse files Browse the repository at this point in the history
This improves support for programmatic registration of mappings to
use the same config as that of the RequestMappingHandlerMapping.

See gh-27723
  • Loading branch information
neiser authored and rstoyanchev committed Nov 24, 2021
1 parent 0d7c562 commit ce0aed2
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -246,6 +246,17 @@ public List<String> getFileExtensions() {
return this.config.getFileExtensions();
}

/**
* 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}.
*/
public RequestMappingInfo.BuilderConfiguration getRequestMappingInfoBuilderConfiguration() {
return this.config;
}

/**
* {@inheritDoc}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -79,6 +79,17 @@ static Stream<Arguments> pathPatternsArguments() {
return Stream.of(Arguments.of(mapping1, wac1), Arguments.of(mapping2, wac2));
}

@Test
void getRequestMappingInfoBuilderConfiguration() {
RequestMappingHandlerMapping handlerMapping = new RequestMappingHandlerMapping();
handlerMapping.setApplicationContext(new StaticWebApplicationContext());

RequestMappingInfo.BuilderConfiguration beforeAfterPropertiesSet = handlerMapping.getRequestMappingInfoBuilderConfiguration();
assertThat(beforeAfterPropertiesSet).isNotNull();
handlerMapping.afterPropertiesSet();
RequestMappingInfo.BuilderConfiguration afterPropertiesSet = handlerMapping.getRequestMappingInfoBuilderConfiguration();
assertThat(afterPropertiesSet).isNotNull().isNotSameAs(beforeAfterPropertiesSet);
}

@Test
@SuppressWarnings("deprecation")
Expand Down

0 comments on commit ce0aed2

Please sign in to comment.