You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@activemq.apache.org by gt...@apache.org on 2010/03/18 21:02:14 UTC
svn commit: r924972 - in /activemq/trunk/activemq-core/src:
main/java/org/apache/activemq/jndi/ActiveMQInitialContextFactory.java
test/java/org/apache/activemq/jndi/XAConnectionFactoryTest.java
Author: gtully
Date: Thu Mar 18 20:02:13 2010
New Revision: 924972
URL: http://svn.apache.org/viewvc?rev=924972&view=rev
Log:
resolve https://issues.apache.org/activemq/browse/AMQ-2656 xa=true in the environment will ensure an XACOnnectionFactory is created
Added:
activemq/trunk/activemq-core/src/test/java/org/apache/activemq/jndi/XAConnectionFactoryTest.java (with props)
Modified:
activemq/trunk/activemq-core/src/main/java/org/apache/activemq/jndi/ActiveMQInitialContextFactory.java
Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/jndi/ActiveMQInitialContextFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/jndi/ActiveMQInitialContextFactory.java?rev=924972&r1=924971&r2=924972&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/jndi/ActiveMQInitialContextFactory.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/jndi/ActiveMQInitialContextFactory.java Thu Mar 18 20:02:13 2010
@@ -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 ActiveMQInitialContextFacto
* 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;
}
Added: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/jndi/XAConnectionFactoryTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/jndi/XAConnectionFactoryTest.java?rev=924972&view=auto
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/jndi/XAConnectionFactoryTest.java (added)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/jndi/XAConnectionFactoryTest.java Thu Mar 18 20:02:13 2010
@@ -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();
+ }
+}
Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/jndi/XAConnectionFactoryTest.java
------------------------------------------------------------------------------
svn:eol-style = native
Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/jndi/XAConnectionFactoryTest.java
------------------------------------------------------------------------------
svn:executable = *
Propchange: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/jndi/XAConnectionFactoryTest.java
------------------------------------------------------------------------------
svn:keywords = Rev Date