001 /** 002 * 003 * Copyright 2004 Protique Ltd 004 * 005 * Licensed under the Apache License, Version 2.0 (the "License"); 006 * you may not use this file except in compliance with the License. 007 * You may obtain a copy of the License at 008 * 009 * http://www.apache.org/licenses/LICENSE-2.0 010 * 011 * Unless required by applicable law or agreed to in writing, software 012 * distributed under the License is distributed on an "AS IS" BASIS, 013 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 014 * See the License for the specific language governing permissions and 015 * limitations under the License. 016 * 017 **/ 018 package org.activemq; 019 020 import org.activemq.broker.BrokerContainer; 021 022 import javax.jms.Connection; 023 import javax.jms.JMSException; 024 import javax.jms.QueueConnection; 025 import javax.jms.TopicConnection; 026 import javax.jms.XAConnection; 027 import javax.jms.XAConnectionFactory; 028 import javax.jms.XAQueueConnection; 029 import javax.jms.XAQueueConnectionFactory; 030 import javax.jms.XATopicConnection; 031 import javax.jms.XATopicConnectionFactory; 032 033 /** 034 * The XAConnectionFactory interface is a base interface for the 035 * XAQueueConnectionFactory and XATopicConnectionFactory interfaces. 036 * <p/> 037 * Some application servers provide support for grouping JTS capable resource 038 * use into a distributed transaction (optional). To include JMS API 039 * transactions in a JTS transaction, an application server requires a JTS 040 * aware JMS provider. A JMS provider exposes its JTS support using an 041 * XAConnectionFactory object, which an application server uses to create 042 * XAConnection objects. 043 * <p/> 044 * XAConnectionFactory objects are JMS administered objects, just like 045 * ConnectionFactory objects. It is expected that application servers will 046 * find them using the Java Naming and Directory Interface (JNDI) API. 047 * <p/> 048 * The XAConnectionFactory interface is optional. JMS providers are not 049 * required to support this interface. This interface is for use by JMS 050 * providers to support transactional environments. Client programs are 051 * strongly encouraged to use the transactional support available in their 052 * environment, rather than use these XA interfaces directly. 053 * 054 * @version $Revision: 1.1.1.1 $ 055 * @see javax.jms.ConnectionFactory 056 */ 057 public class ActiveMQXAConnectionFactory extends ActiveMQConnectionFactory implements XAConnectionFactory, XAQueueConnectionFactory, XATopicConnectionFactory { 058 059 public ActiveMQXAConnectionFactory() { 060 super(); 061 } 062 063 public ActiveMQXAConnectionFactory(String brokerURL) { 064 super(brokerURL); 065 } 066 067 public ActiveMQXAConnectionFactory(String userName, String password, String brokerURL) { 068 super(userName, password, brokerURL); 069 } 070 071 public ActiveMQXAConnectionFactory(BrokerContainer container) { 072 super(container); 073 } 074 075 public ActiveMQXAConnectionFactory(BrokerContainer container, String brokerURL) { 076 super(container, brokerURL); 077 } 078 079 public XAConnection createXAConnection() throws JMSException { 080 return createActiveMQXAConnection(this.userName, this.password); 081 } 082 083 public XAConnection createXAConnection(String userName, String password) throws JMSException { 084 return createActiveMQXAConnection(userName, password); 085 } 086 087 public XAQueueConnection createXAQueueConnection() throws JMSException { 088 return createActiveMQXAConnection(userName, password); 089 } 090 091 public XAQueueConnection createXAQueueConnection(String userName, String password) throws JMSException { 092 return createActiveMQXAConnection(userName, password); 093 } 094 095 public XATopicConnection createXATopicConnection() throws JMSException { 096 return createActiveMQXAConnection(userName, password); 097 } 098 099 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 }