KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > joram > client > jms > QueueSession


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):
23  */

24 package org.objectweb.joram.client.jms;
25
26 import javax.jms.IllegalStateException JavaDoc;
27 import javax.jms.JMSException JavaDoc;
28
29 import org.objectweb.joram.client.jms.connection.RequestMultiplexer;
30
31 /**
32  * Implements the <code>javax.jms.QueueSession</code> interface.
33  */

34 public class QueueSession extends Session implements javax.jms.QueueSession JavaDoc
35 {
36   /**
37    * Constructs a queue session.
38    *
39    * @param cnx The connection the session belongs to.
40    * @param transacted <code>true</code> for a transacted session.
41    * @param acknowledgeMode 1 (auto), 2 (client) or 3 (dups ok).
42    *
43    * @exception JMSException In case of an invalid acknowledge mode.
44    */

45   QueueSession(Connection cnx,
46                boolean transacted,
47                int acknowledgeMode,
48                RequestMultiplexer mtpx) throws JMSException JavaDoc
49   {
50     super(cnx, transacted, acknowledgeMode, mtpx);
51   }
52
53   /** Returns a String image of this session. */
54   public String JavaDoc toString()
55   {
56     return "QueueSess:" + getId();
57   }
58
59
60   /**
61    * API method.
62    *
63    * @exception IllegalStateException If the session is closed or if the
64    * connection is broken.
65    * @exception JMSException If the creation fails for any other reason.
66    */

67   public synchronized javax.jms.QueueSender JavaDoc createSender(javax.jms.Queue JavaDoc queue)
68        throws JMSException JavaDoc {
69     checkClosed();
70     QueueSender qc = new QueueSender(this, (Destination) queue);
71     addProducer(qc);
72     return qc;
73   }
74
75   /**
76    * API method.
77    *
78    * @exception IllegalStateException If the session is closed or if the
79    * connection is broken.
80    * @exception JMSException If the creation fails for any other reason.
81    */

82   public javax.jms.QueueReceiver JavaDoc
83          createReceiver(javax.jms.Queue JavaDoc queue, String JavaDoc selector)
84          throws JMSException JavaDoc {
85     checkClosed();
86     QueueReceiver qr = new QueueReceiver(this, (Destination) queue, selector);
87     addConsumer(qr);
88     return qr;
89   }
90
91   /**
92    * API method.
93    *
94    * @exception IllegalStateException If the session is closed or if the
95    * connection is broken.
96    * @exception JMSException If the creation fails for any other reason.
97    */

98   public javax.jms.QueueReceiver JavaDoc createReceiver(javax.jms.Queue JavaDoc queue)
99          throws JMSException JavaDoc {
100     checkClosed();
101     QueueReceiver qr = new QueueReceiver(this, (Destination) queue, null);
102     addConsumer(qr);
103     return qr;
104   }
105
106   /**
107    * API method.
108    *
109    * @exception IllegalStateException Systematically.
110    */

111   public javax.jms.TopicSubscriber JavaDoc
112          createDurableSubscriber(javax.jms.Topic JavaDoc topic, String JavaDoc name,
113                                  String JavaDoc selector,
114                                  boolean noLocal) throws JMSException JavaDoc
115   {
116     throw new IllegalStateException JavaDoc("Forbidden call on a QueueSession.");
117   }
118
119   /**
120    * API method.
121    *
122    * @exception IllegalStateException Systematically.
123    */

124   public javax.jms.TopicSubscriber JavaDoc
125          createDurableSubscriber(javax.jms.Topic JavaDoc topic, String JavaDoc name)
126          throws JMSException JavaDoc
127   {
128     throw new IllegalStateException JavaDoc("Forbidden call on a QueueSession.");
129   }
130
131   /**
132    * API method.
133    *
134    * @exception IllegalStateException Systematically.
135    */

136   public javax.jms.Topic JavaDoc createTopic(String JavaDoc topicName) throws JMSException JavaDoc
137   {
138     throw new IllegalStateException JavaDoc("Forbidden call on a QueueSession.");
139   }
140
141   /**
142    * API method.
143    *
144    * @exception IllegalStateException Systematically.
145    */

146   public javax.jms.TemporaryTopic JavaDoc createTemporaryTopic() throws JMSException JavaDoc
147   {
148     throw new IllegalStateException JavaDoc("Forbidden call on a QueueSession.");
149   }
150
151   /**
152    * API method.
153    *
154    * @exception IllegalStateException Systematically.
155    */

156   public void unsubscribe(String JavaDoc name) throws JMSException JavaDoc
157   {
158     throw new IllegalStateException JavaDoc("Forbidden call on a QueueSession.");
159   }
160 }
161
Popular Tags