public class HandlerMappingIntrospector extends Object implements CorsConfigurationSource, ApplicationContextAware, InitializingBean
HandlerMapping
that would
serve a specific request.
Provides the following methods:
getMatchableHandlerMapping(javax.servlet.http.HttpServletRequest)
— obtain a HandlerMapping
to check request-matching criteria against.
getCorsConfiguration(javax.servlet.http.HttpServletRequest)
— obtain the CORS configuration for the
request.
Note: This is primarily an SPI to allow Spring Security to align its pattern matching with the same pattern matching that would be used in Spring MVC for a given request, in order to avoid security issues. Use of this introspector should be avoided for other purposes because it incurs the overhead of resolving the handler for a request.
Constructor and Description |
---|
HandlerMappingIntrospector()
Constructor for use with
ApplicationContextAware . |
HandlerMappingIntrospector(ApplicationContext context)
Deprecated.
as of 4.3.12, in favor of
setApplicationContext(org.springframework.context.ApplicationContext) |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet()
Invoked by the containing
BeanFactory after it has set all bean properties
and satisfied BeanFactoryAware , ApplicationContextAware etc. |
CorsConfiguration |
getCorsConfiguration(HttpServletRequest request)
Return a
CorsConfiguration based on the incoming request. |
List<HandlerMapping> |
getHandlerMappings()
Return the configured or detected HandlerMapping's.
|
MatchableHandlerMapping |
getMatchableHandlerMapping(HttpServletRequest request)
Find the
HandlerMapping that would handle the given request and
return it as a MatchableHandlerMapping that can be used to test
request-matching criteria. |
void |
setApplicationContext(ApplicationContext applicationContext)
Set the ApplicationContext that this object runs in.
|
public HandlerMappingIntrospector()
ApplicationContextAware
.@Deprecated public HandlerMappingIntrospector(ApplicationContext context)
setApplicationContext(org.springframework.context.ApplicationContext)
HandlerMapping
s in the
given ApplicationContext
or falls back on
"DispatcherServlet.properties" like the DispatcherServlet
.public List<HandlerMapping> getHandlerMappings()
public void setApplicationContext(ApplicationContext applicationContext)
ApplicationContextAware
Invoked after population of normal bean properties but before an init callback such
as InitializingBean.afterPropertiesSet()
or a custom init-method. Invoked after ResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader)
,
ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)
and
MessageSourceAware
, if applicable.
setApplicationContext
in interface ApplicationContextAware
applicationContext
- the ApplicationContext object to be used by this objectBeanInitializationException
public void afterPropertiesSet()
InitializingBean
BeanFactory
after it has set all bean properties
and satisfied BeanFactoryAware
, ApplicationContextAware
etc.
This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
afterPropertiesSet
in interface InitializingBean
@Nullable public MatchableHandlerMapping getMatchableHandlerMapping(HttpServletRequest request) throws Exception
HandlerMapping
that would handle the given request and
return it as a MatchableHandlerMapping
that can be used to test
request-matching criteria.
If the matching HandlerMapping is not an instance of
MatchableHandlerMapping
, an IllegalStateException is raised.
request
- the current requestnull
Exception
- if any of the HandlerMapping's raise an exception@Nullable public CorsConfiguration getCorsConfiguration(HttpServletRequest request)
CorsConfigurationSource
CorsConfiguration
based on the incoming request.getCorsConfiguration
in interface CorsConfigurationSource
CorsConfiguration
, or null
if none