qpid-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From arnaudsi...@apache.org
Subject svn commit: r576378 - in /incubator/qpid/trunk/qpid/java/client/src: main/java/org/apache/qpid/client/ main/java/org/apache/qpid/client/url/ main/java/org/apache/qpid/jms/ test/java/org/apache/qpid/testutil/
Date Mon, 17 Sep 2007 11:31:17 GMT
Author: arnaudsimon
Date: Mon Sep 17 04:31:17 2007
New Revision: 576378

URL: http://svn.apache.org/viewvc?rev=576378&view=rev
Log:
Updated ConnectionURL

Modified:
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionURL.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser_0_10.java
    incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java
    incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidClientConnection.java

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java?rev=576378&r1=576377&r2=576378&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java
(original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionFactory.java
Mon Sep 17 04:31:17 2007
@@ -60,16 +60,26 @@
     {
     }
 
+    /**
+     * This is the Only constructor used!
+     * It is used form the context and from the JNDI objects.
+     */
     public AMQConnectionFactory(String url) throws URLSyntaxException
     {
         _connectionDetails = new AMQConnectionURL(url);
     }
 
+    /**
+     * This constructor is never used!
+     */
     public AMQConnectionFactory(ConnectionURL url)
     {
         _connectionDetails = url;
     }
 
+     /**
+     * This constructor is never used!
+     */
     public AMQConnectionFactory(String broker, String username, String password,
                                 String clientName, String virtualHost) throws URLSyntaxException
     {
@@ -78,11 +88,17 @@
                                   virtualHost + "?brokerlist='" + broker + "'"));
     }
 
+     /**
+     * This constructor is never used!
+     */
     public AMQConnectionFactory(String host, int port, String virtualPath)
     {
         this(host, port, "guest", "guest", virtualPath);
     }
 
+     /**
+     * This constructor is never used!
+     */
     public AMQConnectionFactory(String host, int port, String defaultUsername, String defaultPassword,
                                 String virtualPath)
     {
@@ -382,7 +398,7 @@
 
                 if (addr != null)
                 {
-                    return new AMQConnectionFactory(new AMQConnectionURL((String) addr.getContent()));
+                    return new AMQConnectionFactory((String) addr.getContent());
                 }
             }
 

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionURL.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionURL.java?rev=576378&r1=576377&r2=576378&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionURL.java
(original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/AMQConnectionURL.java
Mon Sep 17 04:31:17 2007
@@ -24,8 +24,10 @@
 import java.util.LinkedList;
 import java.util.List;
 import java.util.Map;
+import java.net.MalformedURLException;
 
 import org.apache.qpid.client.url.URLParser_0_8;
+import org.apache.qpid.client.url.URLParser_0_10;
 import org.apache.qpid.framing.AMQShortString;
 import org.apache.qpid.jms.BrokerDetails;
 import org.apache.qpid.jms.ConnectionURL;
@@ -67,11 +69,28 @@
             if (fullURL.startsWith("qpid"))
             {
                 //URLParser
+                URLParser_0_10 parser = null;
+                try
+                {
+                    parser = new URLParser_0_10(fullURL);
+                }
+                catch (MalformedURLException e)
+                {
+                    throw new URLSyntaxException(fullURL,e.getMessage(),0,0);
+                }
+                setBrokerDetails(parser.getAllBrokerDetails());
+                // use the first instance username and password
+                // This is temporary as the URL must be changed for olding this information
as part of the full URL
+                BrokerDetails firstBroker = getBrokerDetails(0);
+                setUsername(firstBroker.getProperty(BrokerDetails.USERNAME));
+                setPassword(firstBroker.getProperty(BrokerDetails.PASSWORD));
+                setClientName(firstBroker.getProperty(BrokerDetails.CLIENT_ID));
+                setVirtualHost(firstBroker.getProperty(BrokerDetails.VIRTUAL_HOST));
                 _urlVersion = URL_0_10;
             }
             else
             {
-                URLParser_0_8 urlParser = new URLParser_0_8(this);
+                 new URLParser_0_8(this);
                 _urlVersion = URL_0_8;
             }
         }
@@ -145,6 +164,11 @@
         {
             _brokers.add(broker);
         }
+    }
+
+    public void setBrokerDetails(List<BrokerDetails> brokers)
+    {
+        _brokers = brokers;
     }
 
     public List<BrokerDetails> getAllBrokerDetails()

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser_0_10.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser_0_10.java?rev=576378&r1=576377&r2=576378&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser_0_10.java
(original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/client/url/URLParser_0_10.java
Mon Sep 17 04:31:17 2007
@@ -96,7 +96,7 @@
 
     public URLParser_0_10(String url) throws MalformedURLException
     {
-        _url = (url + "END_OF_URL_MARKER").toCharArray();
+        _url = (url + END_OF_URL_MARKER).toCharArray();
         _endOfURL = false;
         _currentParserState = URLParserState.QPID_URL_START;
         URLParserState prevState = _currentParserState; // for error handling
@@ -402,7 +402,7 @@
 
     public static void main(String[] args)
     {
-        String testurl = "qpid:password=pass;username=name@tcp:test1,tcp:fooBroker,keystore=/usr/foo@tls:tlsBroker";
+        String testurl = "qpid:password=pass;username=name@tcp:test1";
         try
         {
             URLParser_0_10 impl = new URLParser_0_10(testurl);

Modified: incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java?rev=576378&r1=576377&r2=576378&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java
(original)
+++ incubator/qpid/trunk/qpid/java/client/src/main/java/org/apache/qpid/jms/ConnectionURL.java
Mon Sep 17 04:31:17 2007
@@ -60,6 +60,8 @@
 
     void addBrokerDetails(BrokerDetails broker);
 
+    void setBrokerDetails(List<BrokerDetails> brokers);
+
     List<BrokerDetails> getAllBrokerDetails();
 
     String getClientName();

Modified: incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidClientConnection.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidClientConnection.java?rev=576378&r1=576377&r2=576378&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidClientConnection.java
(original)
+++ incubator/qpid/trunk/qpid/java/client/src/test/java/org/apache/qpid/testutil/QpidClientConnection.java
Mon Sep 17 04:31:17 2007
@@ -75,7 +75,7 @@
             String brokerUrl = "amqp://guest:guest@" + virtualHost + "?brokerlist='" + brokerlist
+ "'";
             try
             {
-                AMQConnectionFactory factory = new AMQConnectionFactory(new AMQConnectionURL(brokerUrl));
+                AMQConnectionFactory factory = new AMQConnectionFactory(brokerUrl);
                 _logger.info("connecting to Qpid :" + brokerUrl);
                 connection = factory.createConnection();
 



Mime
View raw message