public final class MappedInterceptor extends Object
HandlerInterceptor
along with include (and optionally
exclude) path patterns to which the interceptor should apply. Also provides
matching logic to test if the interceptor applies to a given request path.
A MappedInterceptor can be registered directly with any
AbstractHandlerMethodMapping
. Furthermore, beans of type MappedInterceptor
are automatically detected by AbstractHandlerMethodMapping
(including
ancestor ApplicationContext's) which effectively means the interceptor is
registered "globally" with all handler mappings.
Constructor and Description |
---|
MappedInterceptor(String[] includePatterns,
HandlerInterceptor interceptor)
Create a new MappedInterceptor instance.
|
MappedInterceptor(String[] includePatterns,
String[] excludePatterns,
HandlerInterceptor interceptor)
Create a new MappedInterceptor instance.
|
MappedInterceptor(String[] includePatterns,
String[] excludePatterns,
WebRequestInterceptor interceptor)
Create a new MappedInterceptor instance.
|
MappedInterceptor(String[] includePatterns,
WebRequestInterceptor interceptor)
Create a new MappedInterceptor instance.
|
Modifier and Type | Method and Description |
---|---|
HandlerInterceptor |
getInterceptor()
The actual Interceptor reference.
|
PathMatcher |
getPathMatcher()
The configured PathMatcher, or
null . |
String[] |
getPathPatterns()
The path into the application the interceptor is mapped to.
|
boolean |
matches(String lookupPath,
PathMatcher pathMatcher)
Returns
true if the interceptor applies to the given request path. |
void |
setPathMatcher(PathMatcher pathMatcher)
Configure a PathMatcher to use with this MappedInterceptor instead of the
one passed by default to the
matches(String, org.springframework.util.PathMatcher)
method. |
public MappedInterceptor(String[] includePatterns, HandlerInterceptor interceptor)
includePatterns
- the path patterns to map with a null
value matching to all pathsinterceptor
- the HandlerInterceptor instance to map to the given patternspublic MappedInterceptor(String[] includePatterns, String[] excludePatterns, HandlerInterceptor interceptor)
includePatterns
- the path patterns to map with a null
value matching to all pathsexcludePatterns
- the path patterns to excludeinterceptor
- the HandlerInterceptor instance to map to the given patternspublic MappedInterceptor(String[] includePatterns, WebRequestInterceptor interceptor)
includePatterns
- the path patterns to map with a null
value matching to all pathsinterceptor
- the WebRequestInterceptor instance to map to the given patternspublic MappedInterceptor(String[] includePatterns, String[] excludePatterns, WebRequestInterceptor interceptor)
includePatterns
- the path patterns to map with a null
value matching to all pathsinterceptor
- the WebRequestInterceptor instance to map to the given patternspublic void setPathMatcher(PathMatcher pathMatcher)
matches(String, org.springframework.util.PathMatcher)
method. This is an advanced property that is only required when using custom
PathMatcher implementations that support mapping metadata other than the
Ant-style path patterns supported by default.pathMatcher
- the path matcher to usepublic PathMatcher getPathMatcher()
null
.public String[] getPathPatterns()
public HandlerInterceptor getInterceptor()
public boolean matches(String lookupPath, PathMatcher pathMatcher)
true
if the interceptor applies to the given request path.lookupPath
- the current request pathpathMatcher
- a path matcher for path pattern matching