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 javax.jms.JMSException; 021 import javax.jms.Session; 022 import javax.jms.XAConnection; 023 import javax.jms.XAQueueConnection; 024 import javax.jms.XAQueueSession; 025 import javax.jms.XASession; 026 import javax.jms.XATopicConnection; 027 import javax.jms.XATopicSession; 028 029 import org.activemq.transport.TransportChannel; 030 031 /** 032 * The XAConnection interface extends the capability of Connection by providing 033 * an XASession (optional). 034 * <p/> 035 * The XAConnection interface is optional. JMS providers are not required to 036 * support this interface. This interface is for use by JMS providers to 037 * support transactional environments. Client programs are strongly encouraged 038 * to use the transactional support available in their environment, rather 039 * than use these XA interfaces directly. 040 * 041 * @version $Revision: 1.1.1.1 $ 042 * @see javax.jms.Connection 043 * @see javax.jms.ConnectionFactory 044 * @see javax.jms.QueueConnection 045 * @see javax.jms.TopicConnection 046 * @see javax.jms.TopicConnectionFactory 047 * @see javax.jms.QueueConnection 048 * @see javax.jms.QueueConnectionFactory 049 */ 050 public class ActiveMQXAConnection extends ActiveMQConnection implements XATopicConnection, XAQueueConnection, XAConnection { 051 052 public ActiveMQXAConnection(ActiveMQConnectionFactory factory, String theUserName, String thePassword, TransportChannel transportChannel) throws JMSException { 053 super(factory, theUserName, thePassword, transportChannel); 054 } 055 056 public ActiveMQXAConnection(ActiveMQConnectionFactory factory, String theUserName, String thePassword) throws JMSException { 057 super(factory, theUserName, thePassword); 058 } 059 060 public XASession createXASession() throws JMSException { 061 return (XASession) createSession(true, Session.SESSION_TRANSACTED); 062 } 063 064 public XATopicSession createXATopicSession() throws JMSException { 065 return (XATopicSession) createSession(true, Session.SESSION_TRANSACTED); 066 } 067 068 public XAQueueSession createXAQueueSession() throws JMSException { 069 return (XAQueueSession) createSession(true, Session.SESSION_TRANSACTED); 070 } 071 072 public Session createSession(boolean transacted, int acknowledgeMode) throws JMSException { 073 checkClosed(); 074 sendConnectionInfoToBroker(); 075 return new ActiveMQXASession(this, Session.SESSION_TRANSACTED); 076 } 077 }