Class IntegrationRequestMappingHandlerMapping

java.lang.Object
org.springframework.context.support.ApplicationObjectSupport
org.springframework.web.context.support.WebApplicationObjectSupport
org.springframework.web.servlet.handler.AbstractHandlerMapping
org.springframework.web.servlet.handler.AbstractHandlerMethodMapping<org.springframework.web.servlet.mvc.method.RequestMappingInfo>
org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping
org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
org.springframework.integration.http.inbound.IntegrationRequestMappingHandlerMapping
All Implemented Interfaces:
EventListener, org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.config.BeanPostProcessor, org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>, org.springframework.context.EmbeddedValueResolverAware, org.springframework.core.Ordered, org.springframework.web.context.ServletContextAware, org.springframework.web.servlet.handler.MatchableHandlerMapping, org.springframework.web.servlet.HandlerMapping

public final class IntegrationRequestMappingHandlerMapping extends org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping implements org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>, org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor
The HandlerMapping implementation that detects and registers RequestMappingInfos for HttpRequestHandlingEndpointSupport from a Spring Integration HTTP configuration of <inbound-channel-adapter/> and <inbound-gateway/> elements.

This class is automatically configured as a bean in the application context during the parsing phase of the <inbound-channel-adapter/> and <inbound-gateway/> elements, if there is none registered, yet. However it can be configured as a regular bean with appropriate configuration for RequestMappingHandlerMapping. It is recommended to have only one similar bean in the application context using the 'id' HttpContextUtils.HANDLER_MAPPING_BEAN_NAME.

In most cases, Spring MVC offers to configure Request Mapping via org.springframework.stereotype.Controller and RequestMapping. That's why Spring MVC's Handler Mapping infrastructure relies on HandlerMethod, as different methods at the same org.springframework.stereotype.Controller user-class may have their own RequestMapping. On the other side, all Spring Integration HTTP Inbound Endpoints are configured on the basis of the same BaseHttpInboundEndpoint class and there is no single RequestMappingInfo configuration without HandlerMethod in Spring MVC. Accordingly IntegrationRequestMappingHandlerMapping is a HandlerMapping compromise implementation between method-level annotations and component-level (e.g. Spring Integration XML) configurations.

Starting with version 5.1, this class implements DestructionAwareBeanPostProcessor to register HTTP endpoints at runtime for dynamically declared beans, e.g. via IntegrationFlowContext, and unregister them during the BaseHttpInboundEndpoint destruction.

This class extends the Spring MVC RequestMappingHandlerMapping class, inheriting most of its logic, especially RequestMappingInfoHandlerMapping.handleNoMatch(java.util.Set, String, HttpServletRequest), which throws a specific 4xx error for the HTTP response, when mapping doesn't match for some reason, preventing calls to any remaining mapping handlers in the application context. For this reason, configuring the same path for both Spring Integration and Spring MVC request mappings (e.g. `POST` in one and `GET` in the other) is not supported; the MVC mapping will not be found.

Since:
3.0
See Also:
  • Field Summary

    Fields inherited from class org.springframework.web.servlet.handler.AbstractHandlerMapping

    mappingsLogger

    Fields inherited from class org.springframework.context.support.ApplicationObjectSupport

    logger

    Fields inherited from interface org.springframework.web.servlet.HandlerMapping

    BEST_MATCHING_HANDLER_ATTRIBUTE, BEST_MATCHING_PATTERN_ATTRIBUTE, INTROSPECT_TYPE_LEVEL_MAPPING, LOOKUP_PATH, MATRIX_VARIABLES_ATTRIBUTE, PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, URI_TEMPLATE_VARIABLES_ATTRIBUTE

    Fields inherited from interface org.springframework.core.Ordered

    HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    void
     
    protected void
     
    protected org.springframework.web.cors.CorsConfiguration
    getCorsConfiguration(Object handler, jakarta.servlet.http.HttpServletRequest request)
     
    protected org.springframework.web.servlet.HandlerExecutionChain
    getHandlerExecutionChain(Object handlerArg, jakarta.servlet.http.HttpServletRequest request)
     
    protected org.springframework.web.cors.CorsConfiguration
    initCorsConfiguration(Object handler, Method method, org.springframework.web.servlet.mvc.method.RequestMappingInfo mappingInfo)
     
    protected boolean
    isHandler(Class<?> beanType)
     
    void
    onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)
    HttpRequestHandlingEndpointSupports may depend on auto-created requestChannels, so MVC Handlers detection should be postponed as late as possible.
    void
     
     
    boolean
     

    Methods inherited from class org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping

    createRequestMappingInfo, getBuilderConfiguration, getContentNegotiationManager, getCustomMethodCondition, getCustomTypeCondition, getFileExtensions, getMappingForMethod, getPathPrefixes, match, registerHandlerMethod, registerMapping, resolveEmbeddedValuesInPatterns, setContentNegotiationManager, setEmbeddedValueResolver, setPathPrefixes, setPatternParser, setUseRegisteredSuffixPatternMatch, setUseSuffixPatternMatch, setUseTrailingSlashMatch, useRegisteredSuffixPatternMatch, useSuffixPatternMatch, useTrailingSlashMatch

    Methods inherited from class org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping

    getDirectPaths, getHandlerInternal, getMappingComparator, getMappingPathPatterns, getMatchingMapping, handleMatch, handleNoMatch

    Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerMethodMapping

    createHandlerMethod, getCandidateBeanNames, getHandlerMethods, getHandlerMethodsForMappingName, getNamingStrategy, handlerMethodsInitialized, hasCorsConfigurationSource, initHandlerMethods, lookupHandlerMethod, processCandidateBean, setDetectHandlerMethodsInAncestorContexts, setHandlerMethodMappingNamingStrategy, unregisterMapping

    Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerMapping

    adaptInterceptor, detectMappedInterceptors, extendInterceptors, formatMappingName, getAdaptedInterceptors, getCorsConfigurationSource, getCorsHandlerExecutionChain, getCorsProcessor, getDefaultHandler, getHandler, getMappedInterceptors, getOrder, getPathMatcher, getPatternParser, getUrlPathHelper, initApplicationContext, initInterceptors, initLookupPath, setAlwaysUseFullPath, setBeanName, setCorsConfigurations, setCorsConfigurationSource, setCorsProcessor, setDefaultHandler, setInterceptors, setOrder, setPathMatcher, setRemoveSemicolonContent, setUrlDecode, setUrlPathHelper, usesPathPatterns

    Methods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport

    getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext

    Methods inherited from class org.springframework.context.support.ApplicationObjectSupport

    getApplicationContext, getMessageSourceAccessor, obtainApplicationContext, requiredContextClass, setApplicationContext

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait

    Methods inherited from interface org.springframework.beans.factory.config.BeanPostProcessor

    postProcessAfterInitialization

    Methods inherited from interface org.springframework.web.servlet.HandlerMapping

    getHandler, usesPathPatterns

    Methods inherited from interface org.springframework.web.servlet.handler.MatchableHandlerMapping

    getPatternParser
  • Constructor Details

    • IntegrationRequestMappingHandlerMapping

      public IntegrationRequestMappingHandlerMapping()
  • Method Details

    • postProcessBeforeInitialization

      public Object postProcessBeforeInitialization(Object bean, String beanName) throws org.springframework.beans.BeansException
      Specified by:
      postProcessBeforeInitialization in interface org.springframework.beans.factory.config.BeanPostProcessor
      Throws:
      org.springframework.beans.BeansException
    • postProcessBeforeDestruction

      public void postProcessBeforeDestruction(Object bean, String beanName) throws org.springframework.beans.BeansException
      Specified by:
      postProcessBeforeDestruction in interface org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor
      Throws:
      org.springframework.beans.BeansException
    • requiresDestruction

      public boolean requiresDestruction(Object bean)
      Specified by:
      requiresDestruction in interface org.springframework.beans.factory.config.DestructionAwareBeanPostProcessor
    • isHandler

      protected boolean isHandler(Class<?> beanType)
      Overrides:
      isHandler in class org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
    • getHandlerExecutionChain

      protected org.springframework.web.servlet.HandlerExecutionChain getHandlerExecutionChain(Object handlerArg, jakarta.servlet.http.HttpServletRequest request)
      Overrides:
      getHandlerExecutionChain in class org.springframework.web.servlet.handler.AbstractHandlerMapping
    • getCorsConfiguration

      protected org.springframework.web.cors.CorsConfiguration getCorsConfiguration(Object handler, jakarta.servlet.http.HttpServletRequest request)
      Overrides:
      getCorsConfiguration in class org.springframework.web.servlet.handler.AbstractHandlerMethodMapping<org.springframework.web.servlet.mvc.method.RequestMappingInfo>
    • detectHandlerMethods

      protected void detectHandlerMethods(Object handlerArg)
      Overrides:
      detectHandlerMethods in class org.springframework.web.servlet.handler.AbstractHandlerMethodMapping<org.springframework.web.servlet.mvc.method.RequestMappingInfo>
    • initCorsConfiguration

      protected org.springframework.web.cors.CorsConfiguration initCorsConfiguration(Object handler, Method method, org.springframework.web.servlet.mvc.method.RequestMappingInfo mappingInfo)
      Overrides:
      initCorsConfiguration in class org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
    • onApplicationEvent

      public void onApplicationEvent(org.springframework.context.event.ContextRefreshedEvent event)
      HttpRequestHandlingEndpointSupports may depend on auto-created requestChannels, so MVC Handlers detection should be postponed as late as possible.
      Specified by:
      onApplicationEvent in interface org.springframework.context.ApplicationListener<org.springframework.context.event.ContextRefreshedEvent>
      See Also:
      • RequestMappingHandlerMapping.afterPropertiesSet()
    • afterPropertiesSet

      public void afterPropertiesSet()
      Specified by:
      afterPropertiesSet in interface org.springframework.beans.factory.InitializingBean
      Overrides:
      afterPropertiesSet in class org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping