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 ofSimpleUrlHandlerMappingthat is also aSmartLifecyclecontainer and propagates start and stop calls to any handlers that implementLifecycle. The handlers are typically expected to beWebSocketHttpRequestHandlerorSockJsHttpRequestHandler.- 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 intgetPhase()Return the phase value of this object.protected voidinitServletContext(ServletContext servletContext)Subclasses may override this for custom initialization based on the ServletContext that this application object runs in.booleanisAutoStartup()Returnstrueif thisLifecyclecomponent should get started automatically by the container at the time that the containingApplicationContextgets refreshed.booleanisRunning()Check whether this component is currently running.voidstart()Start this component.voidstop()Stop this component, typically in a synchronous fashion, such that the component is fully stopped upon return of this method.voidstop(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:WebApplicationObjectSupportSubclasses 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:
initServletContextin classWebApplicationObjectSupport- Parameters:
servletContext- the ServletContext that this application object runs in (nevernull)
isAutoStartup
public boolean isAutoStartup()
Description copied from interface:SmartLifecycleReturnstrueif thisLifecyclecomponent should get started automatically by the container at the time that the containingApplicationContextgets refreshed.A value of
falseindicates that the component is intended to be started through an explicitLifecycle.start()call instead, analogous to a plainLifecycleimplementation.- Specified by:
isAutoStartupin interfaceSmartLifecycle- See Also:
Lifecycle.start(),Phased.getPhase(),LifecycleProcessor.onRefresh(),ConfigurableApplicationContext.refresh()
getPhase
public int getPhase()
Description copied from interface:PhasedReturn the phase value of this object.
start
public void start()
Description copied from interface:LifecycleStart 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:
startin interfaceLifecycle- See Also:
SmartLifecycle.isAutoStartup()
stop
public void stop()
Description copied from interface:LifecycleStop this component, typically in a synchronous fashion, such that the component is fully stopped upon return of this method. Consider implementingSmartLifecycleand itsstop(Runnable)variant when asynchronous stop behavior is necessary.Note that this stop notification is not guaranteed to come before destruction: On regular shutdown,
Lifecyclebeans 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:
stopin interfaceLifecycle- See Also:
SmartLifecycle.stop(Runnable),DisposableBean.destroy()
stop
public void stop(Runnable callback)
Description copied from interface:SmartLifecycleIndicates that a Lifecycle component must stop if it is currently running.The provided callback is used by the
LifecycleProcessorto support an ordered, and potentially concurrent, shutdown of all components having a common shutdown order value. The callback must be executed after theSmartLifecyclecomponent does indeed stop.The
LifecycleProcessorwill call only this variant of thestopmethod; i.e.Lifecycle.stop()will not be called forSmartLifecycleimplementations unless explicitly delegated to within the implementation of this method.- Specified by:
stopin interfaceSmartLifecycle- See Also:
Lifecycle.stop(),Phased.getPhase()