Class RepositoryRestHandlerMapping

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.data.rest.webmvc.BasePathAwareHandlerMapping
org.springframework.data.rest.webmvc.RepositoryRestHandlerMapping
All Implemented Interfaces:
org.springframework.beans.factory.Aware, org.springframework.beans.factory.BeanNameAware, org.springframework.beans.factory.InitializingBean, org.springframework.context.ApplicationContextAware, 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 class RepositoryRestHandlerMapping extends BasePathAwareHandlerMapping
RequestMappingHandlerMapping implementation that will only find a handler method if a Repository is exported under that URL path segment. Also ensures the OpenEntityManagerInViewInterceptor is registered in the application context. The OEMIVI is required for the REST exporter to function properly.
Author:
Jon Brisbin, Oliver Gierke, Mark Paluch
  • Field Summary

    Fields
    Modifier and Type
    Field
    Description
    static final HttpMethods
     

    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
    RepositoryRestHandlerMapping(ResourceMappings mappings, RepositoryRestConfiguration config, org.springframework.data.repository.support.Repositories repositories)
    Creates a new RepositoryRestHandlerMapping for the given ResourceMappings RepositoryRestConfiguration and Repositories.
  • Method Summary

    Modifier and Type
    Method
    Description
    protected org.springframework.web.servlet.mvc.condition.ProducesRequestCondition
    customize(org.springframework.web.servlet.mvc.condition.ProducesRequestCondition condition)
    Customize the given ProducesRequestCondition.
    protected void
     
    protected org.springframework.web.cors.CorsConfiguration
    getCorsConfiguration(Object handler, jakarta.servlet.http.HttpServletRequest request)
     
    protected org.springframework.web.method.HandlerMethod
    handleNoMatch(Set<org.springframework.web.servlet.mvc.method.RequestMappingInfo> requestMappingInfos, String lookupPath, jakarta.servlet.http.HttpServletRequest request)
     
    protected boolean
    Returns whether the given controller type is considered a handler.
    protected org.springframework.web.method.HandlerMethod
    lookupHandlerMethod(String lookupPath, jakarta.servlet.http.HttpServletRequest request)
     
    void
    setEmbeddedValueResolver(org.springframework.util.StringValueResolver resolver)
     
    void
     

    Methods inherited from class org.springframework.data.rest.webmvc.BasePathAwareHandlerMapping

    getMappingForMethod, hasCorsConfigurationSource, isHandler

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

    afterPropertiesSet, createRequestMappingInfo, getBuilderConfiguration, getContentNegotiationManager, getCustomMethodCondition, getCustomTypeCondition, getFileExtensions, getPathPrefixes, initCorsConfiguration, match, registerHandlerMethod, registerMapping, resolveEmbeddedValuesInPatterns, setContentNegotiationManager, 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

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

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

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

    adaptInterceptor, detectMappedInterceptors, formatMappingName, getAdaptedInterceptors, getCorsConfigurationSource, getCorsHandlerExecutionChain, getCorsProcessor, getDefaultHandler, getHandler, getHandlerExecutionChain, 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.web.servlet.HandlerMapping

    getHandler, usesPathPatterns

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

    getPatternParser
  • Field Details

    • DEFAULT_ALLOWED_METHODS

      public static final HttpMethods DEFAULT_ALLOWED_METHODS
  • Constructor Details

  • Method Details

    • setJpaHelper

      public void setJpaHelper(JpaHelper jpaHelper)
      Parameters:
      jpaHelper - the jpaHelper to set
    • setEmbeddedValueResolver

      public void setEmbeddedValueResolver(org.springframework.util.StringValueResolver resolver)
      Specified by:
      setEmbeddedValueResolver in interface org.springframework.context.EmbeddedValueResolverAware
      Overrides:
      setEmbeddedValueResolver in class org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
    • lookupHandlerMethod

      protected org.springframework.web.method.HandlerMethod lookupHandlerMethod(String lookupPath, jakarta.servlet.http.HttpServletRequest request) throws Exception
      Overrides:
      lookupHandlerMethod in class BasePathAwareHandlerMapping
      Throws:
      Exception
    • handleNoMatch

      protected org.springframework.web.method.HandlerMethod handleNoMatch(Set<org.springframework.web.servlet.mvc.method.RequestMappingInfo> requestMappingInfos, String lookupPath, jakarta.servlet.http.HttpServletRequest request) throws jakarta.servlet.ServletException
      Overrides:
      handleNoMatch in class org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping
      Throws:
      jakarta.servlet.ServletException
    • isHandlerInternal

      protected boolean isHandlerInternal(Class<?> type)
      Description copied from class: BasePathAwareHandlerMapping
      Returns whether the given controller type is considered a handler.
      Overrides:
      isHandlerInternal in class BasePathAwareHandlerMapping
      Parameters:
      type - will never be null.
      Returns:
    • extendInterceptors

      protected void extendInterceptors(List<Object> interceptors)
      Overrides:
      extendInterceptors in class org.springframework.web.servlet.handler.AbstractHandlerMapping
    • customize

      protected org.springframework.web.servlet.mvc.condition.ProducesRequestCondition customize(org.springframework.web.servlet.mvc.condition.ProducesRequestCondition condition)
      Description copied from class: BasePathAwareHandlerMapping
      Customize the given ProducesRequestCondition. Default implementation returns the condition as is.
      Overrides:
      customize in class BasePathAwareHandlerMapping
      Parameters:
      condition - will never be null.
      Returns:
    • 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>