KickJava   Java API By Example, From Geeks To Geeks.

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


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>OutboundQueueConnection</code> instance is a handler for a
32  * physical PTP 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 OutboundQueueConnection
37              extends OutboundConnection
38              implements javax.jms.QueueConnection JavaDoc
39 {
40   /**
41    * Constructs an <code>OutboundQueueConnection</code> instance.
42    *
43    * @param managedCx The managed connection building the handle.
44    * @param xac The underlying physical PTP connection to handle.
45    */

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

64   public QueueSession
65          createQueueSession(boolean transacted, int acknowledgeMode)
66     throws JMSException {
67     if (AdapterTracing.dbgAdapter.isLoggable(BasicLevel.DEBUG))
68       AdapterTracing.dbgAdapter.log(BasicLevel.DEBUG,
69                                     this + " createQueueSession(" + 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 + " createQueueSession sess = " + managedCx.session);
78     Session sess = managedCx.session;
79     if (sess == null)
80       sess = xac.createSession(false, acknowledgeMode);
81
82     return new OutboundQueueSession(sess, this, transacted);
83   }
84
85   /**
86    * Forbidden call on an application or component's outbound connection,
87    * throws a <code>IllegalStateException</code> instance.
88    */

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