001/*
002 * Copyright 2002-2016 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.messaging.simp.user;
018
019import org.springframework.lang.Nullable;
020import org.springframework.messaging.Message;
021
022/**
023 * A strategy for resolving a "user" destination by translating it to one or more
024 * actual destinations one per active user session. When sending a message to a
025 * user destination, the destination must contain the user name so it may be
026 * extracted and used to look up the user sessions. When subscribing to a user
027 * destination, the destination does not have to contain the user's own name.
028 * We simply use the current session.
029 *
030 * <p>See implementation classes and the documentation for example destinations.
031 *
032 * @author Rossen Stoyanchev
033 * @since 4.0
034 *
035 * @see org.springframework.messaging.simp.user.DefaultUserDestinationResolver
036 * @see UserDestinationMessageHandler
037 */
038@FunctionalInterface
039public interface UserDestinationResolver {
040
041        /**
042         * Resolve the given message with a user destination to one or more messages
043         * with actual destinations, one for each active user session.
044         * @param message the message to try to resolve
045         * @return 0 or more target messages (one for each active session), or
046         * {@code null} if the source message does not contain a user destination.
047         */
048        @Nullable
049        UserDestinationResult resolveDestination(Message<?> message);
050
051}