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.jms.support.destination;
018
019import javax.jms.Destination;
020import javax.jms.JMSException;
021import javax.jms.Session;
022
023import org.springframework.lang.Nullable;
024
025/**
026 * Strategy interface for resolving JMS destinations.
027 *
028 * <p>Used by {@link org.springframework.jms.core.JmsTemplate} for resolving
029 * destination names from simple {@link String Strings} to actual
030 * {@link Destination} implementation instances.
031 *
032 * <p>The default {@link DestinationResolver} implementation used by
033 * {@link org.springframework.jms.core.JmsTemplate} instances is the
034 * {@link DynamicDestinationResolver} class. Consider using the
035 * {@link JndiDestinationResolver} for more advanced scenarios.
036 *
037 * @author Juergen Hoeller
038 * @since 1.1
039 * @see org.springframework.jms.core.JmsTemplate#setDestinationResolver
040 * @see org.springframework.jms.support.destination.DynamicDestinationResolver
041 * @see org.springframework.jms.support.destination.JndiDestinationResolver
042 */
043@FunctionalInterface
044public interface DestinationResolver {
045
046        /**
047         * Resolve the given destination name, either as located resource
048         * or as dynamic destination.
049         * @param session the current JMS Session
050         * (may be {@code null} if the resolver implementation is able to work without it)
051         * @param destinationName the name of the destination
052         * @param pubSubDomain {@code true} if the domain is pub-sub, {@code false} if P2P
053         * @return the JMS destination (either a topic or a queue)
054         * @throws javax.jms.JMSException if the JMS Session failed to resolve the destination
055         * @throws DestinationResolutionException in case of general destination resolution failure
056         */
057        Destination resolveDestinationName(@Nullable Session session, String destinationName, boolean pubSubDomain)
058                        throws JMSException;
059
060}