spring-framework / org.springframework.web.socket.config.annotation

Package org.springframework.web.socket.config.annotation

Types

AbstractWebSocketHandlerRegistration

abstract class AbstractWebSocketHandlerRegistration<M : Any> : WebSocketHandlerRegistration

Base class for WebSocketHandlerRegistrations that gathers all the configuration options but allows sub-classes to put together the actual HTTP request mappings.

AbstractWebSocketMessageBrokerConfigurer

abstract class AbstractWebSocketMessageBrokerConfigurer : WebSocketMessageBrokerConfigurer

A convenient abstract base class for WebSocketMessageBrokerConfigurer implementations providing empty method implementations for optional methods.

DelegatingWebSocketConfiguration

open class DelegatingWebSocketConfiguration : WebSocketConfigurationSupport

A variation of WebSocketConfigurationSupport that detects implementations of WebSocketConfigurer in Spring configuration and invokes them in order to configure WebSocket request handling.

DelegatingWebSocketMessageBrokerConfiguration

open class DelegatingWebSocketMessageBrokerConfiguration : WebSocketMessageBrokerConfigurationSupport

A WebSocketMessageBrokerConfigurationSupport extension that detects beans of type WebSocketMessageBrokerConfigurer and delegates to all of them allowing callback style customization of the configuration provided in WebSocketMessageBrokerConfigurationSupport.

This class is typically imported via EnableWebSocketMessageBroker.

ServletWebSocketHandlerRegistry

open class ServletWebSocketHandlerRegistry : WebSocketHandlerRegistry

A WebSocketHandlerRegistry that maps WebSocketHandlers to URLs for use in a Servlet container.

SockJsServiceRegistration

open class SockJsServiceRegistration

A helper class for configuring SockJS fallback options for use with an org.springframework.web.socket.config.annotation.EnableWebSocket and WebSocketConfigurer setup.

WebMvcStompEndpointRegistry

open class WebMvcStompEndpointRegistry : StompEndpointRegistry

A registry for STOMP over WebSocket endpoints that maps the endpoints with a org.springframework.web.servlet.HandlerMapping for use in Spring MVC.

WebSocketConfigurer

interface WebSocketConfigurer

Defines callback methods to configure the WebSocket request handling via org.springframework.web.socket.config.annotation.EnableWebSocket.

WebSocketHandlerRegistration

interface WebSocketHandlerRegistration

Provides methods for configuring a WebSocket handler.

WebSocketMessageBrokerConfigurationSupport

abstract class WebSocketMessageBrokerConfigurationSupport : AbstractMessageBrokerConfiguration

Extends AbstractMessageBrokerConfiguration and adds configuration for receiving and responding to STOMP messages from WebSocket clients.

Typically used in conjunction with EnableWebSocketMessageBroker but can also be extended directly.

Annotations

EnableWebSocket

class EnableWebSocket

Add this annotation to an @Configuration class to configure processing WebSocket requests:

 @Configuration @EnableWebSocket public class MyWebSocketConfig { } 

Customize the imported configuration by implementing the WebSocketConfigurer interface:

 @Configuration @EnableWebSocket public class MyConfiguration implements WebSocketConfigurer { @Override public void registerWebSocketHandlers(WebSocketHandlerRegistry registry) { registry.addHandler(echoWebSocketHandler(), "/echo").withSockJS(); } @Bean public WebSocketHandler echoWebSocketHandler() { return new EchoWebSocketHandler(); } } 

EnableWebSocketMessageBroker

class EnableWebSocketMessageBroker

Add this annotation to an @Configuration class to enable broker-backed messaging over WebSocket using a higher-level messaging sub-protocol.

 @Configuration @EnableWebSocketMessageBroker public class MyWebSocketConfig { } 

Customize the imported configuration by implementing the WebSocketMessageBrokerConfigurer interface or more likely extend the convenient base class AbstractWebSocketMessageBrokerConfigurer:

 @Configuration @EnableWebSocketMessageBroker public class MyConfiguration extends AbstractWebSocketMessageBrokerConfigurer { @Override public void registerStompEndpoints(StompEndpointRegistry registry) { registry.addEndpoint("/portfolio").withSockJS(); } @Bean public void configureMessageBroker(MessageBrokerRegistry registry) { registry.enableStompBrokerRelay("/queue/", "/topic/"); registry.setApplicationDestinationPrefixes("/app/"); } }