KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > objectweb > jonas_jms > JTopicConnection


1 /*
2  * JOnAS: Java(TM) Open Application Server
3  * Copyright (C) 1999 Bull S.A.
4  * Contact: jonas-team@objectweb.org
5  *
6  * This library is free software; you can redistribute it and/or
7  * modify it under the terms of the GNU Lesser General Public
8  * License as published by the Free Software Foundation; either
9  * version 2.1 of the License, or any later version.
10  *
11  * This library is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14  * Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public
17  * License along with this library; if not, write to the Free Software
18  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
19  * USA
20  * --------------------------------------------------------------------------
21  * $Id: JTopicConnection.java,v 1.7 2004/03/19 14:31:48 sauthieg Exp $
22  * --------------------------------------------------------------------------
23  */

24
25 package org.objectweb.jonas_jms;
26
27 import javax.jms.ConnectionConsumer JavaDoc;
28 import javax.jms.JMSException JavaDoc;
29 import javax.jms.ServerSessionPool JavaDoc;
30 import javax.jms.Topic JavaDoc;
31 import javax.jms.TopicConnection JavaDoc;
32 import javax.jms.TopicSession JavaDoc;
33 import javax.jms.XAConnection JavaDoc;
34 import javax.jms.XATopicConnection JavaDoc;
35 import javax.jms.XATopicConnectionFactory JavaDoc;
36
37 import org.objectweb.util.monolog.api.BasicLevel;
38
39 /*
40  *
41  * @author Laurent Chauvirey, Frederic Maistre, Nicolas Tachker
42  * Contributor(s):
43  * Philippe Durieux
44  * Jeff Mesnil connection anonymous
45  *
46  */

47
48 public class JTopicConnection extends JConnection implements TopicConnection JavaDoc {
49
50     // The XATopicConnection used in the MOM
51
protected XATopicConnection JavaDoc xatc = null;
52
53
54     /**
55      * Constructor of a JTopicConnection for a specified user.
56      *
57      * @param user user's name
58      * @param passwd user's password
59      */

60     public JTopicConnection(JConnectionFactory jcf, XATopicConnectionFactory JavaDoc xatcf, String JavaDoc user, String JavaDoc passwd) throws JMSException JavaDoc {
61     super(jcf, user);
62     // Create the underlaying XATopicConnection
63
xatc = xatcf.createXATopicConnection(user, passwd);
64     this.xac = (XAConnection JavaDoc) xatc;
65     }
66
67     /**
68      * Constructor of a JQueueConnection for an anonymous user.
69      */

70     public JTopicConnection(JConnectionFactory jcf, XATopicConnectionFactory JavaDoc xatcf) throws JMSException JavaDoc {
71         super(jcf, INTERNAL_USER_NAME);
72         // Create the underlying XATopicConnection
73
xatc = xatcf.createXATopicConnection();
74         this.xac = (XAConnection JavaDoc) xatc;
75     }
76
77     // -----------------------------------------------------------------------
78
// TopicConnection implementation
79
// -----------------------------------------------------------------------
80

81     /**
82      * Create a TopicSession
83      * @param transacted - if true, the session is transacted.
84      * @param acknowledgeMode - indicates whether the consumer or the client will
85      * acknowledge any messages it receives.
86      * This parameter will be ignored if the session is transacted.
87      * @return a newly created topic session.
88      * @throws JMSException - if JMS Connection fails to create a session.
89      */

90     public TopicSession JavaDoc createTopicSession(boolean transacted, int acknowledgeMode) throws JMSException JavaDoc {
91     TraceJms.logger.log(BasicLevel.DEBUG, "");
92     return new JTopicSession(this, xatc);
93     }
94
95     /**
96      * @throws JMSException - if JMS Connection fails to create a ConnectionConsumer
97      */

98     public ConnectionConsumer JavaDoc createConnectionConsumer(Topic JavaDoc topic,
99                                String JavaDoc messageSelector,
100                                ServerSessionPool JavaDoc sessionPool,
101                                int maxMessages) throws JMSException JavaDoc {
102     TraceJms.logger.log(BasicLevel.DEBUG, "");
103     return xatc.createConnectionConsumer(topic, messageSelector, sessionPool, maxMessages);
104     }
105 }
106
Popular Tags