/**
 * 
 * Copyright 2004 Hiram Chirino
 * 
 * Licensed under the Apache License, Version 2.0 (the "License"); 
 * you may not use this file except in compliance with the License. 
 * You may obtain a copy of the License at 
 * 
 * http://www.apache.org/licenses/LICENSE-2.0
 * 
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS, 
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 
 * See the License for the specific language governing permissions and 
 * limitations under the License. 
 * 
 **/
package org.codehaus.activemq.ra;

import org.codehaus.activemq.ActiveMQXAConnectionFactory;
import org.codehaus.activemq.ActiveMQXAConnection;

import javax.jms.JMSException;

/**
 * The ActiveMQRAConnectionFactory extends the ActiveMQXAConnectionFactory so 
 * that it is more flexible in terms of using the availble 
 * transaction context.  A normal ActiveMQXAConnectionFactory implements
 * the XAConnectionFactory interface stictly which means that it
 * can only do work in the context of an XA transaction. 
 *
 */
public class ActiveMQRAConnectionFactory extends ActiveMQXAConnectionFactory {

	public ActiveMQRAConnectionFactory() {
		super();
	}

	public ActiveMQRAConnectionFactory(String brokerURL) {
		super(brokerURL);
	}

	public ActiveMQRAConnectionFactory(String userName, String password,
			String brokerURL) {
		super(userName, password, brokerURL);
	}

	protected ActiveMQXAConnection createActiveMQXAConnection(String userName, String password) throws JMSException {
        ActiveMQRAConnection connection = new ActiveMQRAConnection(this, userName, password, createTransportChannel(this.brokerURL));
        connection.setUseAsyncSend(false);
        if (this.clientID != null && this.clientID.length() > 0) {
            connection.setClientID(this.clientID);
        }
        return connection;
    }
	
}
