public class WebSocketHandlerMapping extends SimpleUrlHandlerMapping implements SmartLifecycle
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.mappingsLogger
logger
DEFAULT_PHASE
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
HIGHEST_PRECEDENCE, LOWEST_PRECEDENCE
Constructor and Description |
---|
WebSocketHandlerMapping() |
Modifier and Type | Method and Description |
---|---|
protected Object |
getHandlerInternal(HttpServletRequest request)
Look up a handler for the URL path of the given request.
|
protected void |
initServletContext(ServletContext servletContext)
Subclasses may override this for custom initialization based
on the ServletContext that this application object runs in.
|
boolean |
isRunning()
Check whether this component is currently running.
|
void |
setWebSocketUpgradeMatch(boolean match)
When this is set, if the matched handler is
WebSocketHttpRequestHandler , ensure the request is a WebSocket
handshake, i.e. |
void |
start()
Start this component.
|
void |
stop()
Stop this component, typically in a synchronous fashion, such that the component is
fully stopped upon return of this method.
|
getUrlMap, initApplicationContext, registerHandlers, setMappings, setUrlMap
buildPathExposingHandler, exposePathWithinMapping, exposeUriTemplateVariables, getHandlerMap, getPathPatternHandlerMap, getRootHandler, lookupHandler, lookupHandler, match, registerHandler, registerHandler, setLazyInitHandlers, setPatternParser, setRootHandler, setUseTrailingSlashMatch, supportsTypeLevelMappings, useTrailingSlashMatch, validateHandler
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, usesPathPatterns
getServletContext, getTempDir, getWebApplicationContext, initApplicationContext, isContextRequired, setServletContext
getApplicationContext, getMessageSourceAccessor, obtainApplicationContext, requiredContextClass, setApplicationContext
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getPhase, isAutoStartup, stop
getPatternParser
getHandler, usesPathPatterns
public void setWebSocketUpgradeMatch(boolean match)
WebSocketHttpRequestHandler
, ensure the request is a WebSocket
handshake, i.e. HTTP GET with the header "Upgrade:websocket"
,
or otherwise suppress the match and return null
allowing another
HandlerMapping
to match for the
same URL path.match
- whether to enable matching on "Upgrade: websocket"
protected void initServletContext(ServletContext servletContext)
WebApplicationObjectSupport
The default implementation is empty. Called by
WebApplicationObjectSupport.initApplicationContext(org.springframework.context.ApplicationContext)
as well as WebApplicationObjectSupport.setServletContext(javax.servlet.ServletContext)
.
initServletContext
in class WebApplicationObjectSupport
servletContext
- the ServletContext that this application object runs in
(never null
)public void start()
Lifecycle
Should not throw an exception if the component is already running.
In the case of a container, this will propagate the start signal to all components that apply.
start
in interface Lifecycle
SmartLifecycle.isAutoStartup()
public void stop()
Lifecycle
SmartLifecycle
and its stop(Runnable)
variant when asynchronous stop behavior is necessary.
Note that this stop notification is not guaranteed to come before destruction:
On regular shutdown, Lifecycle
beans will first receive a stop notification
before the general destruction callbacks are being propagated; however, on hot
refresh during a context's lifetime or on aborted refresh attempts, a given bean's
destroy method will be called without any consideration of stop signals upfront.
Should not throw an exception if the component is not running (not started yet).
In the case of a container, this will propagate the stop signal to all components that apply.
stop
in interface Lifecycle
SmartLifecycle.stop(Runnable)
,
DisposableBean.destroy()
public boolean isRunning()
Lifecycle
In the case of a container, this will return true
only if all
components that apply are currently running.
@Nullable protected Object getHandlerInternal(HttpServletRequest request) throws Exception
AbstractUrlHandlerMapping
getHandlerInternal
in class AbstractUrlHandlerMapping
request
- current HTTP requestnull
if none foundException
- if there is an internal error