M
- the mappings typepublic abstract class AbstractWebSocketHandlerRegistration<M> extends Object implements WebSocketHandlerRegistration
WebSocketHandlerRegistrations
that gathers all the configuration
options but allows sub-classes to put together the actual HTTP request mappings.Constructor and Description |
---|
AbstractWebSocketHandlerRegistration() |
Modifier and Type | Method and 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() |
protected SockJsServiceRegistration |
getSockJsServiceRegistration()
Expose the
SockJsServiceRegistration -- if SockJS is enabled or
null otherwise -- so that it can be configured with a TaskScheduler
if the application did not provide one. |
WebSocketHandlerRegistration |
setAllowedOriginPatterns(String... allowedOriginPatterns)
Alternative to
WebSocketHandlerRegistration.setAllowedOrigins(String...) that supports more
flexible patterns for specifying the origins for which cross-origin
requests are allowed from a browser. |
WebSocketHandlerRegistration |
setAllowedOrigins(String... allowedOrigins)
Set the origins for which cross-origin requests are allowed from a browser.
|
WebSocketHandlerRegistration |
setHandshakeHandler(HandshakeHandler handshakeHandler)
Configure the HandshakeHandler to use.
|
SockJsServiceRegistration |
withSockJS()
Enable SockJS fallback options.
|
public AbstractWebSocketHandlerRegistration()
public WebSocketHandlerRegistration addHandler(WebSocketHandler handler, String... paths)
WebSocketHandlerRegistration
addHandler
in interface WebSocketHandlerRegistration
public WebSocketHandlerRegistration setHandshakeHandler(@Nullable HandshakeHandler handshakeHandler)
WebSocketHandlerRegistration
setHandshakeHandler
in interface WebSocketHandlerRegistration
@Nullable protected HandshakeHandler getHandshakeHandler()
public WebSocketHandlerRegistration addInterceptors(HandshakeInterceptor... interceptors)
WebSocketHandlerRegistration
addInterceptors
in interface WebSocketHandlerRegistration
public WebSocketHandlerRegistration setAllowedOrigins(String... allowedOrigins)
WebSocketHandlerRegistration
CorsConfiguration.setAllowedOrigins(List)
for
format details and considerations, and keep in mind that the CORS spec
does not allow use of "*"
with allowCredentials=true
.
For more flexible origin patterns use WebSocketHandlerRegistration.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.
public WebSocketHandlerRegistration setAllowedOriginPatterns(String... allowedOriginPatterns)
WebSocketHandlerRegistration
WebSocketHandlerRegistration.setAllowedOrigins(String...)
that supports more
flexible patterns for specifying the origins for which cross-origin
requests are allowed from a browser. Please, refer to
CorsConfiguration.setAllowedOriginPatterns(List)
for format
details and other considerations.
By default this is not set.
setAllowedOriginPatterns
in interface WebSocketHandlerRegistration
public SockJsServiceRegistration withSockJS()
WebSocketHandlerRegistration
withSockJS
in interface WebSocketHandlerRegistration
protected HandshakeInterceptor[] getInterceptors()
@Nullable protected SockJsServiceRegistration getSockJsServiceRegistration()
SockJsServiceRegistration
-- if SockJS is enabled or
null
otherwise -- so that it can be configured with a TaskScheduler
if the application did not provide one. This should be done prior to
calling getMappings()
.protected final M getMappings()
protected abstract M createMappings()
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)