public class EndpointHandlerMapping extends RequestMappingHandlerMapping
HandlerMapping
to map Endpoint
s 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.
logger
BEST_MATCHING_PATTERN_ATTRIBUTE, INTROSPECT_TYPE_LEVEL_MAPPING, MATRIX_VARIABLES_ATTRIBUTE, PATH_WITHIN_HANDLER_MAPPING_ATTRIBUTE, PRODUCIBLE_MEDIA_TYPES_ATTRIBUTE, URI_TEMPLATE_VARIABLES_ATTRIBUTE
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
EndpointHandlerMapping(Collection<? extends MvcEndpoint> endpoints)
Create a new
EndpointHandlerMapping instance. |
EndpointHandlerMapping(Collection<? extends MvcEndpoint> endpoints,
CorsConfiguration corsConfiguration)
Create a new
EndpointHandlerMapping instance. |
Modifier and Type | Method and Description |
---|---|
void |
afterPropertiesSet() |
Set<? extends MvcEndpoint> |
getEndpoints()
Return the endpoints.
|
String |
getPath(String endpoint)
Get the path of the endpoint.
|
String |
getPrefix()
Get the prefix used in mappings.
|
protected CorsConfiguration |
initCorsConfiguration(Object handler,
Method method,
RequestMappingInfo mappingInfo) |
boolean |
isDisabled()
Returns if this mapping is disabled.
|
protected boolean |
isHandler(Class<?> beanType)
Since all handler beans are passed into the constructor there is no need to detect
anything here.
|
protected void |
registerHandlerMethod(Object handler,
Method method,
RequestMappingInfo mapping)
Deprecated.
|
void |
setDisabled(boolean disabled)
Sets if this mapping is disabled.
|
void |
setPrefix(String prefix)
Set the prefix used in mappings.
|
createRequestMappingInfo, getContentNegotiationManager, getCustomMethodCondition, getCustomTypeCondition, getFileExtensions, getMappingForMethod, resolveEmbeddedValuesInPatterns, setContentNegotiationManager, setEmbeddedValueResolver, setUseRegisteredSuffixPatternMatch, setUseSuffixPatternMatch, setUseTrailingSlashMatch, useRegisteredSuffixPatternMatch, useSuffixPatternMatch, useTrailingSlashMatch
getMappingComparator, getMappingPathPatterns, getMatchingMapping, handleMatch, handleNoMatch
createHandlerMethod, detectHandlerMethods, getCorsConfiguration, getHandlerInternal, getHandlerMethods, getHandlerMethodsForMappingName, getNamingStrategy, handlerMethodsInitialized, initHandlerMethods, lookupHandlerMethod, registerMapping, setDetectHandlerMethodsInAncestorContexts, setHandlerMethodMappingNamingStrategy, unregisterMapping
adaptInterceptor, detectMappedInterceptors, extendInterceptors, getAdaptedInterceptors, getCorsConfigurations, getCorsHandlerExecutionChain, getCorsProcessor, getDefaultHandler, getHandler, getHandlerExecutionChain, getMappedInterceptors, getOrder, getPathMatcher, getUrlPathHelper, initApplicationContext, initInterceptors, setAlwaysUseFullPath, setCorsConfigurations, setCorsProcessor, setDefaultHandler, setInterceptors, setOrder, setPathMatcher, setRemoveSemicolonContent, setUrlDecode, setUrlPathHelper
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, initServletContext, isContextRequired, setServletContext
getApplicationContext, getMessageSourceAccessor, requiredContextClass, setApplicationContext
public EndpointHandlerMapping(Collection<? extends MvcEndpoint> endpoints)
EndpointHandlerMapping
instance. All Endpoint
s will be
detected from the ApplicationContext
. The endpoints will not accept CORS
requests.endpoints
- the endpointspublic EndpointHandlerMapping(Collection<? extends MvcEndpoint> endpoints, CorsConfiguration corsConfiguration)
EndpointHandlerMapping
instance. All Endpoint
s will be
detected from the ApplicationContext
. The endpoints will accepts CORS
requests based on the given corsConfiguration
.endpoints
- the endpointscorsConfiguration
- the CORS configuration for the endpointspublic void afterPropertiesSet()
afterPropertiesSet
in interface InitializingBean
afterPropertiesSet
in class RequestMappingHandlerMapping
protected boolean isHandler(Class<?> beanType)
isHandler
in class RequestMappingHandlerMapping
@Deprecated protected void registerHandlerMethod(Object handler, Method method, RequestMappingInfo mapping)
registerHandlerMethod
in class AbstractHandlerMethodMapping<RequestMappingInfo>
public void setPrefix(String prefix)
prefix
- the prefixpublic String getPrefix()
public String getPath(String endpoint)
endpoint
- the endpointpublic void setDisabled(boolean disabled)
disabled
- if the mapping is disabledpublic boolean isDisabled()
public Set<? extends MvcEndpoint> getEndpoints()
protected CorsConfiguration initCorsConfiguration(Object handler, Method method, RequestMappingInfo mappingInfo)
initCorsConfiguration
in class RequestMappingHandlerMapping
Copyright © 2016 Pivotal Software, Inc.. All rights reserved.