KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > scalagent > kjoram > QueueSender


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  * Copyright (C) 2001 - ScalAgent Distributed Technologies
4  * Copyright (C) 1996 - Dyade
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA.
20  *
21  * Initial developer(s): Frederic Maistre (INRIA)
22  * Contributor(s): Nicolas Tachker (ScalAgent)
23  */

24 package com.scalagent.kjoram;
25
26 import com.scalagent.kjoram.excepts.IllegalStateException;
27 import com.scalagent.kjoram.excepts.JMSException;
28
29
30 public class QueueSender extends MessageProducer
31 {
32   /**
33    * Constructs a sender.
34    *
35    * @param sess The session the sender belongs to.
36    * @param queue The queue the sender sends messages to.
37    *
38    * @exception IllegalStateException If the connection is broken.
39    * @exception JMSException If the creation fails for any other reason.
40    */

41   QueueSender(QueueSession sess, Queue queue) throws JMSException
42   {
43     super(sess, queue);
44   }
45
46   /** Returns a string view of this receiver. */
47   public String JavaDoc toString()
48   {
49     return "QueueSend:" + sess.ident;
50   }
51
52   /**
53    * API method.
54    *
55    * @exception IllegalStateException If the sender is closed.
56    */

57   public Queue getQueue() throws JMSException
58   {
59     if (closed)
60       throw new IllegalStateException JavaDoc("Forbidden call on a closed sender.");
61
62     return (Queue) super.dest;
63   }
64
65   /**
66    * API method.
67    *
68    * @exception UnsupportedOperationException When the sender did not
69    * properly identify itself.
70    * @exception JMSSecurityException If the user if not a WRITER on the
71    * specified queue.
72    * @exception IllegalStateException If the sender is closed, or if the
73    * connection is broken.
74    * @exception JMSException If the request fails for any other reason.
75    */

76   public void send(Queue queue, Message message)
77             throws JMSException
78   {
79     super.send(queue, message);
80   }
81
82   /**
83    * API method.
84    *
85    * @exception UnsupportedOperationException When the sender did not
86    * properly identify itself.
87    * @exception JMSSecurityException If the user if not a WRITER on the
88    * specified queue.
89    * @exception IllegalStateException If the sender is closed, or if the
90    * connection is broken.
91    * @exception JMSException If the request fails for any other reason.
92    */

93   public void send(Queue queue, Message message,
94                    int deliveryMode, int priority,
95                    long timeToLive) throws JMSException
96   {
97     super.send(queue, message, deliveryMode, priority, timeToLive);
98   }
99 }
100
Popular Tags