01: package org.mockejb.jms;
02:
03: import javax.jms.*;
04:
05: /**
06: * <code>TopicPublisher</code> implementation.
07: * Supports only <code>MockDestination</code> destinations.
08: * @author Dimitar Gospodinov
09: */
10: class TopicPublisherImpl extends MockProducer implements TopicPublisher {
11:
12: /**
13: * Creates new topic publisher for <code>topic</code>.
14: * @param topic
15: */
16: public TopicPublisherImpl(MockTopic topic) {
17: super (topic);
18: }
19:
20: /**
21: * @see javax.jms.TopicPublisher#getTopic()
22: */
23: public Topic getTopic() throws JMSException {
24: return (Topic) getDestination();
25: }
26:
27: /**
28: * @see javax.jms.TopicPublisher#publish(javax.jms.Message)
29: */
30: public void publish(Message msg) throws JMSException {
31: send(msg);
32: }
33:
34: /**
35: * @see javax.jms.TopicPublisher#publish(javax.jms.Message, int, int, long)
36: */
37: public void publish(Message msg, int deliveryMode, int priority,
38: long timeToLive) throws JMSException {
39:
40: send(msg, deliveryMode, priority, timeToLive);
41: }
42:
43: /**
44: * @see javax.jms.TopicPublisher#publish(javax.jms.Topic, javax.jms.Message)
45: */
46: public void publish(Topic topic, Message msg) throws JMSException {
47: publish(topic, msg, getDeliveryMode(), getPriority(), 0);
48: }
49:
50: /**
51: * @see javax.jms.TopicPublisher#publish(javax.jms.Topic, javax.jms.Message, int, int, long)
52: */
53: public void publish(Topic topic, Message msg, int deliveryMode,
54: int priority, long timeToLive) throws JMSException {
55:
56: checkDestination(true);
57: if (topic instanceof MockTopic) {
58: MockProducer.sendMessage((MockTopic) topic, msg,
59: deliveryMode, priority, timeToLive);
60: }
61: throw new InvalidDestinationException(
62: "Invalid topic specified!");
63: }
64: }
|