KickJava   Java API By Example, From Geeks To Geeks.

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


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.StreamMessage JavaDoc;
36 import javax.jms.TemporaryQueue JavaDoc;
37 import javax.jms.TemporaryTopic JavaDoc;
38 import javax.jms.TextMessage JavaDoc;
39 import javax.jms.Topic JavaDoc;
40 import javax.jms.TopicPublisher JavaDoc;
41 import javax.jms.TopicSession JavaDoc;
42 import javax.jms.TopicSubscriber JavaDoc;
43
44 /**
45  * A TopicSession implementation that throws IllegalStateExceptions
46  * when Queue operations are attempted but which delegates
47  * to another TopicSession for all other operations.
48  *
49  * The ActiveMQSessions implement both Topic and Queue Sessions
50  * methods but the spec states that TopicSession should throw Exceptions
51  * if queue operations are attempted on it.
52  *
53  * @version $Revision: 1.2 $
54  */

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

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

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

80     public QueueBrowser JavaDoc createBrowser(Queue JavaDoc queue) throws JMSException JavaDoc {
81         throw new IllegalStateException JavaDoc("Operation not supported by a TopicSession");
82     }
83     /**
84      * @param queue
85      * @param messageSelector
86      * @return
87      * @throws JMSException
88      */

89     public QueueBrowser JavaDoc createBrowser(Queue JavaDoc queue, String JavaDoc messageSelector)
90             throws JMSException JavaDoc {
91         throw new IllegalStateException JavaDoc("Operation not supported by a TopicSession");
92     }
93     /**
94      * @return
95      * @throws JMSException
96      */

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

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

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

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

142     public TopicSubscriber JavaDoc createDurableSubscriber(Topic JavaDoc topic, String JavaDoc name)
143             throws JMSException JavaDoc {
144         return next.createDurableSubscriber(topic, name);
145     }
146     /**
147      * @param topic
148      * @param name
149      * @param messageSelector
150      * @param noLocal
151      * @return
152      * @throws JMSException
153      */

154     public TopicSubscriber JavaDoc createDurableSubscriber(Topic JavaDoc topic, String JavaDoc name,
155             String JavaDoc messageSelector, boolean noLocal) throws JMSException JavaDoc {
156         return next.createDurableSubscriber(topic, name, messageSelector,
157                 noLocal);
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 Queue JavaDoc )
197             throw new InvalidDestinationException JavaDoc("Queues are not supported by a TopicSession");
198         return next.createProducer(destination);
199     }
200     /**
201      * @param topic
202      * @return
203      * @throws JMSException
204      */

205     public TopicPublisher JavaDoc createPublisher(Topic JavaDoc topic) throws JMSException JavaDoc {
206         return next.createPublisher(topic);
207     }
208     /**
209      * @param queueName
210      * @return
211      * @throws JMSException
212      */

213     public Queue JavaDoc createQueue(String JavaDoc queueName) throws JMSException JavaDoc {
214         throw new IllegalStateException JavaDoc("Operation not supported by a TopicSession");
215     }
216     /**
217      * @return
218      * @throws JMSException
219      */

220     public StreamMessage JavaDoc createStreamMessage() throws JMSException JavaDoc {
221         return next.createStreamMessage();
222     }
223     /**
224      * @param topic
225      * @return
226      * @throws JMSException
227      */

228     public TopicSubscriber JavaDoc createSubscriber(Topic JavaDoc topic) throws JMSException JavaDoc {
229         return next.createSubscriber(topic);
230     }
231     /**
232      * @param topic
233      * @param messageSelector
234      * @param noLocal
235      * @return
236      * @throws JMSException
237      */

238     public TopicSubscriber JavaDoc createSubscriber(Topic JavaDoc topic,
239             String JavaDoc messageSelector, boolean noLocal) throws JMSException JavaDoc {
240         return next.createSubscriber(topic, messageSelector, noLocal);
241     }
242     /**
243      * @return
244      * @throws JMSException
245      */

246     public TemporaryQueue JavaDoc createTemporaryQueue() throws JMSException JavaDoc {
247         throw new IllegalStateException JavaDoc("Operation not supported by a TopicSession");
248     }
249     /**
250      * @return
251      * @throws JMSException
252      */

253     public TemporaryTopic JavaDoc createTemporaryTopic() throws JMSException JavaDoc {
254         return next.createTemporaryTopic();
255     }
256     /**
257      * @return
258      * @throws JMSException
259      */

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

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

276     public Topic JavaDoc createTopic(String JavaDoc topicName) throws JMSException JavaDoc {
277         return next.createTopic(topicName);
278     }
279     /* (non-Javadoc)
280      * @see java.lang.Object#equals(java.lang.Object)
281      */

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

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

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

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

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

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

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

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

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

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

348     public void unsubscribe(String JavaDoc name) throws JMSException JavaDoc {
349         next.unsubscribe(name);
350     }
351
352     public TopicSession JavaDoc getNext() {
353         return next;
354     }
355 }
356
Popular Tags