Top Description Fields Constructors Methods
org.springframework.web.socket.config.annotation

public abstract Class AbstractWebSocketHandlerRegistration<M>

extends Object
implements WebSocketHandlerRegistration
Class Inheritance
All Implemented Interfaces
org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration
Known Direct Subclasses
org.springframework.web.socket.config.annotation.ServletWebSocketHandlerRegistration
Type Parameters
<M>
the mappings type
Imports
java.util.ArrayList, .Arrays, .List, org.springframework.lang.Nullable, org.springframework.util.Assert, .LinkedMultiValueMap, .MultiValueMap, .ObjectUtils, .StringUtils, org.springframework.web.socket.WebSocketHandler, org.springframework.web.socket.server.HandshakeHandler, .HandshakeInterceptor, org.springframework.web.socket.server.support.DefaultHandshakeHandler, .OriginHandshakeInterceptor, org.springframework.web.socket.sockjs.SockJsService, org.springframework.web.socket.sockjs.transport.handler.WebSocketTransportHandler

Base class for WebSocketHandlerRegistrations that gathers all the configuration options but allows subclasses to put together the actual HTTP request mappings.
Authors
Rossen Stoyanchev, Sebastien Deleuze
Since
4.0

Field Summary

Modifier and TypeField and Description
private final List<String>
private final List<String>
private final MultiValueMap<WebSocketHandler, String>
private HandshakeHandler
private final List<HandshakeInterceptor>
private SockJsServiceRegistration

Constructor Summary

AccessConstructor and Description
public

Method Summary

Modifier and TypeMethod and Description
public WebSocketHandlerRegistration
addHandler(WebSocketHandler handler, String... paths)

Implements org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration.addHandler.

Add more handlers that will share the same configuration (interceptors, SockJS config, etc).

public WebSocketHandlerRegistration
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
private HandshakeHandler
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.

public WebSocketHandlerRegistration
setAllowedOriginPatterns(String... allowedOriginPatterns)

Implements org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration.setAllowedOriginPatterns.

Alternative to setAllowedOrigins(String...) that supports more flexible patterns for specifying the origins for which cross-origin requests are allowed from a browser.

public WebSocketHandlerRegistration
setAllowedOrigins(String... allowedOrigins)

Implements org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration.setAllowedOrigins.

Set the origins for which cross-origin requests are allowed from a browser.

public WebSocketHandlerRegistration
public SockJsServiceRegistration
Inherited from java.lang.Object:
cloneequalsfinalizegetClasshashCodenotifynotifyAlltoStringwaitwaitwait

Field Detail

allowedOriginPatternsback to summary
private final List<String> allowedOriginPatterns
allowedOriginsback to summary
private final List<String> allowedOrigins
handlerMapback to summary
private final MultiValueMap<WebSocketHandler, String> handlerMap
handshakeHandlerback to summary
private HandshakeHandler handshakeHandler
Annotations
@Nullable
interceptorsback to summary
private final List<HandshakeInterceptor> interceptors
sockJsServiceRegistrationback to summary
private SockJsServiceRegistration sockJsServiceRegistration
Annotations
@Nullable

Constructor Detail

AbstractWebSocketHandlerRegistrationback to summary
public AbstractWebSocketHandlerRegistration()

Method Detail

addHandlerback to summary
public WebSocketHandlerRegistration addHandler(WebSocketHandler handler, String... paths)

Implements org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration.addHandler.

Doc from org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration.addHandler.

Add more handlers that will share the same configuration (interceptors, SockJS config, etc).

Annotations
@Override
addInterceptorsback to summary
public WebSocketHandlerRegistration addInterceptors(HandshakeInterceptor... interceptors)

Implements org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration.addInterceptors.

Doc from org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration.addInterceptors.

Configure interceptors for the handshake request.

Annotations
@Override
addSockJsServiceMappingback to summary
protected abstract void addSockJsServiceMapping(M mappings, SockJsService sockJsService, WebSocketHandler handler, String pathPattern)
addWebSocketHandlerMappingback to summary
protected abstract void addWebSocketHandlerMapping(M mappings, WebSocketHandler wsHandler, HandshakeHandler handshakeHandler, HandshakeInterceptor[] interceptors, String path)
createMappingsback to summary
protected abstract M createMappings()
getHandshakeHandlerback to summary
protected HandshakeHandler getHandshakeHandler()
Annotations
@Nullable
getInterceptorsback to summary
protected HandshakeInterceptor[] getInterceptors()
getMappingsback to summary
protected final M getMappings()
getOrCreateHandshakeHandlerback to summary
private HandshakeHandler getOrCreateHandshakeHandler()
getSockJsServiceRegistrationback to summary
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. This should be done prior to calling getMappings().

Annotations
@Nullable
setAllowedOriginPatternsback to summary
public WebSocketHandlerRegistration setAllowedOriginPatterns(String... allowedOriginPatterns)

Implements org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration.setAllowedOriginPatterns.

Doc from org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration.setAllowedOriginPatterns.

Alternative to 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.

Annotations
@Override
setAllowedOriginsback to summary
public WebSocketHandlerRegistration setAllowedOrigins(String... allowedOrigins)

Implements org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration.setAllowedOrigins.

Doc from org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration.setAllowedOrigins.

Set the origins for which cross-origin requests are allowed from a browser. Please, refer to 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 setAllowedOriginPatterns 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.

Annotations
@Override
setHandshakeHandlerback to summary
public WebSocketHandlerRegistration setHandshakeHandler(HandshakeHandler handshakeHandler)

Implements org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration.setHandshakeHandler.

Doc from org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration.setHandshakeHandler.

Configure the HandshakeHandler to use.

Annotations
@Override
withSockJSback to summary
public SockJsServiceRegistration withSockJS()

Implements org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration.withSockJS.

Doc from org.springframework.web.socket.config.annotation.WebSocketHandlerRegistration.withSockJS.

Enable SockJS fallback options.

Annotations
@Override