KickJava   Java API By Example, From Geeks To Geeks.

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


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  * --------------------------------------------------------------------------
22  * $Id: JQueueConnectionFactory.java,v 1.9 2004/03/19 14:31:48 sauthieg Exp $
23  * --------------------------------------------------------------------------
24  */

25
26 package org.objectweb.jonas_jms;
27
28 import javax.jms.JMSException JavaDoc;
29 import javax.jms.QueueConnection JavaDoc;
30 import javax.jms.QueueConnectionFactory JavaDoc;
31 import javax.jms.XAQueueConnectionFactory JavaDoc;
32
33 import org.objectweb.util.monolog.api.BasicLevel;
34
35 /**
36  * JQueueConnectionFactory wraps a XAQueueConnectionFactory.
37  *
38  * @author Laurent Chauvirey, Frederic Maistre, Nicolas Tachker
39  * Contributor(s):
40  * Philippe Durieux
41  * Jeff Mesnil
42  * Philippe Coq
43  */

44 public class JQueueConnectionFactory extends JConnectionFactory implements QueueConnectionFactory JavaDoc {
45     
46     private XAQueueConnectionFactory JavaDoc xaqcf;
47
48     /**
49      * Constructor.
50      * The underlaying XAQueueConnectionFactory is found in the JmsManager.
51      */

52     public JQueueConnectionFactory(String JavaDoc name) {
53         this.name = name;
54         jms = JmsManagerImpl.getJmsManager();
55         xacf = jms.getXAQueueConnectionFactory();
56         xaqcf = (XAQueueConnectionFactory JavaDoc) xacf;
57     }
58
59     // -----------------------------------------------------------------------
60
// QueueConnectionFactory implementation
61
// -----------------------------------------------------------------------
62

63     /**
64      * Create a queue connection for an anonymous user.
65      *
66      * @return a newly created queue connection.
67      * @throws JMSException - if JMS Provider fails to create Queue Connection
68      * due to some internal error. required resources for a Queue Connection.
69      * @throws JMSSecurityException - if client authentication fails due to
70      * invalid user name or password.
71      */

72     public QueueConnection JavaDoc createQueueConnection() throws JMSException JavaDoc {
73     TraceJms.logger.log(BasicLevel.DEBUG,"");
74     JQueueConnection qc = (JQueueConnection) getJConnection();
75         if (qc == null) {
76             qc = new JQueueConnection(this, xaqcf);
77         }
78         return (QueueConnection JavaDoc) qc;
79     }
80
81     /**
82      * Create a queue connection with specified user identity.
83      * The connection is created in stopped mode. No messages will
84      * be delivered until Connection.start method is explicitly called.
85      *
86      * @param userName - the caller's user name
87      * @param password - the caller's password
88      *
89      * @throws JMSException - if JMS Provider fails to create Queue Connection
90      * due to some internal error. required resources for a Queue Connection.
91      * @throws JMSSecurityException - if client authentication fails due to
92      * invalid user name or password.
93      */

94     public QueueConnection JavaDoc createQueueConnection(String JavaDoc userName, String JavaDoc password) throws JMSException JavaDoc {
95     TraceJms.logger.log(BasicLevel.DEBUG,"");
96     JQueueConnection qc = (JQueueConnection) getJConnection(userName);
97     if (qc == null) {
98         qc = new JQueueConnection(this, xaqcf, userName, password);
99     }
100     return (QueueConnection JavaDoc) qc;
101     }
102
103
104 }
105
Popular Tags