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