Class HandlerMappingIntrospector

java.lang.Object
org.springframework.web.servlet.handler.HandlerMappingIntrospector
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.web.cors.CorsConfigurationSource

public class HandlerMappingIntrospector extends Object implements org.springframework.web.cors.CorsConfigurationSource, org.springframework.context.ApplicationContextAware, org.springframework.beans.factory.InitializingBean
Helper class to get information from the HandlerMapping that would serve a specific request.

Provides the following methods:

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.

Since:
4.3.1
Author:
Rossen Stoyanchev
  • Constructor Details

    • HandlerMappingIntrospector

      public HandlerMappingIntrospector()
  • Method Details

    • setApplicationContext

      public void setApplicationContext(org.springframework.context.ApplicationContext applicationContext)
      Specified by:
      setApplicationContext in interface org.springframework.context.ApplicationContextAware
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
    • getHandlerMappings

      public List<HandlerMapping> getHandlerMappings()
      Return the configured or detected HandlerMappings.
    • getMatchableHandlerMapping

      @Nullable public MatchableHandlerMapping getMatchableHandlerMapping(HttpServletRequest request) throws Exception
      Find the 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.

      Parameters:
      request - the current request
      Returns:
      the resolved matcher, or null
      Throws:
      Exception - if any of the HandlerMapping's raise an exception
    • getCorsConfiguration

      @Nullable public org.springframework.web.cors.CorsConfiguration getCorsConfiguration(HttpServletRequest request)
      Specified by:
      getCorsConfiguration in interface org.springframework.web.cors.CorsConfigurationSource