Class AbstractWebSocketHandlerRegistration<M>
- java.lang.Object
- org.springframework.web.socket.config.annotation.AbstractWebSocketHandlerRegistration<M>
- All Implemented Interfaces:
WebSocketHandlerRegistration
- Direct Known Subclasses:
ServletWebSocketHandlerRegistration
public abstract class AbstractWebSocketHandlerRegistration<M> extends Object implements WebSocketHandlerRegistration
Base class forWebSocketHandlerRegistration
s that gathers all the configuration options but allows sub-classes to put together the actual HTTP request mappings.- Since:
- 4.0
- Author:
- Rossen Stoyanchev, Sebastien Deleuze
Constructor Summary
Constructors Constructor Description AbstractWebSocketHandlerRegistration(TaskScheduler defaultTaskScheduler)
Method Summary
All Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description WebSocketHandlerRegistration
addHandler(WebSocketHandler handler, String... paths)
Add more handlers that will share the same configuration (interceptors, SockJS config, etc)WebSocketHandlerRegistration
addInterceptors(HandshakeInterceptor... interceptors)
Configure interceptors for the handshake request.protected abstract void
addSockJsServiceMapping(M mappings, SockJsService sockJsService, WebSocketHandler handler, String pathPattern)
protected abstract void
addWebSocketHandlerMapping(M mappings, WebSocketHandler wsHandler, HandshakeHandler handshakeHandler, HandshakeInterceptor[] interceptors, String path)
protected abstract M
createMappings()
protected HandshakeHandler
getHandshakeHandler()
protected HandshakeInterceptor[]
getInterceptors()
protected M
getMappings()
WebSocketHandlerRegistration
setAllowedOrigins(String... allowedOrigins)
Configure allowedOrigin
header values.WebSocketHandlerRegistration
setHandshakeHandler(HandshakeHandler handshakeHandler)
Configure the HandshakeHandler to use.SockJsServiceRegistration
withSockJS()
Enable SockJS fallback options.
Constructor Detail
AbstractWebSocketHandlerRegistration
public AbstractWebSocketHandlerRegistration(TaskScheduler defaultTaskScheduler)
Method Detail
addHandler
public WebSocketHandlerRegistration addHandler(WebSocketHandler handler, String... paths)
Description copied from interface:WebSocketHandlerRegistration
Add more handlers that will share the same configuration (interceptors, SockJS config, etc)- Specified by:
addHandler
in interfaceWebSocketHandlerRegistration
setHandshakeHandler
public WebSocketHandlerRegistration setHandshakeHandler(HandshakeHandler handshakeHandler)
Description copied from interface:WebSocketHandlerRegistration
Configure the HandshakeHandler to use.- Specified by:
setHandshakeHandler
in interfaceWebSocketHandlerRegistration
getHandshakeHandler
protected HandshakeHandler getHandshakeHandler()
addInterceptors
public WebSocketHandlerRegistration addInterceptors(HandshakeInterceptor... interceptors)
Description copied from interface:WebSocketHandlerRegistration
Configure interceptors for the handshake request.- Specified by:
addInterceptors
in interfaceWebSocketHandlerRegistration
setAllowedOrigins
public WebSocketHandlerRegistration setAllowedOrigins(String... allowedOrigins)
Description copied from interface:WebSocketHandlerRegistration
Configure allowedOrigin
header values. This check is mostly designed for browser clients. There is nothing preventing other types of client to modify theOrigin
header value.When SockJS is enabled and origins are restricted, transport types that do not allow to check request origin (JSONP and Iframe based transports) are disabled. As a consequence, IE 6 to 9 are not supported when origins are restricted.
Each provided allowed origin must start by "http://", "https://" or be "*" (means that all origins are allowed). By default, only same origin requests are allowed (empty list).
- Specified by:
setAllowedOrigins
in interfaceWebSocketHandlerRegistration
- See Also:
- RFC 6454: The Web Origin Concept, SockJS supported transports by browser
withSockJS
public SockJsServiceRegistration withSockJS()
Description copied from interface:WebSocketHandlerRegistration
Enable SockJS fallback options.- Specified by:
withSockJS
in interfaceWebSocketHandlerRegistration
getInterceptors
protected HandshakeInterceptor[] getInterceptors()
getMappings
protected final M getMappings()
createMappings
protected abstract M createMappings()
addSockJsServiceMapping
protected abstract void addSockJsServiceMapping(M mappings, SockJsService sockJsService, WebSocketHandler handler, String pathPattern)
addWebSocketHandlerMapping
protected abstract void addWebSocketHandlerMapping(M mappings, WebSocketHandler wsHandler, HandshakeHandler handshakeHandler, HandshakeInterceptor[] interceptors, String path)