mirror of https://github.com/apache/activemq.git
resolve https://issues.apache.org/activemq/browse/AMQ-2656 xa=true in the environment will ensure an XACOnnectionFactory is created
git-svn-id: https://svn.apache.org/repos/asf/activemq/trunk@924972 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
parent
a84f524404
commit
d914548559
|
@ -33,6 +33,7 @@ import javax.naming.NamingException;
|
|||
import javax.naming.spi.InitialContextFactory;
|
||||
|
||||
import org.apache.activemq.ActiveMQConnectionFactory;
|
||||
import org.apache.activemq.ActiveMQXAConnectionFactory;
|
||||
import org.apache.activemq.command.ActiveMQQueue;
|
||||
import org.apache.activemq.command.ActiveMQTopic;
|
||||
|
||||
|
@ -198,13 +199,20 @@ public class ActiveMQInitialContextFactory implements InitialContextFactory {
|
|||
* environment
|
||||
*/
|
||||
protected ActiveMQConnectionFactory createConnectionFactory(Hashtable environment) throws URISyntaxException {
|
||||
ActiveMQConnectionFactory answer = new ActiveMQConnectionFactory();
|
||||
ActiveMQConnectionFactory answer = needsXA(environment) ? new ActiveMQXAConnectionFactory() : new ActiveMQConnectionFactory();
|
||||
Properties properties = new Properties();
|
||||
properties.putAll(environment);
|
||||
answer.setProperties(properties);
|
||||
return answer;
|
||||
}
|
||||
|
||||
private boolean needsXA(Hashtable environment) {
|
||||
boolean isXA = Boolean.parseBoolean((String) environment.get("xa"));
|
||||
// property not applicable to connectionfactory so remove
|
||||
environment.remove("xa");
|
||||
return isXA;
|
||||
}
|
||||
|
||||
public String getConnectionPrefix() {
|
||||
return connectionPrefix;
|
||||
}
|
||||
|
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||
* contributor license agreements. See the NOTICE file distributed with
|
||||
* this work for additional information regarding copyright ownership.
|
||||
* The ASF licenses this file to You 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.apache.activemq.jndi;
|
||||
|
||||
import javax.jms.XAConnectionFactory;
|
||||
import javax.naming.NamingException;
|
||||
|
||||
public class XAConnectionFactoryTest extends ActiveMQInitialContextFactoryTest {
|
||||
|
||||
public void testConnectionFactoriesIsXA() throws NamingException {
|
||||
assertTrue("connection factory implements XA", context.lookup(getConnectionFactoryLookupName()) instanceof XAConnectionFactory);
|
||||
}
|
||||
|
||||
protected void configureEnvironment() {
|
||||
environment.put("xa", "true");
|
||||
super.configureEnvironment();
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue