org.springframework.web.socket.config.annotation

## 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

Constructors
Constructor and Description
`AbstractWebSocketHandlerRegistration()`

### Method Summary

All Methods Instance Methods Abstract Methods Concrete Methods
`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` `setAllowedOrigins(String... allowedOrigins)` Configure allowed `Origin` header values.
`WebSocketHandlerRegistration` `setHandshakeHandler(HandshakeHandler handshakeHandler)` Configure the HandshakeHandler to use.
`SockJsServiceRegistration` `withSockJS()` Enable SockJS fallback options.

### Methods inherited from class java.lang.Object

`clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

### Constructor Detail

#### AbstractWebSocketHandlerRegistration

    public AbstractWebSocketHandlerRegistration()

### 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 interface `WebSocketHandlerRegistration`

#### setHandshakeHandler

    public WebSocketHandlerRegistration setHandshakeHandler(@Nullable
                                                            HandshakeHandler handshakeHandler)

Description copied from interface: `WebSocketHandlerRegistration`
Configure the HandshakeHandler to use.

Specified by:
  `setHandshakeHandler` in interface `WebSocketHandlerRegistration`

#### getHandshakeHandler

    @Nullable
    protected HandshakeHandler getHandshakeHandler()

#### addInterceptors

    public WebSocketHandlerRegistration addInterceptors(HandshakeInterceptor... interceptors)

Description copied from interface: `WebSocketHandlerRegistration`
Configure interceptors for the handshake request.

Specified by:
  `addInterceptors` in interface `WebSocketHandlerRegistration`

#### setAllowedOrigins

    public WebSocketHandlerRegistration setAllowedOrigins(String... allowedOrigins)

Description copied from interface: `WebSocketHandlerRegistration`
Configure allowed `Origin` header values. This check is mostly designed for browser clients. There is nothing preventing other types of client to modify the `Origin` header value.

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.

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 interface `WebSocketHandlerRegistration`
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 interface `WebSocketHandlerRegistration`

#### getInterceptors

    protected HandshakeInterceptor[] getInterceptors()

#### getSockJsServiceRegistration

    @Nullable
    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()`.

#### 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)