Class HandlerMappingIntrospector
- java.lang.Object
- org.springframework.web.servlet.handler.HandlerMappingIntrospector
- All Implemented Interfaces:
Aware,InitializingBean,ApplicationContextAware,CorsConfigurationSource
public class HandlerMappingIntrospector extends Object implements CorsConfigurationSource, ApplicationContextAware, InitializingBean
Helper class to get information from theHandlerMappingthat would serve a specific request.Provides the following methods:
getMatchableHandlerMapping(javax.servlet.http.HttpServletRequest)— obtain aHandlerMappingto check request-matching criteria against.getCorsConfiguration(javax.servlet.http.HttpServletRequest)— obtain the CORS configuration for the request.
- Since:
- 4.3.1
- Author:
- Rossen Stoyanchev
Constructor Summary
Constructors Constructor Description HandlerMappingIntrospector()Constructor for use withApplicationContextAware.HandlerMappingIntrospector(ApplicationContext context)Deprecated.as of 4.3.12, in favor ofsetApplicationContext(org.springframework.context.ApplicationContext)
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description voidafterPropertiesSet()Invoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.CorsConfigurationgetCorsConfiguration(HttpServletRequest request)Return aCorsConfigurationbased on the incoming request.List<HandlerMapping>getHandlerMappings()Return the configured HandlerMapping's.MatchableHandlerMappinggetMatchableHandlerMapping(HttpServletRequest request)Find theHandlerMappingthat would handle the given request and return it as aMatchableHandlerMappingthat can be used to test request-matching criteria.voidsetApplicationContext(ApplicationContext applicationContext)Set the ApplicationContext that this object runs in.
Constructor Detail
HandlerMappingIntrospector
public HandlerMappingIntrospector()
Constructor for use withApplicationContextAware.
HandlerMappingIntrospector
@Deprecated public HandlerMappingIntrospector(ApplicationContext context)
Deprecated.as of 4.3.12, in favor ofsetApplicationContext(org.springframework.context.ApplicationContext)Constructor that detects the configuredHandlerMappings in the givenApplicationContextor falls back on "DispatcherServlet.properties" like theDispatcherServlet.
Method Detail
getHandlerMappings
public List<HandlerMapping> getHandlerMappings()
Return the configured HandlerMapping's.
setApplicationContext
public void setApplicationContext(ApplicationContext applicationContext)
Description copied from interface:ApplicationContextAwareSet the ApplicationContext that this object runs in. Normally this call will be used to initialize the object.Invoked after population of normal bean properties but before an init callback such as
InitializingBean.afterPropertiesSet()or a custom init-method. Invoked afterResourceLoaderAware.setResourceLoader(org.springframework.core.io.ResourceLoader),ApplicationEventPublisherAware.setApplicationEventPublisher(org.springframework.context.ApplicationEventPublisher)andMessageSourceAware, if applicable.- Specified by:
setApplicationContextin interfaceApplicationContextAware- Parameters:
applicationContext- the ApplicationContext object to be used by this object- See Also:
BeanInitializationException
afterPropertiesSet
public void afterPropertiesSet()
Description copied from interface:InitializingBeanInvoked by the containingBeanFactoryafter it has set all bean properties and satisfiedBeanFactoryAware,ApplicationContextAwareetc.This method allows the bean instance to perform validation of its overall configuration and final initialization when all bean properties have been set.
- Specified by:
afterPropertiesSetin interfaceInitializingBean
getMatchableHandlerMapping
public MatchableHandlerMapping getMatchableHandlerMapping(HttpServletRequest request) throws Exception
Find theHandlerMappingthat would handle the given request and return it as aMatchableHandlerMappingthat can be used to test request-matching criteria.If the matching HandlerMapping is not an instance of
MatchableHandlerMapping, an IllegalStateException is raised.- Parameters:
request- the current request- Returns:
- the resolved matcher, or
null - Throws:
Exception- if any of the HandlerMapping's raise an exception
getCorsConfiguration
public CorsConfiguration getCorsConfiguration(HttpServletRequest request)
Description copied from interface:CorsConfigurationSourceReturn aCorsConfigurationbased on the incoming request.- Specified by:
getCorsConfigurationin interfaceCorsConfigurationSource- Returns:
- the associated
CorsConfiguration, ornullif none