qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From raj...@apache.org
Subject svn commit: r1163457 - /qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java
Date Wed, 31 Aug 2011 00:24:59 GMT
Author: rajith
Date: Wed Aug 31 00:24:59 2011
New Revision: 1163457

URL: http://svn.apache.org/viewvc?rev=1163457&view=rev
Log:
QPID-3373 Applying Pavel's patch. I also added the same fix for the
createXAConnection method with user,password.

Modified:
    qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java

Modified: qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java
URL: http://svn.apache.org/viewvc/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java?rev=1163457&r1=1163456&r2=1163457&view=diff
==============================================================================
--- qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java
(original)
+++ qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java
Wed Aug 31 00:24:59 2011
@@ -113,27 +113,35 @@ public class AMQConnectionFactory implem
     
     public Connection createConnection(String userName, String password, String id) throws
JMSException
     {
-        try
+        if (_connectionDetails != null)
         {
-            _connectionDetails.setUsername(userName);
-            _connectionDetails.setPassword(password);
-            
-            if (id != null && !id.equals(""))
-            {
-                _connectionDetails.setClientName(id);
-            } 
-            else if (_connectionDetails.getClientName() == null || _connectionDetails.getClientName().equals(""))
+            try
+            {
+                ConnectionURL connectionDetails = new AMQConnectionURL(_connectionDetails.toString());
+                connectionDetails.setUsername(userName);
+                connectionDetails.setPassword(password);
+                
+                if (id != null && !id.equals(""))
+                {
+                    connectionDetails.setClientName(id);
+                } 
+                else if (connectionDetails.getClientName() == null || connectionDetails.getClientName().equals(""))
+                {
+                    connectionDetails.setClientName(getUniqueClientID());
+                }
+                return new AMQConnection(connectionDetails);
+            }
+            catch (Exception e)
             {
-                _connectionDetails.setClientName(getUniqueClientID());
+                JMSException jmse = new JMSException("Error creating connection: " + e.getMessage());
+                jmse.setLinkedException(e);
+                jmse.initCause(e);
+                throw jmse;
             }
-            return new AMQConnection(_connectionDetails);
         }
-        catch (Exception e)
+        else
         {
-            JMSException jmse = new JMSException("Error creating connection: " + e.getMessage());
-            jmse.setLinkedException(e);
-            jmse.initCause(e);
-            throw jmse;
+            throw new JMSException("The connection factory wasn't created with a proper URL,
the connection details are empty");
         }
     }
 
@@ -285,19 +293,30 @@ public class AMQConnectionFactory implem
     {
         if (_connectionDetails != null)
         {
-            _connectionDetails.setUsername(username);
-            _connectionDetails.setPassword(password);
-
-            if (_connectionDetails.getClientName() == null || _connectionDetails.getClientName().equals(""))
+            try
+            {
+                ConnectionURL connectionDetails = new AMQConnectionURL(_connectionDetails.toString());
+                connectionDetails.setUsername(username);
+                connectionDetails.setPassword(password);
+    
+                if (connectionDetails.getClientName() == null || connectionDetails.getClientName().equals(""))
+                {
+                    connectionDetails.setClientName(getUniqueClientID());
+                }
+                return new XAConnectionImpl(connectionDetails);
+            }
+            catch (Exception e)
             {
-                _connectionDetails.setClientName(getUniqueClientID());
+                JMSException jmse = new JMSException("Error creating XA Connection: " + e.getMessage());
+                jmse.setLinkedException(e);
+                jmse.initCause(e);
+                throw jmse;
             }
         }
         else
         {
-            throw new JMSException("A URL must be specified to access XA connections");
-        }
-        return createXAConnection();
+            throw new JMSException("The connection factory wasn't created with a proper URL,
the connection details are empty");
+        }        
     }
 
 



---------------------------------------------------------------------
Apache Qpid - AMQP Messaging Implementation
Project:      http://qpid.apache.org
Use/Interact: mailto:commits-subscribe@qpid.apache.org


Mime
View raw message