KickJava   Java API By Example, From Geeks To Geeks.

Java > Open Source Codes > org > jboss > mq > SpyXAConnectionFactory


1 /*
2 * JBoss, Home of Professional Open Source
3 * Copyright 2005, JBoss Inc., and individual contributors as indicated
4 * by the @authors tag. See the copyright.txt in the distribution for a
5 * full listing of individual contributors.
6 *
7 * This is free software; you can redistribute it and/or modify it
8 * under the terms of the GNU Lesser General Public License as
9 * published by the Free Software Foundation; either version 2.1 of
10 * the License, or (at your option) any later version.
11 *
12 * This software is distributed in the hope that it will be useful,
13 * but WITHOUT ANY WARRANTY; without even the implied warranty of
14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
15 * Lesser General Public License for more details.
16 *
17 * You should have received a copy of the GNU Lesser General Public
18 * License along with this software; if not, write to the Free
19 * Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
20 * 02110-1301 USA, or see the FSF site: http://www.fsf.org.
21 */

22 package org.jboss.mq;
23
24 import java.io.Serializable JavaDoc;
25 import java.util.Properties JavaDoc;
26
27 import javax.jms.JMSException JavaDoc;
28 import javax.jms.XAConnection JavaDoc;
29 import javax.jms.XAConnectionFactory JavaDoc;
30 import javax.jms.XAQueueConnection JavaDoc;
31 import javax.jms.XAQueueConnectionFactory JavaDoc;
32 import javax.jms.XATopicConnection JavaDoc;
33 import javax.jms.XATopicConnectionFactory JavaDoc;
34 import javax.naming.NamingException JavaDoc;
35 import javax.naming.Reference JavaDoc;
36
37 /**
38  * This class implements <code>javax.jms.XATopicConnectionFactory</code> and
39  * <code>javax.jms.XAQueueConnectionFactory</code>.
40  *
41  * @author Hiram Chirino (Cojonudo14@hotmail.com)
42  * @author <a HREF="mailto:jason@planet57.com">Jason Dillon</a>
43  * @author <a HREF="mailto:adrian@jboss.org">Adrian Brock</a>
44  * @version <tt>$Revision: 37459 $</tt>
45  */

46 public class SpyXAConnectionFactory extends SpyConnectionFactory
47    implements Serializable JavaDoc, XAConnectionFactory JavaDoc, XAQueueConnectionFactory JavaDoc, XATopicConnectionFactory JavaDoc
48 {
49    // Constants -----------------------------------------------------
50

51    /** The serialVersionUID */
52    static final long serialVersionUID = -3869656253676593051L;
53    
54    // Attributes ----------------------------------------------------
55

56    // Static --------------------------------------------------------
57

58    // Constructors --------------------------------------------------
59

60    /**
61     * Create a new SpyXAConnectionFactory
62     *
63     * @param factory the generic connection factory
64     */

65    public SpyXAConnectionFactory(GenericConnectionFactory factory)
66    {
67       super(factory);
68    }
69
70    /**
71     * Create a new SpyXAConnectionFactory
72     *
73     * @param config the configuration
74     */

75    public SpyXAConnectionFactory(Properties JavaDoc config)
76    {
77       super(config);
78    }
79    
80    // Public --------------------------------------------------------
81

82    // XAConnectionFactory implementation ----------------------------
83

84    public XAConnection JavaDoc createXAConnection() throws JMSException JavaDoc
85    {
86       try
87       {
88          return new SpyXAConnection(factory);
89       }
90       catch (JMSException JavaDoc e)
91       {
92          throw e;
93       }
94       catch (Exception JavaDoc e)
95       {
96          throw new SpyJMSException("Failed to create XAConnection", e);
97       }
98    }
99
100    public XAConnection JavaDoc createXAConnection(String JavaDoc userName, String JavaDoc password) throws JMSException JavaDoc
101    {
102       try
103       {
104          if (userName == null)
105             throw new SpyJMSException("Username is null");
106          if (password == null)
107             throw new SpyJMSException("Password is null");
108
109          return new SpyXAConnection(userName, password, factory);
110       }
111       catch (JMSException JavaDoc e)
112       {
113          throw e;
114       }
115       catch (Exception JavaDoc e)
116       {
117          throw new SpyJMSException("Failed to create XAConnection", e);
118       }
119    }
120    
121    // XAQueueConnectionFactory implementation -----------------------
122

123    public XAQueueConnection JavaDoc createXAQueueConnection() throws JMSException JavaDoc
124    {
125       return (XAQueueConnection JavaDoc) createXAConnection();
126    }
127
128    public XAQueueConnection JavaDoc createXAQueueConnection(String JavaDoc userName, String JavaDoc password) throws JMSException JavaDoc
129    {
130       return (XAQueueConnection JavaDoc) createXAConnection(userName, password);
131    }
132    
133    // XATopicConnectionFactory implementation -----------------------
134

135    public XATopicConnection JavaDoc createXATopicConnection() throws JMSException JavaDoc
136    {
137       return (XATopicConnection JavaDoc) createXAConnection();
138    }
139
140    public XATopicConnection JavaDoc createXATopicConnection(String JavaDoc userName, String JavaDoc password) throws JMSException JavaDoc
141    {
142       return (XATopicConnection JavaDoc) createXAConnection(userName, password);
143    }
144    
145    // Referenceable implementation ----------------------------------
146

147    public Reference JavaDoc getReference() throws NamingException JavaDoc
148    {
149
150       return new Reference JavaDoc("org.jboss.mq.SpyXAConnectionFactory", new org.jboss.mq.referenceable.ObjectRefAddr("DCF",
151             factory),
152             "org.jboss.mq.referenceable.SpyConnectionFactoryObjectFactory", null);
153    }
154    
155    // Package protected ---------------------------------------------
156

157    // Protected -----------------------------------------------------
158

159    // Private -------------------------------------------------------
160

161    // Inner classes -------------------------------------------------
162
}
Popular Tags