Class AbstractWebSocketHandlerRegistration<M>
java.lang.Object
org.springframework.web.socket.config.annotation.AbstractWebSocketHandlerRegistration<M>
- Type Parameters:
M
- the mappings type
- All Implemented Interfaces:
WebSocketHandlerRegistration
- Direct Known Subclasses:
ServletWebSocketHandlerRegistration
public abstract class AbstractWebSocketHandlerRegistration<M>
extends Object
implements WebSocketHandlerRegistration
Base class for
WebSocketHandlerRegistrations
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
-
Method Summary
Modifier and TypeMethodDescriptionaddHandler
(WebSocketHandler handler, String... paths) Add more handlers that will share the same configuration (interceptors, SockJS config, etc).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
protected HandshakeHandler
protected HandshakeInterceptor[]
protected final M
protected SockJsServiceRegistration
Expose theSockJsServiceRegistration
-- if SockJS is enabled ornull
otherwise -- so that it can be configured with a TaskScheduler if the application did not provide one.setAllowedOriginPatterns
(String... allowedOriginPatterns) Alternative toWebSocketHandlerRegistration.setAllowedOrigins(String...)
that supports more flexible patterns for specifying the origins for which cross-origin requests are allowed from a browser.setAllowedOrigins
(String... allowedOrigins) Set the origins for which cross-origin requests are allowed from a browser.setHandshakeHandler
(HandshakeHandler handshakeHandler) Configure the HandshakeHandler to use.Enable SockJS fallback options.
-
Constructor Details
-
AbstractWebSocketHandlerRegistration
public AbstractWebSocketHandlerRegistration()
-
-
Method Details
-
addHandler
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(@Nullable HandshakeHandler handshakeHandler) Description copied from interface:WebSocketHandlerRegistration
Configure the HandshakeHandler to use.- Specified by:
setHandshakeHandler
in interfaceWebSocketHandlerRegistration
-
getHandshakeHandler
-
addInterceptors
Description copied from interface:WebSocketHandlerRegistration
Configure interceptors for the handshake request.- Specified by:
addInterceptors
in interfaceWebSocketHandlerRegistration
-
setAllowedOrigins
Description copied from interface:WebSocketHandlerRegistration
Set the origins for which cross-origin requests are allowed from a browser. Please, refer toCorsConfiguration.setAllowedOrigins(List)
for format details and considerations, and keep in mind that the CORS spec does not allow use of"*"
withallowCredentials=true
. For more flexible origin patterns useWebSocketHandlerRegistration.setAllowedOriginPatterns(java.lang.String...)
instead.By default, no origins are allowed. When
allowedOriginPatterns
is also set, then that takes precedence over this property.Note when SockJS is enabled and origins are restricted, transport types that do not allow to check request origin (Iframe based transports) are disabled. As a consequence, IE 6 to 9 are not supported when origins are restricted.
-
setAllowedOriginPatterns
Description copied from interface:WebSocketHandlerRegistration
Alternative toWebSocketHandlerRegistration.setAllowedOrigins(String...)
that supports more flexible patterns for specifying the origins for which cross-origin requests are allowed from a browser. Please, refer toCorsConfiguration.setAllowedOriginPatterns(List)
for format details and other considerations.By default this is not set.
- Specified by:
setAllowedOriginPatterns
in interfaceWebSocketHandlerRegistration
-
withSockJS
Description copied from interface:WebSocketHandlerRegistration
Enable SockJS fallback options.- Specified by:
withSockJS
in interfaceWebSocketHandlerRegistration
-
getInterceptors
-
getSockJsServiceRegistration
Expose theSockJsServiceRegistration
-- if SockJS is enabled ornull
otherwise -- so that it can be configured with a TaskScheduler if the application did not provide one. This should be done prior to callinggetMappings()
. -
getMappings
-
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)
-