Source code: org/activemq/ActiveMQXAConnectionFactory.java
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.activemq;
19
20 import org.activemq.broker.BrokerContainer;
21
22 import javax.jms.Connection;
23 import javax.jms.JMSException;
24 import javax.jms.QueueConnection;
25 import javax.jms.TopicConnection;
26 import javax.jms.XAConnection;
27 import javax.jms.XAConnectionFactory;
28 import javax.jms.XAQueueConnection;
29 import javax.jms.XAQueueConnectionFactory;
30 import javax.jms.XATopicConnection;
31 import javax.jms.XATopicConnectionFactory;
32
33 /**
34 * The XAConnectionFactory interface is a base interface for the
35 * XAQueueConnectionFactory and XATopicConnectionFactory interfaces.
36 * <p/>
37 * Some application servers provide support for grouping JTS capable resource
38 * use into a distributed transaction (optional). To include JMS API
39 * transactions in a JTS transaction, an application server requires a JTS
40 * aware JMS provider. A JMS provider exposes its JTS support using an
41 * XAConnectionFactory object, which an application server uses to create
42 * XAConnection objects.
43 * <p/>
44 * XAConnectionFactory objects are JMS administered objects, just like
45 * ConnectionFactory objects. It is expected that application servers will
46 * find them using the Java Naming and Directory Interface (JNDI) API.
47 * <p/>
48 * The XAConnectionFactory interface is optional. JMS providers are not
49 * required to support this interface. This interface is for use by JMS
50 * providers to support transactional environments. Client programs are
51 * strongly encouraged to use the transactional support available in their
52 * environment, rather than use these XA interfaces directly.
53 *
54 * @version $Revision: 1.1.1.1 $
55 * @see javax.jms.ConnectionFactory
56 */
57 public class ActiveMQXAConnectionFactory extends ActiveMQConnectionFactory implements XAConnectionFactory, XAQueueConnectionFactory, XATopicConnectionFactory {
58
59 public ActiveMQXAConnectionFactory() {
60 super();
61 }
62
63 public ActiveMQXAConnectionFactory(String brokerURL) {
64 super(brokerURL);
65 }
66
67 public ActiveMQXAConnectionFactory(String userName, String password, String brokerURL) {
68 super(userName, password, brokerURL);
69 }
70
71 public ActiveMQXAConnectionFactory(BrokerContainer container) {
72 super(container);
73 }
74
75 public ActiveMQXAConnectionFactory(BrokerContainer container, String brokerURL) {
76 super(container, brokerURL);
77 }
78
79 public XAConnection createXAConnection() throws JMSException {
80 return createActiveMQXAConnection(this.userName, this.password);
81 }
82
83 public XAConnection createXAConnection(String userName, String password) throws JMSException {
84 return createActiveMQXAConnection(userName, password);
85 }
86
87 public XAQueueConnection createXAQueueConnection() throws JMSException {
88 return createActiveMQXAConnection(userName, password);
89 }
90
91 public XAQueueConnection createXAQueueConnection(String userName, String password) throws JMSException {
92 return createActiveMQXAConnection(userName, password);
93 }
94
95 public XATopicConnection createXATopicConnection() throws JMSException {
96 return createActiveMQXAConnection(userName, password);
97 }
98
99 public XATopicConnection createXATopicConnection(String userName, String password) throws JMSException {
100 return createActiveMQXAConnection(userName, password);
101 }
102
103 public Connection createConnection() throws JMSException {
104 return createActiveMQXAConnection(userName, password);
105 }
106
107 public Connection createConnection(String userName, String password) throws JMSException {
108 return createActiveMQXAConnection(userName, password);
109 }
110
111 public QueueConnection createQueueConnection() throws JMSException {
112 return createActiveMQXAConnection(userName, password);
113 }
114
115 public QueueConnection createQueueConnection(String userName, String password) throws JMSException {
116 return createActiveMQXAConnection(userName, password);
117 }
118
119 public TopicConnection createTopicConnection() throws JMSException {
120 return createActiveMQXAConnection(userName, password);
121 }
122
123 public TopicConnection createTopicConnection(String userName, String password) throws JMSException {
124 return createActiveMQXAConnection(userName, password);
125 }
126
127 protected ActiveMQXAConnection createActiveMQXAConnection(String userName, String password) throws JMSException {
128 ActiveMQXAConnection connection = new ActiveMQXAConnection(this, userName, password, createTransportChannel(this.brokerURL));
129 connection.setUseAsyncSend(isUseAsyncSend());
130 if (this.clientID != null && this.clientID.length() > 0) {
131 connection.setClientID(this.clientID);
132 }
133 return connection;
134 }
135
136 }