1 16 17 package org.springframework.jms.support.destination; 18 19 import javax.jms.Destination ; 20 import javax.jms.JMSException ; 21 import javax.jms.Queue ; 22 import javax.jms.QueueSession ; 23 import javax.jms.Session ; 24 import javax.jms.Topic ; 25 import javax.jms.TopicSession ; 26 27 import org.springframework.util.Assert; 28 29 45 public class DynamicDestinationResolver implements DestinationResolver { 46 47 57 public Destination resolveDestinationName(Session session, String destinationName, boolean pubSubDomain) 58 throws JMSException { 59 60 Assert.notNull(session, "Session must not be null"); 61 Assert.notNull(destinationName, "Destination name must not be null"); 62 if (pubSubDomain) { 63 return resolveTopic(session, destinationName); 64 } 65 else { 66 return resolveQueue(session, destinationName); 67 } 68 } 69 70 71 79 protected Topic resolveTopic(Session session, String topicName) throws JMSException { 80 if (session instanceof TopicSession ) { 81 return ((TopicSession ) session).createTopic(topicName); 83 } 84 else { 85 return session.createTopic(topicName); 87 } 88 } 89 90 98 protected Queue resolveQueue(Session session, String queueName) throws JMSException { 99 if (session instanceof QueueSession ) { 100 return ((QueueSession ) session).createQueue(queueName); 102 } 103 else { 104 return session.createQueue(queueName); 106 } 107 } 108 109 } 110 | Popular Tags |