KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > com > scalagent > kjoram > 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): 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 QueueSession extends Session
31 {
32   /**
33    * Constructs a queue session.
34    *
35    * @param cnx The connection the session belongs to.
36    * @param transacted <code>true</code> for a transacted session.
37    * @param acknowledgeMode 1 (auto), 2 (client) or 3 (dups ok).
38    *
39    * @exception JMSException In case of an invalid acknowledge mode.
40    */

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

61   public QueueSender createSender(Queue queue)
62        throws JMSException
63   {
64     if (closed)
65       throw new IllegalStateException JavaDoc("Forbidden call on a closed session.");
66
67     return new QueueSender(this, (Queue) queue);
68   }
69
70   /**
71    * API method.
72    *
73    * @exception IllegalStateException If the session is closed or if the
74    * connection is broken.
75    * @exception JMSException If the creation fails for any other reason.
76    */

77   public QueueReceiver
78          createReceiver(Queue queue, String JavaDoc selector)
79          throws JMSException
80   {
81     if (closed)
82       throw new IllegalStateException JavaDoc("Forbidden call on a closed session.");
83
84     return new QueueReceiver(this, (Queue) queue, selector);
85   }
86
87   /**
88    * API method.
89    *
90    * @exception IllegalStateException If the session is closed or if the
91    * connection is broken.
92    * @exception JMSException If the creation fails for any other reason.
93    */

94   public QueueReceiver createReceiver(Queue queue)
95          throws JMSException
96   {
97     if (closed)
98       throw new IllegalStateException JavaDoc("Forbidden call on a closed session.");
99
100     return new QueueReceiver(this, (Queue) queue, null);
101   }
102
103   /**
104    * API method.
105    *
106    * @exception IllegalStateException Systematically.
107    */

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

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

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

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

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