001: /*
002: * JBoss, Home of Professional Open Source.
003: * Copyright 2006, Red Hat Middleware LLC, and individual contributors
004: * as indicated by the @author tags. See the copyright.txt file in the
005: * distribution for a full listing of individual contributors.
006: *
007: * This is free software; you can redistribute it and/or modify it
008: * under the terms of the GNU Lesser General Public License as
009: * published by the Free Software Foundation; either version 2.1 of
010: * the License, or (at your option) any later version.
011: *
012: * This software is distributed in the hope that it will be useful,
013: * but WITHOUT ANY WARRANTY; without even the implied warranty of
014: * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
015: * Lesser General Public License for more details.
016: *
017: * You should have received a copy of the GNU Lesser General Public
018: * License along with this software; if not, write to the Free
019: * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
020: * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
021: */
022: package org.jboss.jms.client;
023:
024: import javax.jms.Connection;
025: import javax.jms.ConnectionFactory;
026: import javax.jms.JMSException;
027: import javax.jms.QueueConnection;
028: import javax.jms.QueueConnectionFactory;
029: import javax.jms.TopicConnection;
030: import javax.jms.TopicConnectionFactory;
031: import javax.jms.XAConnection;
032: import javax.jms.XAConnectionFactory;
033: import javax.jms.XAQueueConnection;
034: import javax.jms.XAQueueConnectionFactory;
035: import javax.jms.XATopicConnection;
036: import javax.jms.XATopicConnectionFactory;
037: import javax.naming.NamingException;
038: import javax.naming.Reference;
039: import javax.naming.Referenceable;
040:
041: /**
042: * A connection factory
043: *
044: * @author <a href="mailto:adrian@jboss.org>Adrian Brock</a>
045: * @version $Revision: 57195 $
046: */
047: public class JBossConnectionFactory implements ConnectionFactory,
048: QueueConnectionFactory, TopicConnectionFactory,
049: XAConnectionFactory, XAQueueConnectionFactory,
050: XATopicConnectionFactory, Referenceable {
051: // Constants -----------------------------------------------------
052:
053: // Attributes ----------------------------------------------------
054:
055: /** The implementation delegate */
056: ImplementationDelegate delegate;
057:
058: // Static --------------------------------------------------------
059:
060: // Constructors --------------------------------------------------
061:
062: // Public --------------------------------------------------------
063:
064: /**
065: * Construct a new Connection factory
066: *
067: * @param delegate the implementation
068: */
069: public JBossConnectionFactory(ImplementationDelegate delegate)
070: throws JMSException {
071: this .delegate = delegate;
072: }
073:
074: // ConnectionFactory implementation ------------------------------
075:
076: public Connection createConnection() throws JMSException {
077: return createConnection(null, null);
078: }
079:
080: public Connection createConnection(String userName, String password)
081: throws JMSException {
082: ConnectionDelegate connection = delegate.createConnection(
083: userName, password);
084: return new JBossConnection(connection, false);
085: }
086:
087: // QueueConnectionFactory implementation -------------------------
088:
089: public QueueConnection createQueueConnection() throws JMSException {
090: return (QueueConnection) createConnection(null, null);
091: }
092:
093: public QueueConnection createQueueConnection(String userName,
094: String password) throws JMSException {
095: return (QueueConnection) createConnection(userName, password);
096: }
097:
098: // TopicConnectionFactory implementation -------------------------
099:
100: public TopicConnection createTopicConnection() throws JMSException {
101: return (TopicConnection) createConnection(null, null);
102: }
103:
104: public TopicConnection createTopicConnection(String userName,
105: String password) throws JMSException {
106: return (TopicConnection) createConnection(userName, password);
107: }
108:
109: // XAConnectionFactory implementation ----------------------------
110:
111: public XAConnection createXAConnection() throws JMSException {
112: return createXAConnection(null, null);
113: }
114:
115: public XAConnection createXAConnection(String userName,
116: String password) throws JMSException {
117: ConnectionDelegate connection = delegate.createConnection(
118: userName, password);
119: return new JBossConnection(connection, true);
120: }
121:
122: // XAQueueConnectionFactory implementation -----------------------
123:
124: public XAQueueConnection createXAQueueConnection()
125: throws JMSException {
126: return (XAQueueConnection) createXAConnection(null, null);
127: }
128:
129: public XAQueueConnection createXAQueueConnection(String userName,
130: String password) throws JMSException {
131: return (XAQueueConnection) createXAConnection(userName,
132: password);
133: }
134:
135: // XATopicConnectionFactory implementation -----------------------
136:
137: public XATopicConnection createXATopicConnection()
138: throws JMSException {
139: return (XATopicConnection) createXAConnection(null, null);
140: }
141:
142: public XATopicConnection createXATopicConnection(String userName,
143: String password) throws JMSException {
144: return (XATopicConnection) createXAConnection(userName,
145: password);
146: }
147:
148: // Referenceable implementation------------------------------------
149:
150: public Reference getReference() throws NamingException {
151: return delegate.getReference();
152: }
153:
154: // Protected ------------------------------------------------------
155:
156: // Package Private ------------------------------------------------
157:
158: // Private --------------------------------------------------------
159:
160: // Inner Classes --------------------------------------------------
161:
162: }
|