1 21 package com.presumo.jms.client; 22 23 import com.presumo.jms.resources.Resources; 24 import com.presumo.jms.router.Router; 25 import com.presumo.util.log.Logger; 26 import com.presumo.util.log.LoggerFactory; 27 28 import javax.jms.InvalidDestinationException ; 29 import javax.jms.JMSException ; 30 import javax.jms.Topic ; 31 import javax.jms.TopicSession ; 32 import javax.jms.TopicSubscriber ; 33 import javax.jms.TopicPublisher ; 34 import javax.jms.TemporaryTopic ; 35 36 37 42 public final class JmsTopicSession extends JmsSession 43 implements TopicSession 44 { 45 46 50 public JmsTopicSession(Router router, 51 boolean transacted, 52 int acknowledgeMode, 53 JmsConnection connx) 54 throws JMSException 55 { 56 super(router, transacted, acknowledgeMode, connx); 57 58 logger.entry("JmsTopicSession"); 59 logger.exit("JmsTopicSession"); 60 } 61 62 63 64 68 69 73 public Topic createTopic(String topicName) throws JMSException 74 { 75 logger.entry("createTopic"); 76 77 JmsTopic retval = new JmsTopic(topicName); 78 79 logger.exit("createTopic"); 80 return retval; 81 } 82 83 84 public TopicSubscriber createSubscriber(Topic topic) 85 throws JMSException 86 { 87 logger.entry("createSubscriber", topic); 88 89 TopicSubscriber sub = createSubscriber(topic, null, false); 90 91 logger.exit("createSubscriber", sub); 92 return sub; 93 } 94 95 98 public TopicSubscriber createSubscriber(Topic topic, 99 String messageSelector, 100 boolean noLocal) 101 throws JMSException 102 { 103 logger.entry("createSubscriber", new Object [] 104 {topic, messageSelector, new Boolean (noLocal)}); 105 106 JmsTopicSubscriber subscriber = null; 107 108 if (! (topic instanceof JmsTopic)) throw new 109 InvalidDestinationException ("Topic must be from this implementation"); 110 if (closed) throw new 111 IllegalStateException ("Operation attempted on a closed object"); 112 113 subscriber = new JmsTopicSubscriber(this, messageSelector, 114 (JmsTopic) topic, noLocal, null); 115 116 logger.exit("createSubscriber", subscriber); 117 return subscriber; 118 } 119 120 123 public TopicSubscriber createDurableSubscriber(Topic topic, String name) 124 throws JMSException 125 { 126 logger.entry("createDurableSubscriber", topic, name); 127 128 TopicSubscriber sub = createDurableSubscriber(topic, name, null, false); 129 130 logger.exit("createDurableSubscriber", sub); 131 return sub; 132 } 133 134 135 138 public TopicSubscriber createDurableSubscriber(Topic topic, 139 String name, 140 String messageSelector, 141 boolean noLocal) 142 throws JMSException 143 { 144 if (logger.isDebugEnabled()) 145 logger.entry("createDurableSubscriber", new Object [] 146 {topic, name, messageSelector, new Boolean (noLocal)}); 147 148 JmsTopicSubscriber subscriber = null; 149 150 if (! (topic instanceof JmsTopic)) throw new 151 InvalidDestinationException ("Topic must be from this implementation"); 152 if (closed) throw new 153 IllegalStateException ("Operation attempted on a closed object"); 154 if (name == null || name.length() == 0) 155 throw new JMSException ("Durable subscriber id can not be null."); 156 157 subscriber = new JmsTopicSubscriber(this, messageSelector, 158 (JmsTopic) topic, noLocal, name); 159 160 logger.exit("createSubscriber", subscriber); 161 return subscriber; 162 } 163 164 165 168 public TopicPublisher createPublisher(Topic topic) 169 throws JMSException 170 { 171 logger.entry("createPublisher"); 172 173 if (! (topic instanceof JmsTopic)) throw new 174 InvalidDestinationException ("Topic must be from this implementation"); 175 if (closed) throw new 176 IllegalStateException ("Operation attempted on a closed object"); 177 178 TopicPublisher pub = new JmsTopicPublisher(this, (JmsTopic) topic); 179 180 logger.exit("createPublisher"); 181 return pub; 182 } 183 184 185 188 public TemporaryTopic createTemporaryTopic() throws JMSException 189 { 190 throw new JMSException ("Operation not implemented"); 191 } 192 193 194 197 public void unsubscribe(String name) throws JMSException 198 { 199 if (name == null || name.length() == 0) 200 throw new IllegalArgumentException ("null or zero length argument"); 201 202 sendQueueRequest(name, null, null, DURABLE_SUBSCRIBER_DELETE); 203 } 204 205 private static Logger logger = 207 LoggerFactory.getLogger(JmsTopicSession.class, Resources.getBundle()); 208 210 } 211 212 213 214 215 | Popular Tags |