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:
Aware
,ApplicationContextAware
,Lifecycle
,Phased
,SmartLifecycle
,Ordered
,ServletContextAware
,MatchableHandlerMapping
,HandlerMapping
public class WebSocketHandlerMapping extends SimpleUrlHandlerMapping implements SmartLifecycle
An extension ofSimpleUrlHandlerMapping
that is also aSmartLifecycle
container and propagates start and stop calls to any handlers that implementLifecycle
. The handlers are typically expected to beWebSocketHttpRequestHandler
orSockJsHttpRequestHandler
.- Since:
- 4.2
- Author:
- Rossen Stoyanchev
Field Summary
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, 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 WebSocketHandlerMapping()
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description int
getPhase()
Return the phase value of this object.protected void
initServletContext(ServletContext servletContext)
Subclasses may override this for custom initialization based on the ServletContext that this application object runs in.boolean
isAutoStartup()
Returnstrue
if thisLifecycle
component should get started automatically by the container at the time that the containingApplicationContext
gets refreshed.boolean
isRunning()
Check whether this component is currently running.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.void
stop(Runnable callback)
Indicates that a Lifecycle component must stop if it is currently running.Methods inherited from class org.springframework.web.servlet.handler.SimpleUrlHandlerMapping
getUrlMap, initApplicationContext, registerHandlers, setMappings, setUrlMap
Methods inherited from class org.springframework.web.servlet.handler.AbstractUrlHandlerMapping
buildPathExposingHandler, exposePathWithinMapping, exposeUriTemplateVariables, getHandlerInternal, getHandlerMap, getRootHandler, lookupHandler, match, registerHandler, registerHandler, setLazyInitHandlers, setRootHandler, setUseTrailingSlashMatch, supportsTypeLevelMappings, useTrailingSlashMatch, validateHandler
Methods inherited from class org.springframework.web.servlet.handler.AbstractHandlerMapping
adaptInterceptor, detectMappedInterceptors, extendInterceptors, getAdaptedInterceptors, getCorsConfiguration, getCorsConfigurations, getCorsHandlerExecutionChain, getCorsProcessor, getDefaultHandler, getHandler, getHandlerExecutionChain, getMappedInterceptors, getOrder, getPathMatcher, getUrlPathHelper, 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, isContextRequired, setServletContext
Methods inherited from class org.springframework.context.support.ApplicationObjectSupport
getApplicationContext, getMessageSourceAccessor, 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
Constructor Detail
WebSocketHandlerMapping
public WebSocketHandlerMapping()
Method Detail
initServletContext
protected void initServletContext(ServletContext servletContext)
Description copied from class:WebApplicationObjectSupport
Subclasses may override this for custom initialization based on the ServletContext that this application object runs in.The default implementation is empty. Called by
WebApplicationObjectSupport.initApplicationContext(org.springframework.context.ApplicationContext)
as well asWebApplicationObjectSupport.setServletContext(javax.servlet.ServletContext)
.- Overrides:
initServletContext
in classWebApplicationObjectSupport
- Parameters:
servletContext
- the ServletContext that this application object runs in (nevernull
)
isAutoStartup
public boolean isAutoStartup()
Description copied from interface:SmartLifecycle
Returnstrue
if thisLifecycle
component should get started automatically by the container at the time that the containingApplicationContext
gets refreshed.A value of
false
indicates that the component is intended to be started through an explicitLifecycle.start()
call instead, analogous to a plainLifecycle
implementation.- Specified by:
isAutoStartup
in interfaceSmartLifecycle
- See Also:
Lifecycle.start()
,Phased.getPhase()
,LifecycleProcessor.onRefresh()
,ConfigurableApplicationContext.refresh()
getPhase
public int getPhase()
Description copied from interface:Phased
Return the phase value of this object.
start
public void start()
Description copied from interface:Lifecycle
Start this component.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.
- Specified by:
start
in interfaceLifecycle
- See Also:
SmartLifecycle.isAutoStartup()
stop
public void stop()
Description copied from interface:Lifecycle
Stop this component, typically in a synchronous fashion, such that the component is fully stopped upon return of this method. Consider implementingSmartLifecycle
and itsstop(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.
- Specified by:
stop
in interfaceLifecycle
- See Also:
SmartLifecycle.stop(Runnable)
,DisposableBean.destroy()
stop
public void stop(Runnable callback)
Description copied from interface:SmartLifecycle
Indicates that a Lifecycle component must stop if it is currently running.The provided callback is used by the
LifecycleProcessor
to support an ordered, and potentially concurrent, shutdown of all components having a common shutdown order value. The callback must be executed after theSmartLifecycle
component does indeed stop.The
LifecycleProcessor
will call only this variant of thestop
method; i.e.Lifecycle.stop()
will not be called forSmartLifecycle
implementations unless explicitly delegated to within the implementation of this method.- Specified by:
stop
in interfaceSmartLifecycle
- See Also:
Lifecycle.stop()
,Phased.getPhase()