Docjar: A Java Source and Docuemnt Enginecom.*    java.*    javax.*    org.*    all    new    plug-in

Quick Search    Search Deep

Source code: org/activemq/ActiveMQQueueSession.java


1   /**
2    * 
3    * Copyright 2004 Hiram Chirino
4    * 
5    * Licensed under the Apache License, Version 2.0 (the "License"); 
6    * you may not use this file except in compliance with the License. 
7    * You may obtain a copy of the License at 
8    * 
9    * http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, 
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
14   * See the License for the specific language governing permissions and 
15   * limitations under the License. 
16   * 
17   **/
18  package org.activemq;
19  
20  import java.io.Serializable;
21  
22  import javax.jms.BytesMessage;
23  import javax.jms.Destination;
24  import javax.jms.IllegalStateException;
25  import javax.jms.InvalidDestinationException;
26  import javax.jms.JMSException;
27  import javax.jms.MapMessage;
28  import javax.jms.Message;
29  import javax.jms.MessageConsumer;
30  import javax.jms.MessageListener;
31  import javax.jms.MessageProducer;
32  import javax.jms.ObjectMessage;
33  import javax.jms.Queue;
34  import javax.jms.QueueBrowser;
35  import javax.jms.QueueReceiver;
36  import javax.jms.QueueSender;
37  import javax.jms.QueueSession;
38  import javax.jms.StreamMessage;
39  import javax.jms.TemporaryQueue;
40  import javax.jms.TemporaryTopic;
41  import javax.jms.TextMessage;
42  import javax.jms.Topic;
43  import javax.jms.TopicSubscriber;
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.1.1.1 $
55   */
56  public class ActiveMQQueueSession implements QueueSession {
57  
58    private final QueueSession next;
59    
60    public ActiveMQQueueSession(QueueSession next) {
61      this.next = next;
62    }
63    
64    /**
65     * @throws JMSException
66     */
67    public void close() throws JMSException {
68      next.close();
69    }
70    /**
71     * @throws JMSException
72     */
73    public void commit() throws JMSException {
74      next.commit();
75    }
76    /**
77     * @param queue
78     * @return
79     * @throws JMSException
80     */
81    public QueueBrowser createBrowser(Queue queue) throws JMSException {
82      return next.createBrowser(queue);
83    }
84    /**
85     * @param queue
86     * @param messageSelector
87     * @return
88     * @throws JMSException
89     */
90    public QueueBrowser createBrowser(Queue queue, String messageSelector)
91        throws JMSException {
92      return next.createBrowser(queue, messageSelector);
93    }
94    /**
95     * @return
96     * @throws JMSException
97     */
98    public BytesMessage createBytesMessage() throws JMSException {
99      return next.createBytesMessage();
100   }
101   /**
102    * @param destination
103    * @return
104    * @throws JMSException
105    */
106   public MessageConsumer createConsumer(Destination destination)
107       throws JMSException {
108     if( destination instanceof Topic )
109       throw new InvalidDestinationException("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 createConsumer(Destination destination,
119       String messageSelector) throws JMSException {
120     if( destination instanceof Topic )
121       throw new InvalidDestinationException("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 createConsumer(Destination destination,
132       String messageSelector, boolean NoLocal) throws JMSException {
133     if( destination instanceof Topic )
134       throw new InvalidDestinationException("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 createDurableSubscriber(Topic topic, String name)
144       throws JMSException {
145     throw new IllegalStateException("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 createDurableSubscriber(Topic topic, String name,
156       String messageSelector, boolean noLocal) throws JMSException {
157     throw new IllegalStateException("Operation not supported by a QueueSession");
158   }
159   /**
160    * @return
161    * @throws JMSException
162    */
163   public MapMessage createMapMessage() throws JMSException {
164     return next.createMapMessage();
165   }
166   /**
167    * @return
168    * @throws JMSException
169    */
170   public Message createMessage() throws JMSException {
171     return next.createMessage();
172   }
173   /**
174    * @return
175    * @throws JMSException
176    */
177   public ObjectMessage createObjectMessage() throws JMSException {
178     return next.createObjectMessage();
179   }
180   /**
181    * @param object
182    * @return
183    * @throws JMSException
184    */
185   public ObjectMessage createObjectMessage(Serializable object)
186       throws JMSException {
187     return next.createObjectMessage(object);
188   }
189   /**
190    * @param destination
191    * @return
192    * @throws JMSException
193    */
194   public MessageProducer createProducer(Destination destination)
195       throws JMSException {
196     if( destination instanceof Topic )
197       throw new InvalidDestinationException("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 createQueue(String queueName) throws JMSException {
206     return next.createQueue(queueName);
207   }
208   /**
209    * @param queue
210    * @return
211    * @throws JMSException
212    */
213   public QueueReceiver createReceiver(Queue queue) throws JMSException {
214     return next.createReceiver(queue);
215   }
216   /**
217    * @param queue
218    * @param messageSelector
219    * @return
220    * @throws JMSException
221    */
222   public QueueReceiver createReceiver(Queue queue, String messageSelector)
223       throws JMSException {
224     return next.createReceiver(queue, messageSelector);
225   }
226   /**
227    * @param queue
228    * @return
229    * @throws JMSException
230    */
231   public QueueSender createSender(Queue queue) throws JMSException {
232     return next.createSender(queue);
233   }
234   /**
235    * @return
236    * @throws JMSException
237    */
238   public StreamMessage createStreamMessage() throws JMSException {
239     return next.createStreamMessage();
240   }
241   /**
242    * @return
243    * @throws JMSException
244    */
245   public TemporaryQueue createTemporaryQueue() throws JMSException {
246     return next.createTemporaryQueue();
247   }
248   /**
249    * @return
250    * @throws JMSException
251    */
252   public TemporaryTopic createTemporaryTopic() throws JMSException {
253     throw new IllegalStateException("Operation not supported by a QueueSession");
254   }
255   /**
256    * @return
257    * @throws JMSException
258    */
259   public TextMessage createTextMessage() throws JMSException {
260     return next.createTextMessage();
261   }
262   /**
263    * @param text
264    * @return
265    * @throws JMSException
266    */
267   public TextMessage createTextMessage(String text) throws JMSException {
268     return next.createTextMessage(text);
269   }
270   /**
271    * @param topicName
272    * @return
273    * @throws JMSException
274    */
275   public Topic createTopic(String topicName) throws JMSException {
276     throw new IllegalStateException("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 arg0) {
282     return next.equals(arg0);
283   }
284   /**
285    * @return
286    * @throws JMSException
287    */
288   public int getAcknowledgeMode() throws JMSException {
289     return next.getAcknowledgeMode();
290   }
291   /**
292    * @return
293    * @throws JMSException
294    */
295   public MessageListener getMessageListener() throws JMSException {
296     return next.getMessageListener();
297   }
298   /**
299    * @return
300    * @throws JMSException
301    */
302   public boolean getTransacted() throws JMSException {
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 {
315     next.recover();
316   }
317   /**
318    * @throws JMSException
319    */
320   public void rollback() throws JMSException {
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 listener)
334       throws JMSException {
335     next.setMessageListener(listener);
336   }
337   /* (non-Javadoc)
338    * @see java.lang.Object#toString()
339    */
340   public String toString() {
341     return next.toString();
342   }
343   /**
344    * @param name
345    * @throws JMSException
346    */
347   public void unsubscribe(String name) throws JMSException {
348     throw new IllegalStateException("Operation not supported by a QueueSession");
349   }
350 
351     public QueueSession getNext() {
352         return next;
353     }
354 
355 }