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 subclasses to put together the actual HTTP request mappings.- Since:
- 4.0
- Author:
- Rossen Stoyanchev, Sebastien Deleuze
-
Constructor Summary
Constructors -
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 voidaddSockJsServiceMapping(M mappings, SockJsService sockJsService, WebSocketHandler handler, String pathPattern) protected abstract voidaddWebSocketHandlerMapping(M mappings, WebSocketHandler wsHandler, HandshakeHandler handshakeHandler, HandshakeInterceptor[] interceptors, String path) protected abstract Mprotected @Nullable HandshakeHandlerprotected HandshakeInterceptor[]protected final Mprotected @Nullable SockJsServiceRegistrationExpose theSockJsServiceRegistration-- if SockJS is enabled ornullotherwise -- 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(@Nullable HandshakeHandler handshakeHandler) Configure the HandshakeHandler to use.Enable SockJS fallback options.
-
Constructor Details
-
AbstractWebSocketHandlerRegistration
public AbstractWebSocketHandlerRegistration()
-
-
Method Details
-
addHandler
Description copied from interface:WebSocketHandlerRegistrationAdd more handlers that will share the same configuration (interceptors, SockJS config, etc).- Specified by:
addHandlerin interfaceWebSocketHandlerRegistration
-
setHandshakeHandler
public WebSocketHandlerRegistration setHandshakeHandler(@Nullable HandshakeHandler handshakeHandler) Description copied from interface:WebSocketHandlerRegistrationConfigure the HandshakeHandler to use.- Specified by:
setHandshakeHandlerin interfaceWebSocketHandlerRegistration
-
getHandshakeHandler
-
addInterceptors
Description copied from interface:WebSocketHandlerRegistrationConfigure interceptors for the handshake request.- Specified by:
addInterceptorsin interfaceWebSocketHandlerRegistration
-
setAllowedOrigins
Description copied from interface:WebSocketHandlerRegistrationSet 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(String...)instead.By default, no origins are allowed. When
allowedOriginPatternsis 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.
- Specified by:
setAllowedOriginsin interfaceWebSocketHandlerRegistration- See Also:
-
setAllowedOriginPatterns
Description copied from interface:WebSocketHandlerRegistrationAlternative 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:
setAllowedOriginPatternsin interfaceWebSocketHandlerRegistration
-
withSockJS
Description copied from interface:WebSocketHandlerRegistrationEnable SockJS fallback options.- Specified by:
withSockJSin interfaceWebSocketHandlerRegistration
-
getInterceptors
-
getSockJsServiceRegistration
Expose theSockJsServiceRegistration-- if SockJS is enabled ornullotherwise -- 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)
-