Expose mvcPatternParser bean in WebMvcConfigurationSupport
See gh-26427
This commit is contained in:
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2002-2020 the original author or authors.
|
||||
* Copyright 2002-2021 the original author or authors.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||
* you may not use this file except in compliance with the License.
|
||||
@@ -63,6 +63,9 @@ public class PathMatchConfigurer {
|
||||
@Nullable
|
||||
private PathMatcher pathMatcher;
|
||||
|
||||
@Nullable
|
||||
private PathPatternParser defaultPatternParser;
|
||||
|
||||
@Nullable
|
||||
private UrlPathHelper defaultUrlPathHelper;
|
||||
|
||||
@@ -226,7 +229,7 @@ public class PathMatchConfigurer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the configure UrlPathHelper instance or a default (shared) instance.
|
||||
* Return the configure UrlPathHelper or a default, shared instance otherwise.
|
||||
* @since 5.3
|
||||
*/
|
||||
protected UrlPathHelper getUrlPathHelperOrDefault() {
|
||||
@@ -240,7 +243,7 @@ public class PathMatchConfigurer {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the configure PathMatcher instance or a default (shared) instance.
|
||||
* Return the configure PathMatcher or a default, shared, instance otherwise.
|
||||
* @since 5.3
|
||||
*/
|
||||
protected PathMatcher getPathMatcherOrDefault() {
|
||||
@@ -253,4 +256,17 @@ public class PathMatchConfigurer {
|
||||
return this.defaultPathMatcher;
|
||||
}
|
||||
|
||||
/**
|
||||
* Return the configured PathPatternParser or a default, shared, instance otherwise.
|
||||
* @since 5.3.4
|
||||
*/
|
||||
public PathPatternParser getPatternParserOrDefault() {
|
||||
if (this.patternParser != null) {
|
||||
return this.patternParser;
|
||||
}
|
||||
if (this.defaultPatternParser == null) {
|
||||
this.defaultPatternParser = new PathPatternParser();
|
||||
}
|
||||
return this.defaultPatternParser;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -395,6 +395,17 @@ public class WebMvcConfigurationSupport implements ApplicationContextAware, Serv
|
||||
protected void configurePathMatch(PathMatchConfigurer configurer) {
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a global {@link PathPatternParser} instance to use for parsing
|
||||
* patterns to match to the {@link org.springframework.http.server.RequestPath}.
|
||||
* The returned instance can be configured using
|
||||
* {@link #configurePathMatch(PathMatchConfigurer)}.
|
||||
* @since 5.3.4
|
||||
*/
|
||||
@Bean
|
||||
public PathPatternParser mvcPatternParser() {
|
||||
return getPathMatchConfigurer().getPatternParserOrDefault();
|
||||
}
|
||||
|
||||
/**
|
||||
* Return a global {@link UrlPathHelper} instance which is used to resolve
|
||||
|
||||
Reference in New Issue
Block a user