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.mq;
023:
024: import java.io.Serializable;
025: import java.util.Properties;
026:
027: import javax.jms.JMSException;
028: import javax.jms.XAConnection;
029: import javax.jms.XAConnectionFactory;
030: import javax.jms.XAQueueConnection;
031: import javax.jms.XAQueueConnectionFactory;
032: import javax.jms.XATopicConnection;
033: import javax.jms.XATopicConnectionFactory;
034: import javax.naming.NamingException;
035: import javax.naming.Reference;
036:
037: /**
038: * This class implements <code>javax.jms.XATopicConnectionFactory</code> and
039: * <code>javax.jms.XAQueueConnectionFactory</code>.
040: *
041: * @author Hiram Chirino (Cojonudo14@hotmail.com)
042: * @author <a href="mailto:jason@planet57.com">Jason Dillon</a>
043: * @author <a href="mailto:adrian@jboss.org">Adrian Brock</a>
044: * @version <tt>$Revision: 57198 $</tt>
045: */
046: public class SpyXAConnectionFactory extends SpyConnectionFactory
047: implements Serializable, XAConnectionFactory,
048: XAQueueConnectionFactory, XATopicConnectionFactory {
049: // Constants -----------------------------------------------------
050:
051: /** The serialVersionUID */
052: static final long serialVersionUID = -3869656253676593051L;
053:
054: // Attributes ----------------------------------------------------
055:
056: // Static --------------------------------------------------------
057:
058: // Constructors --------------------------------------------------
059:
060: /**
061: * Create a new SpyXAConnectionFactory
062: *
063: * @param factory the generic connection factory
064: */
065: public SpyXAConnectionFactory(GenericConnectionFactory factory) {
066: super (factory);
067: }
068:
069: /**
070: * Create a new SpyXAConnectionFactory
071: *
072: * @param config the configuration
073: */
074: public SpyXAConnectionFactory(Properties config) {
075: super (config);
076: }
077:
078: // Public --------------------------------------------------------
079:
080: // XAConnectionFactory implementation ----------------------------
081:
082: public XAConnection createXAConnection() throws JMSException {
083: try {
084: return new SpyXAConnection(factory);
085: } catch (JMSException e) {
086: throw e;
087: } catch (Exception e) {
088: throw new SpyJMSException("Failed to create XAConnection",
089: e);
090: }
091: }
092:
093: public XAConnection createXAConnection(String userName,
094: String password) throws JMSException {
095: try {
096: if (userName == null)
097: throw new SpyJMSException("Username is null");
098: if (password == null)
099: throw new SpyJMSException("Password is null");
100:
101: return new SpyXAConnection(userName, password, factory);
102: } catch (JMSException e) {
103: throw e;
104: } catch (Exception e) {
105: throw new SpyJMSException("Failed to create XAConnection",
106: e);
107: }
108: }
109:
110: // XAQueueConnectionFactory implementation -----------------------
111:
112: public XAQueueConnection createXAQueueConnection()
113: throws JMSException {
114: return (XAQueueConnection) createXAConnection();
115: }
116:
117: public XAQueueConnection createXAQueueConnection(String userName,
118: String password) throws JMSException {
119: return (XAQueueConnection) createXAConnection(userName,
120: password);
121: }
122:
123: // XATopicConnectionFactory implementation -----------------------
124:
125: public XATopicConnection createXATopicConnection()
126: throws JMSException {
127: return (XATopicConnection) createXAConnection();
128: }
129:
130: public XATopicConnection createXATopicConnection(String userName,
131: String password) throws JMSException {
132: return (XATopicConnection) createXAConnection(userName,
133: password);
134: }
135:
136: // Referenceable implementation ----------------------------------
137:
138: public Reference getReference() throws NamingException {
139:
140: return new Reference(
141: "org.jboss.mq.SpyXAConnectionFactory",
142: new org.jboss.mq.referenceable.ObjectRefAddr("DCF",
143: factory),
144: "org.jboss.mq.referenceable.SpyConnectionFactoryObjectFactory",
145: null);
146: }
147:
148: // Package protected ---------------------------------------------
149:
150: // Protected -----------------------------------------------------
151:
152: // Private -------------------------------------------------------
153:
154: // Inner classes -------------------------------------------------
155: }
|