KickJava   Java API By Example, From Geeks To Geeks.

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


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.*;
26 import javax.jms.IllegalStateException JavaDoc;
27
28 import org.objectweb.util.monolog.api.BasicLevel;
29
30 /**
31  * An <code>OutboundTopicConnection</code> instance is a handler for a
32  * physical PubSub connection to an underlying JORAM server, allowing a
33  * component to transparently use this physical connection possibly within
34  * a transaction (local or global).
35  */

36 public class OutboundTopicConnection
37              extends OutboundConnection
38              implements javax.jms.TopicConnection JavaDoc
39 {
40   /**
41    * Constructs an <code>OutboundTopicConnection</code> instance.
42    *
43    * @param managedCx The managed connection building the handle.
44    * @param xac The underlying physical PubSub connection to handle.
45    */

46   OutboundTopicConnection(ManagedConnectionImpl managedCx,
47                           XATopicConnection xac) {
48     super(managedCx, xac);
49
50     if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
51       AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
52                                     "OutboundTopicConnection(" + managedCx +
53                                     ", " + xac + ")");
54   }
55
56  
57   /**
58    * Returns the unique authorized JMS session per connection wrapped in
59    * an <code>OutboundTopicSession</code> instance.
60    *
61    * @exception javax.jms.IllegalStateException If the handle is invalid.
62    * @exception javax.jms.JMSException Generic exception.
63    */

64   public TopicSession
65       createTopicSession(boolean transacted, int acknowledgeMode)
66     throws JMSException {
67     if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
68       AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
69                                     this + " createTopicSession(" + transacted +
70                                     ", " + acknowledgeMode + ")");
71     
72     if (! valid)
73       throw new javax.jms.IllegalStateException JavaDoc("Invalid connection handle.");
74
75     if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
76       AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
77                                     this + " createTopicSession sess = " + managedCx.session);
78
79     Session sess = managedCx.session;
80     if (sess == null)
81       sess = xac.createSession(false, acknowledgeMode);
82
83     return new OutboundTopicSession(sess, this, transacted);
84   }
85
86   /**
87    * Forbidden call on an application or component's outbound connection,
88    * throws a <code>IllegalStateException</code> instance.
89    */

90   public ConnectionConsumer
91       createConnectionConsumer(Topic topic,
92                                String JavaDoc messageSelector,
93                                ServerSessionPool sessionPool,
94                                int maxMessages)
95     throws JMSException {
96     throw new IllegalStateException JavaDoc("Forbidden call on a component's "
97                                     + "connection.");
98   }
99 }
100
Popular Tags