001/*
002 * Copyright 2002-2014 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.web.socket.config.annotation;
018
019import java.util.List;
020
021import org.springframework.messaging.converter.MessageConverter;
022import org.springframework.messaging.handler.invocation.HandlerMethodArgumentResolver;
023import org.springframework.messaging.handler.invocation.HandlerMethodReturnValueHandler;
024import org.springframework.messaging.simp.config.ChannelRegistration;
025import org.springframework.messaging.simp.config.MessageBrokerRegistry;
026
027/**
028 * Defines methods for configuring message handling with simple messaging
029 * protocols (e.g. STOMP) from WebSocket clients.
030 *
031 * <p>Typically used to customize the configuration provided via
032 * {@link EnableWebSocketMessageBroker @EnableWebSocketMessageBroker}.
033 *
034 * @author Rossen Stoyanchev
035 * @since 4.0
036 */
037public interface WebSocketMessageBrokerConfigurer {
038
039        /**
040         * Register STOMP endpoints mapping each to a specific URL and (optionally)
041         * enabling and configuring SockJS fallback options.
042         */
043        void registerStompEndpoints(StompEndpointRegistry registry);
044
045        /**
046         * Configure options related to the processing of messages received from and
047         * sent to WebSocket clients.
048         */
049        void configureWebSocketTransport(WebSocketTransportRegistration registry);
050
051        /**
052         * Configure the {@link org.springframework.messaging.MessageChannel} used for
053         * incoming messages from WebSocket clients. By default the channel is backed
054         * by a thread pool of size 1. It is recommended to customize thread pool
055         * settings for production use.
056         */
057        void configureClientInboundChannel(ChannelRegistration registration);
058
059        /**
060         * Configure the {@link org.springframework.messaging.MessageChannel} used for
061         * outbound messages to WebSocket clients. By default the channel is backed
062         * by a thread pool of size 1. It is recommended to customize thread pool
063         * settings for production use.
064         */
065        void configureClientOutboundChannel(ChannelRegistration registration);
066
067        /**
068         * Add resolvers to support custom controller method argument types.
069         * <p>This does not override the built-in support for resolving handler
070         * method arguments. To customize the built-in support for argument
071         * resolution, configure {@code SimpAnnotationMethodMessageHandler} directly.
072         * @param argumentResolvers the resolvers to register (initially an empty list)
073         * @since 4.1.1
074         */
075        void addArgumentResolvers(List<HandlerMethodArgumentResolver> argumentResolvers);
076
077        /**
078         * Add handlers to support custom controller method return value types.
079         * <p>Using this option does not override the built-in support for handling
080         * return values. To customize the built-in support for handling return
081         * values, configure  {@code SimpAnnotationMethodMessageHandler} directly.
082         * @param returnValueHandlers the handlers to register (initially an empty list)
083         * @since 4.1.1
084         */
085        void addReturnValueHandlers(List<HandlerMethodReturnValueHandler> returnValueHandlers);
086
087        /**
088         * Configure the message converters to use when extracting the payload of
089         * messages in annotated methods and when sending messages (e.g. through the
090         * "broker" SimpMessagingTemplate).
091         * <p>The provided list, initially empty, can be used to add message converters
092         * while the boolean return value is used to determine if default message should
093         * be added as well.
094         * @param messageConverters the converters to configure (initially an empty list)
095         * @return whether to also add default converter or not
096         */
097        boolean configureMessageConverters(List<MessageConverter> messageConverters);
098
099        /**
100         * Configure message broker options.
101         */
102        void configureMessageBroker(MessageBrokerRegistry registry);
103
104}