001: /*
002: * JOnAS: Java(TM) Open Application Server
003: * Copyright (C) 1999 Bull S.A.
004: * Contact: jonas-team@objectweb.org
005: *
006: * This library is free software; you can redistribute it and/or
007: * modify it under the terms of the GNU Lesser General Public
008: * License as published by the Free Software Foundation; either
009: * version 2.1 of the License, or any later version.
010: *
011: * This library is distributed in the hope that it will be useful,
012: * but WITHOUT ANY WARRANTY; without even the implied warranty of
013: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
014: * Lesser General Public License for more details.
015: *
016: * You should have received a copy of the GNU Lesser General Public
017: * License along with this library; if not, write to the Free Software
018: * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307
019: * USA
020: *
021: * --------------------------------------------------------------------------
022: * $Id: JQueueConnectionFactory.java 4408 2004-03-19 14:31:54Z sauthieg $
023: * --------------------------------------------------------------------------
024: */
025:
026: package org.objectweb.jonas_jms;
027:
028: import javax.jms.JMSException;
029: import javax.jms.QueueConnection;
030: import javax.jms.QueueConnectionFactory;
031: import javax.jms.XAQueueConnectionFactory;
032:
033: import org.objectweb.util.monolog.api.BasicLevel;
034:
035: /**
036: * JQueueConnectionFactory wraps a XAQueueConnectionFactory.
037: *
038: * @author Laurent Chauvirey, Frederic Maistre, Nicolas Tachker
039: * Contributor(s):
040: * Philippe Durieux
041: * Jeff Mesnil
042: * Philippe Coq
043: */
044: public class JQueueConnectionFactory extends JConnectionFactory
045: implements QueueConnectionFactory {
046:
047: private XAQueueConnectionFactory xaqcf;
048:
049: /**
050: * Constructor.
051: * The underlaying XAQueueConnectionFactory is found in the JmsManager.
052: */
053: public JQueueConnectionFactory(String name) {
054: this .name = name;
055: jms = JmsManagerImpl.getJmsManager();
056: xacf = jms.getXAQueueConnectionFactory();
057: xaqcf = (XAQueueConnectionFactory) xacf;
058: }
059:
060: // -----------------------------------------------------------------------
061: // QueueConnectionFactory implementation
062: // -----------------------------------------------------------------------
063:
064: /**
065: * Create a queue connection for an anonymous user.
066: *
067: * @return a newly created queue connection.
068: * @throws JMSException - if JMS Provider fails to create Queue Connection
069: * due to some internal error. required resources for a Queue Connection.
070: * @throws JMSSecurityException - if client authentication fails due to
071: * invalid user name or password.
072: */
073: public QueueConnection createQueueConnection() throws JMSException {
074: TraceJms.logger.log(BasicLevel.DEBUG, "");
075: JQueueConnection qc = (JQueueConnection) getJConnection();
076: if (qc == null) {
077: qc = new JQueueConnection(this , xaqcf);
078: }
079: return (QueueConnection) qc;
080: }
081:
082: /**
083: * Create a queue connection with specified user identity.
084: * The connection is created in stopped mode. No messages will
085: * be delivered until Connection.start method is explicitly called.
086: *
087: * @param userName - the caller's user name
088: * @param password - the caller's password
089: *
090: * @throws JMSException - if JMS Provider fails to create Queue Connection
091: * due to some internal error. required resources for a Queue Connection.
092: * @throws JMSSecurityException - if client authentication fails due to
093: * invalid user name or password.
094: */
095: public QueueConnection createQueueConnection(String userName,
096: String password) throws JMSException {
097: TraceJms.logger.log(BasicLevel.DEBUG, "");
098: JQueueConnection qc = (JQueueConnection) getJConnection(userName);
099: if (qc == null) {
100: qc = new JQueueConnection(this , xaqcf, userName, password);
101: }
102: return (QueueConnection) qc;
103: }
104:
105: }
|