001/** 002 * Licensed to the Apache Software Foundation (ASF) under one or more 003 * contributor license agreements. See the NOTICE file distributed with 004 * this work for additional information regarding copyright ownership. 005 * The ASF licenses this file to You under the Apache License, Version 2.0 006 * (the "License"); you may not use this file except in compliance with 007 * the License. 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 */ 017package org.apache.activemq; 018 019import java.net.URI; 020import java.util.Properties; 021 022import javax.jms.JMSException; 023import javax.jms.XAConnection; 024import javax.jms.XAConnectionFactory; 025import javax.jms.XAQueueConnection; 026import javax.jms.XAQueueConnectionFactory; 027import javax.jms.XATopicConnection; 028import javax.jms.XATopicConnectionFactory; 029 030import org.apache.activemq.management.JMSStatsImpl; 031import org.apache.activemq.transport.Transport; 032 033public class ActiveMQXASslConnectionFactory extends ActiveMQSslConnectionFactory implements XAConnectionFactory, XAQueueConnectionFactory, XATopicConnectionFactory { 034 035 public ActiveMQXASslConnectionFactory() { 036 } 037 038 public ActiveMQXASslConnectionFactory(String brokerURL) { 039 super(brokerURL); 040 } 041 042 public ActiveMQXASslConnectionFactory(URI brokerURL) { 043 super(brokerURL); 044 } 045 046 @Override 047 public XAConnection createXAConnection() throws JMSException { 048 return (XAConnection) createActiveMQConnection(); 049 } 050 051 @Override 052 public XAConnection createXAConnection(String userName, String password) throws JMSException { 053 return (XAConnection) createActiveMQConnection(userName, password); 054 } 055 056 @Override 057 public XAQueueConnection createXAQueueConnection() throws JMSException { 058 return (XAQueueConnection) createActiveMQConnection(); 059 } 060 061 @Override 062 public XAQueueConnection createXAQueueConnection(String userName, String password) throws JMSException { 063 return (XAQueueConnection) createActiveMQConnection(userName, password); 064 } 065 066 @Override 067 public XATopicConnection createXATopicConnection() throws JMSException { 068 return (XATopicConnection) createActiveMQConnection(); 069 } 070 071 @Override 072 public XATopicConnection createXATopicConnection(String userName, String password) throws JMSException { 073 return (XATopicConnection) createActiveMQConnection(userName, password); 074 } 075 076 @Override 077 protected ActiveMQConnection createActiveMQConnection(Transport transport, JMSStatsImpl stats) throws Exception { 078 ActiveMQXAConnection connection = new ActiveMQXAConnection(transport, getClientIdGenerator(), getConnectionIdGenerator(), stats); 079 configureXAConnection(connection); 080 return connection; 081 } 082 083 private void configureXAConnection(ActiveMQXAConnection connection) { 084 connection.setXaAckMode(xaAckMode); 085 } 086 087 public int getXaAckMode() { 088 return xaAckMode; 089 } 090 091 public void setXaAckMode(int xaAckMode) { 092 this.xaAckMode = xaAckMode; 093 } 094 095 @Override 096 public void populateProperties(Properties props) { 097 super.populateProperties(props); 098 props.put("xaAckMode", Integer.toString(xaAckMode)); 099 } 100}