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