KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > apache > activemq > ActiveMQQueueSession


1 /**
2  *
3  * Licensed to the Apache Software Foundation (ASF) under one or more
4  * contributor license agreements. See the NOTICE file distributed with
5  * this work for additional information regarding copyright ownership.
6  * The ASF licenses this file to You under the Apache License, Version 2.0
7  * (the "License"); you may not use this file except in compliance with
8  * the License. You may obtain a copy of the License at
9  *
10  * http://www.apache.org/licenses/LICENSE-2.0
11  *
12  * Unless required by applicable law or agreed to in writing, software
13  * distributed under the License is distributed on an "AS IS" BASIS,
14  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15  * See the License for the specific language governing permissions and
16  * limitations under the License.
17  */

18 package org.apache.activemq;
19
20 import java.io.Serializable JavaDoc;
21
22 import javax.jms.BytesMessage JavaDoc;
23 import javax.jms.Destination JavaDoc;
24 import javax.jms.IllegalStateException JavaDoc;
25 import javax.jms.InvalidDestinationException JavaDoc;
26 import javax.jms.JMSException JavaDoc;
27 import javax.jms.MapMessage JavaDoc;
28 import javax.jms.Message JavaDoc;
29 import javax.jms.MessageConsumer JavaDoc;
30 import javax.jms.MessageListener JavaDoc;
31 import javax.jms.MessageProducer JavaDoc;
32 import javax.jms.ObjectMessage JavaDoc;
33 import javax.jms.Queue JavaDoc;
34 import javax.jms.QueueBrowser JavaDoc;
35 import javax.jms.QueueReceiver JavaDoc;
36 import javax.jms.QueueSender JavaDoc;
37 import javax.jms.QueueSession JavaDoc;
38 import javax.jms.StreamMessage JavaDoc;
39 import javax.jms.TemporaryQueue JavaDoc;
40 import javax.jms.TemporaryTopic JavaDoc;
41 import javax.jms.TextMessage JavaDoc;
42 import javax.jms.Topic JavaDoc;
43 import javax.jms.TopicSubscriber JavaDoc;
44
45 /**
46  * A QueueSession implementation that throws IllegalStateExceptions
47  * when Topic operations are attempted but which delegates
48  * to another QueueSession for all other operations.
49  *
50  * The ActiveMQSessions implement both Topic and Queue Sessions
51  * methods but the spec states that Queue session should throw Exceptions
52  * if topic operations are attempted on it.
53  *
54  * @version $Revision: 1.2 $
55  */

56 public class ActiveMQQueueSession implements QueueSession JavaDoc {
57
58     private final QueueSession JavaDoc next;
59     
60     public ActiveMQQueueSession(QueueSession JavaDoc next) {
61         this.next = next;
62     }
63     
64     /**
65      * @throws JMSException
66      */

67     public void close() throws JMSException JavaDoc {
68         next.close();
69     }
70     /**
71      * @throws JMSException
72      */

73     public void commit() throws JMSException JavaDoc {
74         next.commit();
75     }
76     /**
77      * @param queue
78      * @return
79      * @throws JMSException
80      */

81     public QueueBrowser JavaDoc createBrowser(Queue JavaDoc queue) throws JMSException JavaDoc {
82         return next.createBrowser(queue);
83     }
84     /**
85      * @param queue
86      * @param messageSelector
87      * @return
88      * @throws JMSException
89      */

90     public QueueBrowser JavaDoc createBrowser(Queue JavaDoc queue, String JavaDoc messageSelector)
91             throws JMSException JavaDoc {
92         return next.createBrowser(queue, messageSelector);
93     }
94     /**
95      * @return
96      * @throws JMSException
97      */

98     public BytesMessage JavaDoc createBytesMessage() throws JMSException JavaDoc {
99         return next.createBytesMessage();
100     }
101     /**
102      * @param destination
103      * @return
104      * @throws JMSException
105      */

106     public MessageConsumer JavaDoc createConsumer(Destination JavaDoc destination)
107             throws JMSException JavaDoc {
108         if( destination instanceof Topic JavaDoc )
109             throw new InvalidDestinationException JavaDoc("Topics are not supported by a QueueSession");
110         return next.createConsumer(destination);
111     }
112     /**
113      * @param destination
114      * @param messageSelector
115      * @return
116      * @throws JMSException
117      */

118     public MessageConsumer JavaDoc createConsumer(Destination JavaDoc destination,
119             String JavaDoc messageSelector) throws JMSException JavaDoc {
120         if( destination instanceof Topic JavaDoc )
121             throw new InvalidDestinationException JavaDoc("Topics are not supported by a QueueSession");
122         return next.createConsumer(destination, messageSelector);
123     }
124     /**
125      * @param destination
126      * @param messageSelector
127      * @param NoLocal
128      * @return
129      * @throws JMSException
130      */

131     public MessageConsumer JavaDoc createConsumer(Destination JavaDoc destination,
132             String JavaDoc messageSelector, boolean NoLocal) throws JMSException JavaDoc {
133         if( destination instanceof Topic JavaDoc )
134             throw new InvalidDestinationException JavaDoc("Topics are not supported by a QueueSession");
135         return next.createConsumer(destination, messageSelector, NoLocal);
136     }
137     /**
138      * @param topic
139      * @param name
140      * @return
141      * @throws JMSException
142      */

143     public TopicSubscriber JavaDoc createDurableSubscriber(Topic JavaDoc topic, String JavaDoc name)
144             throws JMSException JavaDoc {
145         throw new IllegalStateException JavaDoc("Operation not supported by a QueueSession");
146     }
147     /**
148      * @param topic
149      * @param name
150      * @param messageSelector
151      * @param noLocal
152      * @return
153      * @throws JMSException
154      */

155     public TopicSubscriber JavaDoc createDurableSubscriber(Topic JavaDoc topic, String JavaDoc name,
156             String JavaDoc messageSelector, boolean noLocal) throws JMSException JavaDoc {
157         throw new IllegalStateException JavaDoc("Operation not supported by a QueueSession");
158     }
159     /**
160      * @return
161      * @throws JMSException
162      */

163     public MapMessage JavaDoc createMapMessage() throws JMSException JavaDoc {
164         return next.createMapMessage();
165     }
166     /**
167      * @return
168      * @throws JMSException
169      */

170     public Message createMessage() throws JMSException JavaDoc {
171         return next.createMessage();
172     }
173     /**
174      * @return
175      * @throws JMSException
176      */

177     public ObjectMessage JavaDoc createObjectMessage() throws JMSException JavaDoc {
178         return next.createObjectMessage();
179     }
180     /**
181      * @param object
182      * @return
183      * @throws JMSException
184      */

185     public ObjectMessage JavaDoc createObjectMessage(Serializable JavaDoc object)
186             throws JMSException JavaDoc {
187         return next.createObjectMessage(object);
188     }
189     /**
190      * @param destination
191      * @return
192      * @throws JMSException
193      */

194     public MessageProducer JavaDoc createProducer(Destination JavaDoc destination)
195             throws JMSException JavaDoc {
196         if( destination instanceof Topic JavaDoc )
197             throw new InvalidDestinationException JavaDoc("Topics are not supported by a QueueSession");
198         return next.createProducer(destination);
199     }
200     /**
201      * @param queueName
202      * @return
203      * @throws JMSException
204      */

205     public Queue JavaDoc createQueue(String JavaDoc queueName) throws JMSException JavaDoc {
206         return next.createQueue(queueName);
207     }
208     /**
209      * @param queue
210      * @return
211      * @throws JMSException
212      */

213     public QueueReceiver JavaDoc createReceiver(Queue JavaDoc queue) throws JMSException JavaDoc {
214         return next.createReceiver(queue);
215     }
216     /**
217      * @param queue
218      * @param messageSelector
219      * @return
220      * @throws JMSException
221      */

222     public QueueReceiver JavaDoc createReceiver(Queue JavaDoc queue, String JavaDoc messageSelector)
223             throws JMSException JavaDoc {
224         return next.createReceiver(queue, messageSelector);
225     }
226     /**
227      * @param queue
228      * @return
229      * @throws JMSException
230      */

231     public QueueSender JavaDoc createSender(Queue JavaDoc queue) throws JMSException JavaDoc {
232         return next.createSender(queue);
233     }
234     /**
235      * @return
236      * @throws JMSException
237      */

238     public StreamMessage JavaDoc createStreamMessage() throws JMSException JavaDoc {
239         return next.createStreamMessage();
240     }
241     /**
242      * @return
243      * @throws JMSException
244      */

245     public TemporaryQueue JavaDoc createTemporaryQueue() throws JMSException JavaDoc {
246         return next.createTemporaryQueue();
247     }
248     /**
249      * @return
250      * @throws JMSException
251      */

252     public TemporaryTopic JavaDoc createTemporaryTopic() throws JMSException JavaDoc {
253         throw new IllegalStateException JavaDoc("Operation not supported by a QueueSession");
254     }
255     /**
256      * @return
257      * @throws JMSException
258      */

259     public TextMessage JavaDoc createTextMessage() throws JMSException JavaDoc {
260         return next.createTextMessage();
261     }
262     /**
263      * @param text
264      * @return
265      * @throws JMSException
266      */

267     public TextMessage JavaDoc createTextMessage(String JavaDoc text) throws JMSException JavaDoc {
268         return next.createTextMessage(text);
269     }
270     /**
271      * @param topicName
272      * @return
273      * @throws JMSException
274      */

275     public Topic JavaDoc createTopic(String JavaDoc topicName) throws JMSException JavaDoc {
276         throw new IllegalStateException JavaDoc("Operation not supported by a QueueSession");
277     }
278     /* (non-Javadoc)
279      * @see java.lang.Object#equals(java.lang.Object)
280      */

281     public boolean equals(Object JavaDoc arg0) {
282         return next.equals(arg0);
283     }
284     /**
285      * @return
286      * @throws JMSException
287      */

288     public int getAcknowledgeMode() throws JMSException JavaDoc {
289         return next.getAcknowledgeMode();
290     }
291     /**
292      * @return
293      * @throws JMSException
294      */

295     public MessageListener JavaDoc getMessageListener() throws JMSException JavaDoc {
296         return next.getMessageListener();
297     }
298     /**
299      * @return
300      * @throws JMSException
301      */

302     public boolean getTransacted() throws JMSException JavaDoc {
303         return next.getTransacted();
304     }
305     /* (non-Javadoc)
306      * @see java.lang.Object#hashCode()
307      */

308     public int hashCode() {
309         return next.hashCode();
310     }
311     /**
312      * @throws JMSException
313      */

314     public void recover() throws JMSException JavaDoc {
315         next.recover();
316     }
317     /**
318      * @throws JMSException
319      */

320     public void rollback() throws JMSException JavaDoc {
321         next.rollback();
322     }
323     /**
324      *
325      */

326     public void run() {
327         next.run();
328     }
329     /**
330      * @param listener
331      * @throws JMSException
332      */

333     public void setMessageListener(MessageListener JavaDoc listener)
334             throws JMSException JavaDoc {
335         next.setMessageListener(listener);
336     }
337     /* (non-Javadoc)
338      * @see java.lang.Object#toString()
339      */

340     public String JavaDoc toString() {
341         return next.toString();
342     }
343     /**
344      * @param name
345      * @throws JMSException
346      */

347     public void unsubscribe(String JavaDoc name) throws JMSException JavaDoc {
348         throw new IllegalStateException JavaDoc("Operation not supported by a QueueSession");
349     }
350
351     public QueueSession JavaDoc getNext() {
352         return next;
353     }
354
355 }
356
Popular Tags