/*
 * Copyright 2002-2004 the original author or authors.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

package org.springframework.jms.support.destination;

import javax.jms.Destination;
import javax.jms.JMSException;
import javax.jms.Session;

/**
 * Simple implementation of the DestinationResolver interface,
 * resolving destination names as dynamic destinations.
 * @author Juergen Hoeller
 * @since 20.07.2004
 * @see javax.jms.Session#createQueue
 * @see javax.jms.Session#createTopic
 */
public class DynamicDestinationResolver implements DestinationResolver {

	public Destination resolveDestinationName(Session session, String destinationName, boolean isPubSubDomain)
			throws JMSException {
		if (isPubSubDomain) {
			return session.createTopic(destinationName);
		}
		else {
			return session.createQueue(destinationName);
		}
	}

}

@@ -743,24 +743,86 @@
 t javax.jms.
+QueueSession;%0Aimport javax.jms.Session;%0Aimport javax.jms.Topic
 Session;%0A%0A/*
@@ -948,53 +948,342 @@
 .%0A *
- @author Juergen Hoeller%0A * @since 20.07.2004
+%0A * %3Cp%3EThis implementation will work on both JMS 1.1 and JMS 1.0.2,%0A * because it uses the QueueSession respectively TopicSession methods%0A * if possible, falling back to JMS 1.1's generic Session methods.%0A *%0A * @author Juergen Hoeller%0A * @since 1.1%0A * @see javax.jms.QueueSession#createQueue%0A * @see javax.jms.TopicSession#createTopic
 %0A * 
@@ -1525,19 +1525,17 @@
 boolean 
-isP
+p
 ubSubDom
@@ -1574,11 +1574,9 @@
 if (
-isP
+p
 ubSu
@@ -1585,38 +1585,162 @@
 omain) %7B%0A%09%09%09
-return
+if (session instanceof TopicSession) %7B%0A%09%09%09%09// cast to TopicSession: will work on both JMS 1.1 and 1.0.2%0A%09%09%09%09return ((TopicSession)
  session
 .createTopic
@@ -1723,24 +1723,25 @@
 ion) session
+)
 .createTopic
@@ -1761,18 +1761,20 @@
 ame);%0A%09%09
+%09
 %7D%0A
+%09
 %09%09else %7B
@@ -1781,52 +1781,445 @@
 %0A%09%09%09
-return session.createQueue(destinationName);
+%09// fallback to generic JMS Session: will only work on JMS 1.1%0A%09%09%09%09return session.createTopic(destinationName);%0A%09%09%09%7D%0A%09%09%7D%0A%09%09else %7B%0A%09%09%09if (session instanceof QueueSession) %7B%0A%09%09%09%09// cast to QueueSession: will work on both JMS 1.1 and 1.0.2%0A%09%09%09%09return ((QueueSession) session).createQueue(destinationName);%0A%09%09%09%7D%0A%09%09%09else %7B%0A%09%09%09%09// fallback to generic JMS Session: will only work on JMS 1.1%0A%09%09%09%09return session.createQueue(destinationName);%0A%09%09%09%7D
 %0A%09%09%7D

work with both JMS 1.1 and JMS 1.0.2