01: package org.mockejb.jms;
02:
03: import javax.jms.*;
04:
05: /**
06: * <code>QueueSender</code> implementation.
07: * Supports only queues, which are instances of <code>MockQueue</code>
08: * @author Dimitar Gospodinov
09: * @see javax.jms.QueueSender
10: */
11: class QueueSenderImpl extends MockProducer implements QueueSender {
12:
13: /**
14: * Creates queue sender for <code>queue</code>
15: * @param queue
16: */
17: QueueSenderImpl(MockQueue queue) {
18: super (queue);
19: }
20:
21: /**
22: * @see javax.jms.QueueSender#getQueue()
23: */
24: public Queue getQueue() throws JMSException {
25: return (Queue) getDestination();
26: }
27:
28: /**
29: * @see javax.jms.QueueSender#send(javax.jms.Queue, javax.jms.Message)
30: */
31: public void send(Queue queue, Message msg) throws JMSException {
32: send(queue, msg, getDeliveryMode(), getPriority(), 0);
33: }
34:
35: /**
36: * @see javax.jms.QueueSender#send(javax.jms.Queue, javax.jms.Message, int, int, long)
37: */
38: public void send(Queue queue, Message msg, int deliveryMode,
39: int priority, long timeToLive) throws JMSException {
40:
41: checkDestination(true);
42: if (queue instanceof MockQueue) {
43: MockProducer.sendMessage((MockQueue) queue, msg,
44: deliveryMode, priority, timeToLive);
45: }
46: throw new InvalidDestinationException(
47: "Invalid queue specified!");
48: }
49:
50: }
|