activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From gtu...@apache.org
Subject svn commit: r1360125 - in /activemq/trunk/activemq-core/src: main/java/org/apache/activemq/jndi/ActiveMQInitialContextFactory.java test/java/org/apache/activemq/jndi/InitialContextTest.java
Date Wed, 11 Jul 2012 11:36:20 GMT
Author: gtully
Date: Wed Jul 11 11:36:20 2012
New Revision: 1360125

URL: http://svn.apache.org/viewvc?rev=1360125&view=rev
Log:
https://issues.apache.org/jira/browse/AMQ-2656 - add wellknown xa factory name, XAConnectionFactory
so that context.lookup("XAConnectionFactory") will work as expected out of the box

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/jndi/ActiveMQInitialContextFactory.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/jndi/InitialContextTest.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=1360125&r1=1360124&r2=1360125&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
Wed Jul 11 11:36:20 2012
@@ -48,7 +48,7 @@ import org.apache.activemq.command.Activ
  */
 public class ActiveMQInitialContextFactory implements InitialContextFactory {
 
-    private static final String[] DEFAULT_CONNECTION_FACTORY_NAMES = {"ConnectionFactory",
"QueueConnectionFactory", "TopicConnectionFactory"};
+    private static final String[] DEFAULT_CONNECTION_FACTORY_NAMES = {"ConnectionFactory",
"XAConnectionFactory", "QueueConnectionFactory", "TopicConnectionFactory"};
 
     private String connectionPrefix = "connection.";
     private String queuePrefix = "queue.";
@@ -127,6 +127,10 @@ public class ActiveMQInitialContextFacto
 
     protected ActiveMQConnectionFactory createConnectionFactory(String name, Hashtable environment)
throws URISyntaxException {
         Hashtable temp = new Hashtable(environment);
+        if (DEFAULT_CONNECTION_FACTORY_NAMES[1].equals(name)) {
+            // don't try to mod environment, it may be readonly
+            temp.put("xa", String.valueOf(true));
+        }
         String prefix = connectionPrefix + name + ".";
         for (Iterator iter = environment.entrySet().iterator(); iter.hasNext();) {
             Map.Entry entry = (Map.Entry)iter.next();

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/jndi/InitialContextTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/jndi/InitialContextTest.java?rev=1360125&r1=1360124&r2=1360125&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/jndi/InitialContextTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/jndi/InitialContextTest.java
Wed Jul 11 11:36:20 2012
@@ -23,6 +23,7 @@ import javax.naming.InitialContext;
 
 import junit.framework.TestCase;
 import org.apache.activemq.ActiveMQConnectionFactory;
+import org.apache.activemq.ActiveMQXAConnectionFactory;
 import org.slf4j.Logger;
 import org.slf4j.LoggerFactory;
 
@@ -45,6 +46,18 @@ public class InitialContextTest extends 
 
     }
 
+    public void testInitialContextHasXA() throws Exception {
+        InitialContext context = new InitialContext();
+        assertTrue("Created context", context != null);
+
+        ActiveMQXAConnectionFactory connectionFactory = (ActiveMQXAConnectionFactory)context.lookup("XAConnectionFactory");
+
+        assertTrue("Should have created an XAConnectionFactory", connectionFactory != null);
+
+        LOG.info("Created with brokerURL: " + connectionFactory.getBrokerURL());
+
+    }
+
     public void testUsingStandardJNDIKeys() throws Exception {
         Properties properties = new Properties();
         properties.put(Context.INITIAL_CONTEXT_FACTORY, "org.apache.activemq.jndi.ActiveMQInitialContextFactory");



Mime
View raw message