View Javadoc

1   /*** 
2    * 
3    * Copyright 2004 Protique Ltd
4    * 
5    * Licensed under the Apache License, Version 2.0 (the "License"); 
6    * you may not use this file except in compliance with the License. 
7    * You may obtain a copy of the License at 
8    * 
9    * http://www.apache.org/licenses/LICENSE-2.0
10   * 
11   * Unless required by applicable law or agreed to in writing, software
12   * distributed under the License is distributed on an "AS IS" BASIS, 
13   * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
14   * See the License for the specific language governing permissions and 
15   * limitations under the License. 
16   * 
17   **/
18  package org.codehaus.activemq;
19  
20  import javax.jms.Connection;
21  import javax.jms.JMSException;
22  import javax.jms.QueueConnection;
23  import javax.jms.TopicConnection;
24  import javax.jms.XAConnection;
25  import javax.jms.XAConnectionFactory;
26  import javax.jms.XAQueueConnection;
27  import javax.jms.XAQueueConnectionFactory;
28  import javax.jms.XATopicConnection;
29  import javax.jms.XATopicConnectionFactory;
30  
31  /***
32   * The XAConnectionFactory interface is a base interface for the
33   * XAQueueConnectionFactory and XATopicConnectionFactory interfaces.
34   * <p/>
35   * Some application servers provide support for grouping JTS capable resource
36   * use into a distributed transaction (optional). To include JMS API
37   * transactions in a JTS transaction, an application server requires a JTS
38   * aware JMS  provider. A JMS provider exposes its JTS support using an
39   * XAConnectionFactory object, which an application server uses to create
40   * XAConnection objects.
41   * <p/>
42   * XAConnectionFactory objects are JMS administered objects, just like
43   * ConnectionFactory objects. It is expected that application servers will
44   * find them using the Java Naming and Directory  Interface (JNDI) API.
45   * <p/>
46   * The XAConnectionFactory interface is optional. JMS providers are not
47   * required to support this interface. This interface is for use by JMS
48   * providers to support transactional environments. Client programs are
49   * strongly encouraged to use the transactional support  available in their
50   * environment, rather than use these XA  interfaces directly.
51   *
52   * @version $Revision: 1.2 $
53   * @see javax.jms.ConnectionFactory
54   */
55  public class ActiveMQXAConnectionFactory extends ActiveMQConnectionFactory implements XAConnectionFactory, XAQueueConnectionFactory, XATopicConnectionFactory {
56  
57      public ActiveMQXAConnectionFactory() {
58      }
59  
60      public ActiveMQXAConnectionFactory(String brokerURL) {
61          super(brokerURL);
62      }
63  
64      public ActiveMQXAConnectionFactory(String userName, String password, String brokerURL) {
65          super(userName, password, brokerURL);
66      }
67  
68      public XAConnection createXAConnection() throws JMSException {
69          return createActiveMQXAConnection(this.userName, this.password);
70      }
71  
72      public XAConnection createXAConnection(String userName, String password) throws JMSException {
73          return createActiveMQXAConnection(userName, password);
74      }
75  
76      public XAQueueConnection createXAQueueConnection() throws JMSException {
77          return createActiveMQXAConnection(userName, password);
78      }
79  
80      public XAQueueConnection createXAQueueConnection(String userName, String password) throws JMSException {
81          return createActiveMQXAConnection(userName, password);
82      }
83  
84      public XATopicConnection createXATopicConnection() throws JMSException {
85          return createActiveMQXAConnection(userName, password);
86      }
87  
88      public XATopicConnection createXATopicConnection(String userName, String password) throws JMSException {
89          return createActiveMQXAConnection(userName, password);
90      }
91  
92      public Connection createConnection() throws JMSException {
93          return createActiveMQXAConnection(userName, password);
94      }
95  
96      public Connection createConnection(String userName, String password) throws JMSException {
97          return createActiveMQXAConnection(userName, password);
98      }
99  
100     public QueueConnection createQueueConnection() throws JMSException {
101         return createActiveMQXAConnection(userName, password);
102     }
103 
104     public QueueConnection createQueueConnection(String userName, String password) throws JMSException {
105         return createActiveMQXAConnection(userName, password);
106     }
107 
108     public TopicConnection createTopicConnection() throws JMSException {
109         return createActiveMQXAConnection(userName, password);
110     }
111 
112     public TopicConnection createTopicConnection(String userName, String password) throws JMSException {
113         return createActiveMQXAConnection(userName, password);
114     }
115 
116     protected ActiveMQXAConnection createActiveMQXAConnection(String userName, String password) throws JMSException {
117         ActiveMQXAConnection connection = new ActiveMQXAConnection(this, userName, password, createTransportChannel(this.brokerURL));
118         if (this.clientID != null && this.clientID.length() > 0) {
119             connection.setClientID(this.clientID);
120         }
121         return connection;
122     }
123 }