Class WebSocketHandlerMapping
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.AbstractUrlHandlerMapping
org.springframework.web.servlet.handler.SimpleUrlHandlerMapping
org.springframework.web.socket.server.support.WebSocketHandlerMapping
- All Implemented Interfaces:
org.springframework.beans.factory.Aware,org.springframework.beans.factory.BeanNameAware,org.springframework.context.ApplicationContextAware,org.springframework.context.Lifecycle,org.springframework.context.Phased,org.springframework.context.SmartLifecycle,org.springframework.core.Ordered,org.springframework.web.context.ServletContextAware,org.springframework.web.servlet.handler.MatchableHandlerMapping,org.springframework.web.servlet.HandlerMapping
public class WebSocketHandlerMapping
extends org.springframework.web.servlet.handler.SimpleUrlHandlerMapping
implements org.springframework.context.SmartLifecycle
Extension of
SimpleUrlHandlerMapping with support for more
precise mapping of WebSocket handshake requests to handlers of type
WebSocketHttpRequestHandler. Also delegates Lifecycle
methods to handlers in the SimpleUrlHandlerMapping.getUrlMap() that implement it.- Since:
- 4.2
- Author:
- Rossen Stoyanchev
-
Field Summary
Fields inherited from class org.springframework.web.servlet.handler.AbstractHandlerMapping
mappingsLoggerFields inherited from class org.springframework.context.support.ApplicationObjectSupport
loggerFields 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_ATTRIBUTEFields inherited from interface org.springframework.core.Ordered
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCEFields inherited from interface org.springframework.context.SmartLifecycle
DEFAULT_PHASE -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected ObjectgetHandlerInternal(HttpServletRequest request) intgetPhase()protected voidinitServletContext(ServletContext servletContext) booleanvoidsetPhase(int phase) Set the phase that this handler should run in.voidsetWebSocketUpgradeMatch(boolean match) When this is set, if the matched handler isWebSocketHttpRequestHandler, ensure the request is a WebSocket handshake, i.e.voidstart()voidstop()Methods inherited from class org.springframework.web.servlet.handler.SimpleUrlHandlerMapping
getUrlMap, initApplicationContext, registerHandlers, setMappings, setUrlMapMethods inherited from class org.springframework.web.servlet.handler.AbstractUrlHandlerMapping
buildPathExposingHandler, exposePathWithinMapping, exposeUriTemplateVariables, getHandlerMap, getPathPatternHandlerMap, getRootHandler, lookupHandler, lookupHandler, match, registerHandler, registerHandler, setLazyInitHandlers, setPatternParser, setRootHandler, setUseTrailingSlashMatch, supportsTypeLevelMappings, useTrailingSlashMatch, validateHandlerMethods inherited from class org.springframework.web.servlet.handler.AbstractHandlerMapping
adaptInterceptor, detectMappedInterceptors, extendInterceptors, formatMappingName, getAdaptedInterceptors, getCorsConfiguration, getCorsConfigurationSource, getCorsHandlerExecutionChain, getCorsProcessor, getDefaultHandler, getHandler, getHandlerExecutionChain, getMappedInterceptors, getOrder, getPathMatcher, getPatternParser, getUrlPathHelper, hasCorsConfigurationSource, initInterceptors, initLookupPath, setAlwaysUseFullPath, setBeanName, setCorsConfigurations, setCorsConfigurationSource, setCorsProcessor, setDefaultHandler, setInterceptors, setOrder, setPathMatcher, setRemoveSemicolonContent, setUrlDecode, setUrlPathHelper, usesPathPatternsMethods inherited from class org.springframework.web.context.support.WebApplicationObjectSupport
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, isContextRequired, setServletContextMethods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, obtainApplicationContext, requiredContextClass, setApplicationContextMethods inherited from class java.lang.Object
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface org.springframework.web.servlet.HandlerMapping
getHandler, usesPathPatternsMethods inherited from interface org.springframework.web.servlet.handler.MatchableHandlerMapping
getPatternParserMethods inherited from interface org.springframework.context.SmartLifecycle
isAutoStartup, stop
-
Constructor Details
-
WebSocketHandlerMapping
public WebSocketHandlerMapping()
-
-
Method Details
-
setWebSocketUpgradeMatch
public void setWebSocketUpgradeMatch(boolean match) When this is set, if the matched handler isWebSocketHttpRequestHandler, ensure the request is a WebSocket handshake, i.e. HTTP GET with the header"Upgrade:websocket", or otherwise suppress the match and returnnullallowing anotherHandlerMappingto match for the same URL path.- Parameters:
match- whether to enable matching on"Upgrade: websocket"- Since:
- 5.3.5
-
setPhase
public void setPhase(int phase) Set the phase that this handler should run in.By default, this is
SmartLifecycle.DEFAULT_PHASE.- Since:
- 6.1.4
-
getPhase
public int getPhase()- Specified by:
getPhasein interfaceorg.springframework.context.Phased- Specified by:
getPhasein interfaceorg.springframework.context.SmartLifecycle
-
initServletContext
- Overrides:
initServletContextin classorg.springframework.web.context.support.WebApplicationObjectSupport
-
start
public void start()- Specified by:
startin interfaceorg.springframework.context.Lifecycle
-
stop
public void stop()- Specified by:
stopin interfaceorg.springframework.context.Lifecycle
-
isRunning
public boolean isRunning()- Specified by:
isRunningin interfaceorg.springframework.context.Lifecycle
-
getHandlerInternal
- Overrides:
getHandlerInternalin classorg.springframework.web.servlet.handler.AbstractUrlHandlerMapping- Throws:
Exception
-