KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > joram > client > connector > OutboundTopicSession


1 /*
2  * JORAM: Java(TM) Open Reliable Asynchronous Messaging
3  * Copyright (C) 2004 - Bull SA
4  *
5  * This library is free software; you can redistribute it and/or
6  * modify it under the terms of the GNU Lesser General Public
7  * License as published by the Free Software Foundation; either
8  * version 2.1 of the License, or any later version.
9  *
10  * This library is distributed in the hope that it will be useful,
11  * but WITHOUT ANY WARRANTY; without even the implied warranty of
12  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  * Lesser General Public License for more details.
14  *
15  * You should have received a copy of the GNU Lesser General Public
16  * License along with this library; if not, write to the Free Software
17  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
18  * USA.
19  *
20  * Initial developer(s): Frederic Maistre (Bull SA)
21  * Contributor(s): Nicolas Tachker (Bull SA)
22  */

23 package org.objectweb.joram.client.connector;
24
25 import javax.jms.JMSException JavaDoc;
26 import javax.jms.MessageConsumer JavaDoc;
27 import javax.jms.Topic JavaDoc;
28 import javax.jms.TopicSubscriber JavaDoc;
29 import javax.jms.Session JavaDoc;
30
31 import org.objectweb.util.monolog.api.BasicLevel;
32
33 /**
34  * An <code>OutboundTopicSession</code> instance wraps a JMS TopicSession
35  * (XA or not) for a component involved in PubSub outbound messaging.
36  */

37 public class OutboundTopicSession extends OutboundSession
38                                   implements javax.jms.TopicSession JavaDoc
39 {
40   /**
41    * Constructs an <code>OutboundTopicSession</code> instance.
42    */

43   OutboundTopicSession(Session JavaDoc sess, OutboundConnection cnx) {
44     super(sess, cnx);
45
46     if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
47       AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
48                                     "OutboundTopicSession(" + sess +
49                                     ", " + cnx + ")");
50   }
51
52   /**
53    * Constructs an <code>OutboundTopicSession</code> instance.
54    */

55   OutboundTopicSession(Session JavaDoc sess,
56                        OutboundConnection cnx,
57                        boolean transacted) {
58     super(sess, cnx, transacted);
59
60     if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
61       AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
62                                     "OutboundTopicSession(" + sess +
63                                     ", " + cnx + ")");
64   }
65
66   /**
67    * Delegates the call to the wrapped JMS session.
68    */

69   public javax.jms.TopicPublisher JavaDoc createPublisher(Topic JavaDoc topic)
70     throws JMSException JavaDoc {
71     if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
72       AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
73                                     this + " createPublisher(" + topic + ")");
74
75     checkValidity();
76     return new OutboundPublisher(sess.createProducer(topic), this);
77   }
78
79   /**
80    * Delegates the call to the wrapped JMS session.
81    */

82   public TopicSubscriber JavaDoc createSubscriber(Topic JavaDoc topic,
83                                           String JavaDoc selector,
84                                           boolean noLocal)
85     throws JMSException JavaDoc {
86     if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
87       AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
88                                     this + " createSubscriber(" + topic +
89                                     ", " + selector +
90                                     ", " + noLocal + ")");
91
92     checkValidity();
93     MessageConsumer JavaDoc cons = sess.createConsumer(topic, selector, noLocal);
94     return new OutboundSubscriber(topic, noLocal, cons, this);
95   }
96
97   /**
98    * Delegates the call to the wrapped JMS session.
99    */

100   public TopicSubscriber JavaDoc createSubscriber(Topic JavaDoc topic, String JavaDoc selector)
101     throws JMSException JavaDoc {
102     if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
103       AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
104                                     this + " createSubscriber(" + topic +
105                                     ", " + selector + ")");
106
107     checkValidity();
108     MessageConsumer JavaDoc cons = sess.createConsumer(topic, selector);
109     return new OutboundSubscriber(topic, false, cons, this);
110   }
111
112   /**
113    * Delegates the call to the wrapped JMS session.
114    */

115   public TopicSubscriber JavaDoc createSubscriber(Topic JavaDoc topic)
116     throws JMSException JavaDoc {
117     if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
118       AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
119                                     this + " createSubscriber(" + topic + ")");
120
121     checkValidity();
122     return new OutboundSubscriber(topic,
123                                   false,
124                                   sess.createConsumer(topic),
125                                   this);
126   }
127
128   /**
129    * API method.
130    *
131    * @exception javax.jms.IllegalStateException Systematically.
132    */

133   public javax.jms.QueueBrowser JavaDoc
134       createBrowser(javax.jms.Queue JavaDoc queue,
135                     String JavaDoc selector)
136     throws JMSException JavaDoc {
137     throw new javax.jms.IllegalStateException JavaDoc("Forbidden call on a TopicSession.");
138   }
139   
140   /**
141    * API method.
142    *
143    * @exception javax.jms.IllegalStateException Systematically.
144    */

145   public javax.jms.QueueBrowser JavaDoc createBrowser(javax.jms.Queue JavaDoc queue)
146     throws JMSException JavaDoc {
147     throw new javax.jms.IllegalStateException JavaDoc("Forbidden call on a TopicSession.");
148   }
149   
150   /**
151    * API method.
152    *
153    * @exception javax.jms.IllegalStateException Systematically.
154    */

155   public javax.jms.Queue JavaDoc createQueue(String JavaDoc queueName)
156     throws JMSException JavaDoc {
157     throw new javax.jms.IllegalStateException JavaDoc("Forbidden call on a TopicSession.");
158   }
159   
160   /**
161    * API method.
162    *
163    * @exception javax.jms.IllegalStateException Systematically.
164    */

165   public javax.jms.TemporaryQueue JavaDoc createTemporaryQueue()
166     throws JMSException JavaDoc {
167     throw new javax.jms.IllegalStateException JavaDoc("Forbidden call on a TopicSession.");
168   }
169 }
170
Popular Tags