Class AbstractEndpointHandlerMapping<E extends MvcEndpoint>

  • Type Parameters:
    E - The endpoint type
    All Implemented Interfaces:
    org.springframework.beans.factory.Aware, 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
    Direct Known Subclasses:
    EndpointHandlerMapping

    public abstract class AbstractEndpointHandlerMapping<E extends MvcEndpoint>
    extends org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
    HandlerMapping to map Endpoints to URLs via Endpoint.getId(). The semantics of @RequestMapping should be identical to a normal @Controller, but the endpoints should not be annotated as @Controller (otherwise they will be mapped by the normal MVC mechanisms).

    One of the aims of the mapping is to support endpoints that work as HTTP endpoints but can still provide useful service interfaces when there is no HTTP server (and no Spring MVC on the classpath). Note that any endpoints having method signatures will break in a non-servlet environment.

    • Field Summary

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

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

        BEST_MATCHING_PATTERN_ATTRIBUTE, INTROSPECT_TYPE_LEVEL_MAPPING, 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
    • Method Summary

      All Methods Instance Methods Concrete Methods Deprecated Methods 
      Modifier and TypeMethodDescription
      voidafterPropertiesSet() 
      protected voidextendInterceptors​(List<Object> interceptors) 
      protected org.springframework.web.servlet.HandlerExecutionChaingetCorsHandlerExecutionChain​(javax.servlet.http.HttpServletRequest request, org.springframework.web.servlet.HandlerExecutionChain chain, org.springframework.web.cors.CorsConfiguration config) 
      Set<E>getEndpoints()
      Return the endpoints.
      protected org.springframework.web.servlet.HandlerExecutionChaingetHandlerExecutionChain​(Object handler, javax.servlet.http.HttpServletRequest request) 
      StringgetPath​(String endpoint)
      Get the path of the endpoint.
      protected StringgetPath​(MvcEndpoint endpoint)
      Return the path that should be used to map the given MvcEndpoint.
      StringgetPrefix()
      Get the prefix used in mappings.
      protected org.springframework.web.cors.CorsConfigurationinitCorsConfiguration​(Object handler, Method method, org.springframework.web.servlet.mvc.method.RequestMappingInfo mappingInfo) 
      booleanisDisabled()
      Returns if this mapping is disabled.
      protected booleanisHandler​(Class<?> beanType)
      Since all handler beans are passed into the constructor there is no need to detect anything here.
      protected voidpostProcessEndpoints​(Set<E> endpoints)
      Post process the endpoint setting before they are used.
      protected voidregisterHandlerMethod​(Object handler, Method method, org.springframework.web.servlet.mvc.method.RequestMappingInfo mapping)
      Deprecated.
      voidsetDisabled​(boolean disabled)
      Sets if this mapping is disabled.
      voidsetPrefix​(String prefix)
      Set the prefix used in mappings.
      voidsetSecurityInterceptor​(org.springframework.web.servlet.HandlerInterceptor securityInterceptor)
      Set the handler interceptor that will be used for security.
      • Methods inherited from class org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping

        createRequestMappingInfo, getContentNegotiationManager, getCustomMethodCondition, getCustomTypeCondition, getFileExtensions, getMappingForMethod, match, resolveEmbeddedValuesInPatterns, setContentNegotiationManager, setEmbeddedValueResolver, setUseRegisteredSuffixPatternMatch, setUseSuffixPatternMatch, setUseTrailingSlashMatch, useRegisteredSuffixPatternMatch, useSuffixPatternMatch, useTrailingSlashMatch
      • Methods inherited from class org.springframework.web.servlet.mvc.method.RequestMappingInfoHandlerMapping

        getMappingComparator, getMappingPathPatterns, getMatchingMapping, handleMatch, handleNoMatch
      • Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerMethodMapping

        createHandlerMethod, detectHandlerMethods, getCorsConfiguration, getHandlerInternal, getHandlerMethods, getHandlerMethodsForMappingName, getNamingStrategy, handlerMethodsInitialized, initHandlerMethods, lookupHandlerMethod, registerMapping, setDetectHandlerMethodsInAncestorContexts, setHandlerMethodMappingNamingStrategy, unregisterMapping
      • Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerMapping

        adaptInterceptor, detectMappedInterceptors, getAdaptedInterceptors, getCorsConfigurations, getCorsProcessor, getDefaultHandler, getHandler, getMappedInterceptors, getOrder, getPathMatcher, getUrlPathHelper, initApplicationContext, initInterceptors, setAlwaysUseFullPath, setCorsConfigurations, setCorsProcessor, setDefaultHandler, setInterceptors, setOrder, setPathMatcher, setRemoveSemicolonContent, setUrlDecode, setUrlPathHelper
      • 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, requiredContextClass, setApplicationContext
      • Methods inherited from interface org.springframework.web.servlet.HandlerMapping

        getHandler
    • Constructor Detail

      • AbstractEndpointHandlerMapping

        public AbstractEndpointHandlerMapping​(Collection<? extends E> endpoints,
                                              org.springframework.web.cors.CorsConfiguration corsConfiguration)
        Create a new AbstractEndpointHandlerMapping instance. All Endpoints will be detected from the ApplicationContext. The endpoints will accepts CORS requests based on the given corsConfiguration.
        Parameters:
        endpoints - the endpoints
        corsConfiguration - the CORS configuration for the endpoints
        Since:
        1.3.0
    • Method Detail

      • postProcessEndpoints

        protected void postProcessEndpoints​(Set<E> endpoints)
        Post process the endpoint setting before they are used. Subclasses can add or modify the endpoints as necessary.
        Parameters:
        endpoints - the endpoints to post process
      • 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
      • isHandler

        protected boolean isHandler​(Class<?> beanType)
        Since all handler beans are passed into the constructor there is no need to detect anything here.
        Overrides:
        isHandler in class org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping
      • registerHandlerMethod

        @Deprecated
        protected void registerHandlerMethod​(Object handler,
                                             Method method,
                                             org.springframework.web.servlet.mvc.method.RequestMappingInfo mapping)
        Deprecated.
        Overrides:
        registerHandlerMethod in class org.springframework.web.servlet.handler.AbstractHandlerMethodMapping<org.springframework.web.servlet.mvc.method.RequestMappingInfo>
      • getPath

        protected String getPath​(MvcEndpoint endpoint)
        Return the path that should be used to map the given MvcEndpoint.
        Parameters:
        endpoint - the endpoint to map
        Returns:
        the path to use for the endpoint or null if no mapping is required
      • getHandlerExecutionChain

        protected org.springframework.web.servlet.HandlerExecutionChain getHandlerExecutionChain​(Object handler,
                                                                                                 javax.servlet.http.HttpServletRequest request)
        Overrides:
        getHandlerExecutionChain in class org.springframework.web.servlet.handler.AbstractHandlerMapping
      • getCorsHandlerExecutionChain

        protected org.springframework.web.servlet.HandlerExecutionChain getCorsHandlerExecutionChain​(javax.servlet.http.HttpServletRequest request,
                                                                                                     org.springframework.web.servlet.HandlerExecutionChain chain,
                                                                                                     org.springframework.web.cors.CorsConfiguration config)
        Overrides:
        getCorsHandlerExecutionChain in class org.springframework.web.servlet.handler.AbstractHandlerMapping
      • extendInterceptors

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

        public void setSecurityInterceptor​(org.springframework.web.servlet.HandlerInterceptor securityInterceptor)
        Set the handler interceptor that will be used for security.
        Parameters:
        securityInterceptor - the security handler interceptor
      • setPrefix

        public void setPrefix​(String prefix)
        Set the prefix used in mappings.
        Parameters:
        prefix - the prefix
      • getPrefix

        public String getPrefix()
        Get the prefix used in mappings.
        Returns:
        the prefix
      • getPath

        public String getPath​(String endpoint)
        Get the path of the endpoint.
        Parameters:
        endpoint - the endpoint
        Returns:
        the path used in mappings
      • setDisabled

        public void setDisabled​(boolean disabled)
        Sets if this mapping is disabled.
        Parameters:
        disabled - if the mapping is disabled
      • isDisabled

        public boolean isDisabled()
        Returns if this mapping is disabled.
        Returns:
        true if the mapping is disabled
      • getEndpoints

        public Set<EgetEndpoints()
        Return the endpoints.
        Returns:
        the endpoints
      • 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