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: * $Id: JTopicConnectionFactory.java 4408 2004-03-19 14:31:54Z sauthieg $
022: * --------------------------------------------------------------------------
023: */
024:
025: package org.objectweb.jonas_jms;
026:
027: import javax.jms.JMSException;
028: import javax.jms.TopicConnection;
029: import javax.jms.TopicConnectionFactory;
030: import javax.jms.XATopicConnectionFactory;
031:
032: import org.objectweb.util.monolog.api.BasicLevel;
033:
034: /**
035: * JTopicConnectionFactory wraps a XATopicConnectionFactory.
036: *
037: * @author Laurent Chauvirey, Frederic Maistre, Nicolas Tachker
038: * Contributor(s):
039: * Philippe Durieux
040: * Jeff Mesnil connection anonymous
041: *
042: */
043: public class JTopicConnectionFactory extends JConnectionFactory
044: implements TopicConnectionFactory {
045:
046: private XATopicConnectionFactory xatcf;
047:
048: /**
049: * Constructor.
050: * The underlaying XATopicConnectionFactory is found in the JmsManager.
051: */
052: public JTopicConnectionFactory(String name) {
053: this .name = name;
054: jms = JmsManagerImpl.getJmsManager();
055: xacf = jms.getXATopicConnectionFactory();
056: xatcf = (XATopicConnectionFactory) xacf;
057: }
058:
059: // -----------------------------------------------------------------------
060: // TopicConnectionFactory implementation
061: // -----------------------------------------------------------------------
062:
063: /**
064: * Create a topic connection for an anonymous user.
065: *
066: * @return a newly created topic connection.
067: * @throws JMSException - if JMS Provider fails to create a Topic
068: * Connection due to some internal error.
069: * @throws JMSSecurityException - if client authentication fails due to
070: * invalid user name or password.
071: */
072: public TopicConnection createTopicConnection() throws JMSException {
073: // Try to reuse a connection from the pool.
074: // Create a new one if no connection available.
075: TraceJms.logger.log(BasicLevel.DEBUG, "");
076: JTopicConnection tc = (JTopicConnection) getJConnection();
077: if (tc == null) {
078: tc = new JTopicConnection(this , xatcf);
079: }
080: return (TopicConnection) tc;
081: }
082:
083: /**
084: * Create a topic connection with specified user identity.
085: * The connection is created in stopped mode. No messages will
086: * be delivered until Connection.start method is explicitly called.
087: *
088: * @param userName - the caller's user name
089: * @param password - the caller's password
090: *
091: * @throws JMSException - if JMS Provider fails to create Topic Connection
092: * due to some internal error. required resources for a Topic Connection.
093: * @throws JMSSecurityException - if client authentication fails due to
094: * invalid user name or password.
095: */
096: public TopicConnection createTopicConnection(String userName,
097: String password) throws JMSException {
098: TraceJms.logger.log(BasicLevel.DEBUG, "");
099: // Try to reuse a connection from the pool.
100: // Create a new one if no connection available.
101: JTopicConnection tc = (JTopicConnection) getJConnection(userName);
102: if (tc == null) {
103: tc = new JTopicConnection(this , xatcf, userName, password);
104: }
105: return (TopicConnection) tc;
106: }
107:
108: }
|