You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@qpid.apache.org by ar...@apache.org on 2007/08/20 11:37:02 UTC

svn commit: r567627 - in /incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity: BrokerDetails.java BrokerDetailsImpl.java url/QpidURL.java url/QpidURLImpl.java

Author: arnaudsimon
Date: Mon Aug 20 02:37:02 2007
New Revision: 567627

URL: http://svn.apache.org/viewvc?rev=567627&view=rev
Log:
Updated QpidURL scheme 

Modified:
    incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/BrokerDetails.java
    incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/BrokerDetailsImpl.java
    incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/url/QpidURL.java
    incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/url/QpidURLImpl.java

Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/BrokerDetails.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/BrokerDetails.java?rev=567627&r1=567626&r2=567627&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/BrokerDetails.java (original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/BrokerDetails.java Mon Aug 20 02:37:02 2007
@@ -130,7 +130,7 @@
     /**
      * Sets the properties associated with this connection
      * 
-     * @param props
+     * @param props the new p[roperties. 
      */
     public void setProperties(Map<String,String> props);
     

Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/BrokerDetailsImpl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/BrokerDetailsImpl.java?rev=567627&r1=567626&r2=567627&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/BrokerDetailsImpl.java (original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/BrokerDetailsImpl.java Mon Aug 20 02:37:02 2007
@@ -32,19 +32,20 @@
 
     //---- The brker details
     private String _host;
-    private int _port;
+    private int _port = 0;
     private String _virtualHost;
     private String _userName = DEFAULT_USERNAME;
     private String _password = DEFAULT_PASSWORD;
     private String _protocol;
-    private Map<String,String> _props = new HashMap<String,String>();;
-    
+    private Map<String, String> _props = new HashMap<String, String>();
+    ;
+
     //--- Constructors
 
     public BrokerDetailsImpl()
-    {        
+    {
     }
-    
+
     /**
      * Create a new broker details given all the reuqired information
      *
@@ -56,7 +57,7 @@
      * @param password    The user password.
      */
     public BrokerDetailsImpl(String protocol, String host, int port, String virtualHost, String userName,
-                             String password,Map<String,String> props)
+                             String password, Map<String, String> props)
     {
         _protocol = protocol;
         _host = host;
@@ -72,20 +73,12 @@
      * default values are used for the other details.
      *
      * @param protocol The protocol used for this broker connection
-     * @param host The host name.
+     * @param host     The host name.
      */
     public BrokerDetailsImpl(String protocol, String host)
     {
         _protocol = protocol;
         _host = host;
-        if (protocol.equals(BrokerDetails.PROTOCOL_TCP))
-        {
-            _port = 1234;
-        }
-        else if (protocol.equals(BrokerDetails.PROTOCOL_TLS))
-        {
-            _port = 5555;
-        }
         _virtualHost = DEFAULT_VIRTUALHOST;
         _userName = DEFAULT_USERNAME;
         _password = DEFAULT_PASSWORD;
@@ -119,6 +112,17 @@
      */
     public int getPort()
     {
+        if (_port == 0)
+        {
+            if (getProtocol().equals(BrokerDetails.PROTOCOL_TCP))
+            {
+                _port = 1234;
+            }
+            else if (getProtocol().equals(BrokerDetails.PROTOCOL_TLS))
+            {
+                _port = 5555;
+            }
+        }
         return _port;
     }
 
@@ -211,50 +215,50 @@
     {
         _protocol = protocol;
     }
-    
+
     /**
      * Ex: keystore path
-     * 
+     *
      * @return the Properties associated with this connection.
      */
-    public Map<String,String> getProperties()
+    public Map<String, String> getProperties()
     {
         return _props;
     }
-    
+
     /**
      * Sets the properties associated with this connection
-     * 
+     *
      * @param props
      */
-    public void setProperties(Map<String,String> props)
+    public void setProperties(Map<String, String> props)
     {
         _props = props;
     }
-    
-    public void setProperty(String key,String value)
+
+    public void setProperty(String key, String value)
     {
         _props.put(key, value);
     }
-    
+
     public String toString()
     {
         StringBuilder b = new StringBuilder();
         b.append("[username=" + _userName);
         b.append(",password=" + _password);
-        b.append(",transport="+ _protocol);
+        b.append(",transport=" + _protocol);
         b.append(",host=" + _host);
-        b.append(",port=" + _port + "]");
+        b.append(",port=" + getPort() + "]");
         b.append(" - Properties[");
         if (_props != null)
         {
-            for (String k:_props.keySet())
+            for (String k : _props.keySet())
             {
                 b.append(k + "=" + _props.get(k) + ",");
             }
         }
         b.append("]");
-        
+
         return b.toString();
     }
 }

Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/url/QpidURL.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/url/QpidURL.java?rev=567627&r1=567626&r2=567627&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/url/QpidURL.java (original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/url/QpidURL.java Mon Aug 20 02:37:02 2007
@@ -24,7 +24,7 @@
 /**
  * The format of the Qpid URL is based on the AMQP one.
  * The grammar is as follows:
- * <p> qpid_url          = "qpid:" prot_addr_list ["/" future-parameters]
+ * <p> qpid_url          = "qpid:" [user_props] prot_addr_list ["/" future-parameters]
  * <p> prot_addr_list 	 = [prot_addr ","]* prot_addr
  * <p> prot_addr         = tcp_prot_addr | tls_prot_addr | future_prot_addr
  * <p> tcp_prot_addr     = tcp_id tcp_addr

Modified: incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/url/QpidURLImpl.java
URL: http://svn.apache.org/viewvc/incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/url/QpidURLImpl.java?rev=567627&r1=567626&r2=567627&view=diff
==============================================================================
--- incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/url/QpidURLImpl.java (original)
+++ incubator/qpid/trunk/qpid/java/common/src/main/java/org/apache/qpidity/url/QpidURLImpl.java Mon Aug 20 02:37:02 2007
@@ -27,60 +27,66 @@
 /**
  * The format Qpid URL is based on the AMQP one.
  * The grammar is as follows:
- * <p> qpid_url          = "qpid:" port_addr_list ["/" future-parameters]
+ * <p> qpid_url          = "qpid:" [client_props "@"] port_addr_list ["/" future-parameters]
  * <p> port_addr_list 	 = [port_addr ","]* port_addr
  * <p> port_addr         = tcp_port_addr | tls_prot_addr | future_prot_addr
  * <p> tcp_port_addr     = tcp_id tcp_addr
  * <p> tcp_id            = "tcp:" | ""
- * <p> tcp_addr          = [host [":" port] ]
- * <p> host              = <as per [2]>
+ * <p> tcp_addr          = host [":" port]
+ * <p> host              = <as per http://www.apps.ietf.org/>
  * <p> port              = number
  * <p> tls_prot_addr     = tls_id tls_addr
  * <p> tls_id            = "tls:" | ""
- * <p> tls_addr          = [host [":" port] ]
+ * <p> tls_addr          = host [":" port]
  * <p> future_prot_addr  = future_prot_id future_prot_addr
  * <p> future_prot_id    = <placeholder, must end in ":". Example "sctp:">
  * <p> future_prot_addr  = <placeholder, protocl-specific address>
  * <p> future_parameters = <placeholder, not used in failover addresses>
- * 
- * Ex: qpid:virtualhost=test@client_id1:tcp:myhost.com:5672,virtualhost=prod,keystore=/opt/keystore@client_id2:tls:mysecurehost.com:5672
+ * <p> client_props      = [client_prop ";"]*  client_prop
+ * <p> client_prop       = prop "=" val
+ * <p> prop              = chars as per <as per http://www.apps.ietf.org/>
+ * <p> val               = valid as per <as per http://www.apps.ietf.org/>
+ * <p/>
+ * Ex: qpid:virtualhost=tcp:host-foo,test,client_id=foo@tcp:myhost.com:5672,virtualhost=prod;
+ * keystore=/opt/keystore@client_id2@tls:mysecurehost.com:5672
  */
 public class QpidURLImpl implements QpidURL
 {
-    private static final char[] URL_START_SEQ = new char[]{'q','p','i','d',':'}; 
+    private static final char[] URL_START_SEQ = new char[]{'q', 'p', 'i', 'd', ':'};
     private static final char PROPERTY_EQUALS_CHAR = '=';
-    private static final char PROPERTY_SEPARATOR_CHAR = ',';
+    private static final char PROPERTY_SEPARATOR_CHAR = ';';
     private static final char ADDRESS_SEPERATOR_CHAR = ',';
-    private static final char CLIENT_ID_TRANSPORT_SEPARATOR_CHAR = ':';
+
+    //private static final char CLIENT_ID_TRANSPORT_SEPARATOR_CHAR = ':';
     private static final char TRANSPORT_HOST_SEPARATOR_CHAR = ':';
     private static final char HOST_PORT_SEPARATOR_CHAR = ':';
     private static final char AT_CHAR = '@';
-    
+
     enum URLParserState
     {
-       QPID_URL_START,       
-       ADDRESS_START,
-       PROPERTY_NAME,
-       PROPERTY_EQUALS,
-       PROPERTY_VALUE,
-       PROPERTY_SEPARATOR,
-       AT_CHAR,
-       CLIENT_ID,
-       CLIENT_ID_TRANSPORT_SEPARATOR,
-       TRANSPORT,
-       TRANSPORT_HOST_SEPARATOR,
-       HOST,
-       HOST_PORT_SEPARATOR,
-       PORT,
-       ADDRESS_END,
-       ADDRESS_SEPERATOR,
-       QPID_URL_END,
-       ERROR;
+        QPID_URL_START,
+        ADDRESS_START,
+        PROPERTY_NAME,
+        PROPERTY_EQUALS,
+        PROPERTY_VALUE,
+        PROPERTY_SEPARATOR,
+        AT_CHAR,
+        //   CLIENT_ID,
+        //   CLIENT_ID_TRANSPORT_SEPARATOR,
+        TRANSPORT,
+        TRANSPORT_HOST_SEPARATOR,
+        HOST,
+        HOST_PORT_SEPARATOR,
+        PORT,
+        ADDRESS_END,
+        ADDRESS_SEPERATOR,
+        QPID_URL_END,
+        ERROR
     }
-       
+
     //-- Constructors
-    
-    private char[] _url;    
+
+    private char[] _url;
     private List<BrokerDetails> _brokerDetailList = new ArrayList<BrokerDetails>();
     private String _error;
     private int _index = 0;
@@ -88,315 +94,367 @@
     private String _currentPropName;
     private boolean _endOfURL = false;
     private URLParserState _currentParserState;
-    
+
     public QpidURLImpl(String url) throws MalformedURLException
-    {    
+    {
         _url = url.toCharArray();
         _endOfURL = false;
         _currentParserState = URLParserState.QPID_URL_START;
         URLParserState prevState = _currentParserState; // for error handling        
-        BrokerDetails _brokerDetails = new BrokerDetailsImpl();
         try
-        {   
-            while ( _currentParserState != URLParserState.ERROR && _currentParserState != URLParserState.QPID_URL_END)
+        {
+            while (_currentParserState != URLParserState.ERROR && _currentParserState != URLParserState.QPID_URL_END)
             {
                 prevState = _currentParserState;
                 _currentParserState = next();
-            }   
-            
-            if(_currentParserState == URLParserState.ERROR)
+            }
+
+            if (_currentParserState == URLParserState.ERROR)
             {
-                _error = "Invalid URL format [current_state = " +  prevState + ", broker details parsed so far " + _currentBroker + " ] error at (" + _index +") due to " + _error;            
-                MalformedURLException ex = new MalformedURLException(_error);
+                _error =
+                        "Invalid URL format [current_state = " + prevState + ", broker details parsed so far " + _currentBroker + " ] error at (" + _index + ") due to " + _error;
+                MalformedURLException ex;
+                ex = new MalformedURLException(_error);
                 throw ex;
             }
         }
-        catch(ArrayIndexOutOfBoundsException e)
+        catch (ArrayIndexOutOfBoundsException e)
         {
-            _error = "Invalid URL format [current_state = " +  prevState + ", broker details parsed so far " + _currentBroker + " ] error at (" + _index +")";            
-            MalformedURLException ex = new MalformedURLException(_error);
+            e.printStackTrace();
+            _error =
+                    "Invalid URL format [current_state = " + prevState + ", broker details parsed so far " + _currentBroker + " ] error at (" + _index + ")";
+            MalformedURLException ex;
+            ex = new MalformedURLException(_error);
             throw ex;
         }
     }
-    
+
     //-- interface QpidURL
     public List<BrokerDetails> getAllBrokerDetails()
     {
         return _brokerDetailList;
     }
 
-     public String getURL()
-     {
-         return new String(_url);
-     }
-     
-     private URLParserState next()
-     {
-         switch(_currentParserState)      
-         {
-         case QPID_URL_START:             
-             return checkSequence(URL_START_SEQ,URLParserState.ADDRESS_START);
-         case ADDRESS_START:
-             return startAddress();
-         case PROPERTY_NAME:    
-             return extractPropertyName();
-         case PROPERTY_EQUALS:   
-             _index++; // skip the equal sign
-             return URLParserState.PROPERTY_VALUE;
-         case PROPERTY_VALUE:    
-             return extractPropertyValue();
-         case PROPERTY_SEPARATOR:
-             _index++; // skip ","
-             return URLParserState.PROPERTY_NAME;
-         case AT_CHAR:
-             _index++; // skip the @ sign
-         case CLIENT_ID:    
-             return extractClientId();
-         case CLIENT_ID_TRANSPORT_SEPARATOR:
-             _index++; // skip ":"
-             return URLParserState.TRANSPORT;
-         case TRANSPORT:    
-             return extractTransport();
-         case TRANSPORT_HOST_SEPARATOR:
-             _index++; // skip ":"
-             return URLParserState.HOST;
-         case HOST:
-             return extractHost();
-         case HOST_PORT_SEPARATOR:
-             _index++; // skip ":"
-             return URLParserState.PORT;
-         case PORT:
-             extractPort();
-         case ADDRESS_END:
-             return endAddress();
-         case ADDRESS_SEPERATOR:
-             _index++; // skip ","
-             return URLParserState.ADDRESS_START;
-         default:
-             return URLParserState.ERROR;
-         }
-     }
-     
-     private URLParserState checkSequence(char[] expected,URLParserState nextPart)
-     {   
-         for(int i=0;i<expected.length;i++)
-         {
-             if(expected[i] != _url[_index])
-             {
-                 _error = "Excepted (" + expected[i] + ") at position " + _index + ", got (" + _url[_index] + ")";
-                 return URLParserState.ERROR;
-             }
-             _index++;
-         }
-         return nextPart;
-     }   
-     
-     private URLParserState startAddress()
-     {
-         _currentBroker = new BrokerDetailsImpl();
-         return URLParserState.PROPERTY_NAME;
-     }
-     
-     private URLParserState endAddress()
-     {
-         _brokerDetailList.add(_currentBroker);
-         if(_endOfURL)
-         {
-             return URLParserState.QPID_URL_END;
-         }
-         else
-         {
-             return URLParserState.ADDRESS_SEPERATOR;
-         }
-     }
-     
-     private URLParserState extractPropertyName()
-     {
-         StringBuilder b = new StringBuilder();
-         char next = _url[_index];
-         while(next != PROPERTY_EQUALS_CHAR && next != AT_CHAR)
-         {
-             b.append(next);
-             next = _url[++_index];
-         }
-         _currentPropName = b.toString();         
-         if(_currentPropName.trim().equals(""))
-         {
-             _error = "Property name cannot be empty";
-             return URLParserState.ERROR;
-         }
-         else if (next == PROPERTY_EQUALS_CHAR)
-         {
-             return URLParserState.PROPERTY_EQUALS;
-         }
-         else
-         {
-             return URLParserState.AT_CHAR;
-         }
-     }
-     
-     private URLParserState extractPropertyValue()
-     {
-         StringBuilder b = new StringBuilder();
-         char next = _url[_index];
-         while(next != PROPERTY_SEPARATOR_CHAR && next != AT_CHAR)
-         {
-             b.append(next);
-             next = _url[++_index];
-         }
-         String propValue = b.toString();
-         if(propValue.trim().equals(""))
-         {
-             _error = "Property values cannot be empty";
-             return URLParserState.ERROR;
-         }
-         else
-         {
-             _currentBroker.setProperty(_currentPropName, propValue);
-             if (next == PROPERTY_SEPARATOR_CHAR)
-             {
-                 return URLParserState.PROPERTY_SEPARATOR;
-             }
-             else
-             {
-                 return URLParserState.AT_CHAR;
-             }
-         }
-     }
-     
-     private URLParserState extractClientId()
-     {
-         //Check if atleast virtualhost is there
-         if (_currentBroker.getProperties().get(BrokerDetails.VIRTUAL_HOST) == null)
-         {
-             _error = "Virtual host is a mandatory property";
-             return URLParserState.ERROR;
-         }
-         else
-         {
-             _currentBroker.setVirtualHost(_currentBroker.getProperties().get(BrokerDetails.VIRTUAL_HOST));
-             _currentBroker.getProperties().remove(BrokerDetails.VIRTUAL_HOST);
-         }
-         
-         if (_currentBroker.getProperties().get(BrokerDetails.USERNAME) != null)
-         {
-             String username = _currentBroker.getProperties().get(BrokerDetails.USERNAME);
-             _currentBroker.setUserName(username);
-         }
-         if (_currentBroker.getProperties().get(BrokerDetails.PASSWORD) != null)
-         {
-             String password = _currentBroker.getProperties().get(BrokerDetails.PASSWORD);
-             _currentBroker.setPassword(password);
-         }
-         
-         String clientId = buildUntil(CLIENT_ID_TRANSPORT_SEPARATOR_CHAR);
-         if (clientId.trim().equals(""))
-         {
-             _error = "Client Id cannot be empty";
-             return URLParserState.ERROR;
-         }
-         else
-         {
-             _currentBroker.setProperty(BrokerDetails.CLIENT_ID, clientId);
-             return URLParserState.CLIENT_ID_TRANSPORT_SEPARATOR;
-         }
-     }
-     
-     private URLParserState extractTransport()
-     {
-         String transport = buildUntil(TRANSPORT_HOST_SEPARATOR_CHAR);
-         if (transport.trim().equals(""))
-         {
-             _error = "Transport cannot be empty";
-             return URLParserState.ERROR;
-         }
-         else
-         {
-             _currentBroker.setProtocol(transport);
-             return URLParserState.TRANSPORT_HOST_SEPARATOR;
-         }
-     }
-     
-     private URLParserState extractHost()
-     {
-         String host = buildUntil(HOST_PORT_SEPARATOR_CHAR);
-         if (host.trim().equals(""))
-         {
-             _error = "Host cannot be empty";
-             return URLParserState.ERROR;
-         }
-         else
-         {
-             _currentBroker.setHost(host);
-             return URLParserState.HOST_PORT_SEPARATOR;
-         }
-     }
-     
-     private URLParserState extractPort()
-     {
-         
-         StringBuilder b = new StringBuilder();
-         try
-         {
-             char next = _url[_index];
-             while(next != ADDRESS_SEPERATOR_CHAR)
-             {
-                 b.append(next);
-                 next = _url[++_index];
-             }
-         }
-         catch(ArrayIndexOutOfBoundsException e)
-         {
-             _endOfURL = true;
-         }         
-         String portStr = b.toString();
-         if (portStr.trim().equals(""))
-         {
-             _error = "Host cannot be empty";
-             return URLParserState.ERROR;
-         }         
-         else
-         {
-             try
-             {
-                 int port = Integer.parseInt(portStr);
-                 _currentBroker.setPort(port);
-                 return URLParserState.ADDRESS_END;
-             }
-             catch(NumberFormatException e)
-             {
-                 _error = "Illegal number for port";
-                 return URLParserState.ERROR;
-             }
-         }
-     }
-     
-     private String buildUntil(char c)
-     {
-         StringBuilder b = new StringBuilder();
-         char next = _url[_index];
-         while(next != c)
-         {
-             b.append(next);
-             next = _url[++_index];
-         }
-         return b.toString();
-     }
-     
-     public static void main(String[] args)
-     {
-         String testurl = "qpid:virtualhost=test@client_id1:tcp:myhost.com:5672,virtualhost=prod,keystore=/opt/keystore@client_id2:tls:mysecurehost.com:5672";
-         try
-         {
-             QpidURLImpl impl = new QpidURLImpl(testurl);
-             for (BrokerDetails d : impl.getAllBrokerDetails())
-             {
-                 System.out.println(d);
-             }
-         }
-         catch(Exception e)
-         {
-             e.printStackTrace();
-         }
-     }
+    public String getURL()
+    {
+        return new String(_url);
+    }
+
+    private URLParserState next()
+    {
+        switch (_currentParserState)
+        {
+            case QPID_URL_START:
+                return checkSequence(URL_START_SEQ, URLParserState.ADDRESS_START);
+            case ADDRESS_START:
+                return startAddress();
+            case PROPERTY_NAME:
+                return extractPropertyName();
+            case PROPERTY_EQUALS:
+                _index++; // skip the equal sign
+                return URLParserState.PROPERTY_VALUE;
+            case PROPERTY_VALUE:
+                return extractPropertyValue();
+            case PROPERTY_SEPARATOR:
+                _index++; // skip ","
+                return URLParserState.PROPERTY_NAME;
+            case AT_CHAR:
+                _index++; // skip the @ sign
+                return setProperties();
+                // case CLIENT_ID:
+                //     return extractClientId();
+                //  case CLIENT_ID_TRANSPORT_SEPARATOR:
+                //      _index++; // skip ":"
+                //      return URLParserState.TRANSPORT;
+            case TRANSPORT:
+                return extractTransport();
+            case TRANSPORT_HOST_SEPARATOR:
+                _index++; // skip ":"
+                return URLParserState.HOST;
+            case HOST:
+                return extractHost();
+            case HOST_PORT_SEPARATOR:
+                _index++; // skip ":"
+                return URLParserState.PORT;
+            case PORT:
+                return extractPort();
+            case ADDRESS_END:
+                return endAddress();
+            case ADDRESS_SEPERATOR:
+                _index++; // skip ","
+                return URLParserState.ADDRESS_START;
+            default:
+                return URLParserState.ERROR;
+        }
+    }
+
+    private URLParserState checkSequence(char[] expected, URLParserState nextPart)
+    {
+        for (char anExpected : expected)
+        {
+            if (anExpected != _url[_index])
+            {
+                _error = "Excepted (" + anExpected + ") at position " + _index + ", got (" + _url[_index] + ")";
+                return URLParserState.ERROR;
+            }
+            _index++;
+        }
+        return nextPart;
+    }
+
+    private URLParserState startAddress()
+    {
+        _currentBroker = new BrokerDetailsImpl();
+        // check that there is a "@" before the nexte ","
+        for (int j = _index; j < _url.length; j++)
+        {
+            if (_url[j] == AT_CHAR)
+            {
+                return URLParserState.PROPERTY_NAME;
+            }
+            else if (_url[j] == ADDRESS_SEPERATOR_CHAR)
+            {
+                return URLParserState.TRANSPORT;
+            }
+        }
+        return URLParserState.TRANSPORT;
+    }
+
+    private URLParserState endAddress()
+    {
+        _brokerDetailList.add(_currentBroker);
+        if (_endOfURL)
+        {
+            return URLParserState.QPID_URL_END;
+        }
+        else
+        {
+            return URLParserState.ADDRESS_SEPERATOR;
+        }
+    }
+
+    private URLParserState extractPropertyName()
+    {
+        StringBuilder b = new StringBuilder();
+        char next = _url[_index];
+        while (next != PROPERTY_EQUALS_CHAR && next != AT_CHAR)
+        {
+            b.append(next);
+            next = _url[++_index];
+        }
+        _currentPropName = b.toString();
+        if (_currentPropName.trim().equals(""))
+        {
+            _error = "Property name cannot be empty";
+            return URLParserState.ERROR;
+        }
+        else if (next == PROPERTY_EQUALS_CHAR)
+        {
+            return URLParserState.PROPERTY_EQUALS;
+        }
+        else
+        {
+            return URLParserState.AT_CHAR;
+        }
+    }
+
+    private URLParserState extractPropertyValue()
+    {
+        StringBuilder b = new StringBuilder();
+        char next = _url[_index];
+        while (next != PROPERTY_SEPARATOR_CHAR && next != AT_CHAR)
+        {
+            b.append(next);
+            next = _url[++_index];
+        }
+        String propValue = b.toString();
+        if (propValue.trim().equals(""))
+        {
+            _error = "Property values cannot be empty";
+            return URLParserState.ERROR;
+        }
+        else
+        {
+            _currentBroker.setProperty(_currentPropName, propValue);
+            if (next == PROPERTY_SEPARATOR_CHAR)
+            {
+                return URLParserState.PROPERTY_SEPARATOR;
+            }
+            else
+            {
+                return URLParserState.AT_CHAR;
+            }
+        }
+    }
+
+    private URLParserState setProperties()
+    {
+        //Check if atleast virtualhost is there
+        if (_currentBroker.getProperties().get(BrokerDetails.VIRTUAL_HOST) != null)
+        {
+            _currentBroker.setVirtualHost(_currentBroker.getProperties().get(BrokerDetails.VIRTUAL_HOST));
+            _currentBroker.getProperties().remove(BrokerDetails.VIRTUAL_HOST);
+        }
+
+        if (_currentBroker.getProperties().get(BrokerDetails.USERNAME) != null)
+        {
+            String username = _currentBroker.getProperties().get(BrokerDetails.USERNAME);
+            _currentBroker.setUserName(username);
+        }
+        if (_currentBroker.getProperties().get(BrokerDetails.PASSWORD) != null)
+        {
+            String password = _currentBroker.getProperties().get(BrokerDetails.PASSWORD);
+            _currentBroker.setPassword(password);
+        }
+        if (_currentBroker.getProperties().get(BrokerDetails.CLIENT_ID) != null)
+        {
+            String clientID = _currentBroker.getProperties().get(BrokerDetails.CLIENT_ID);
+            _currentBroker.setProperty(BrokerDetails.CLIENT_ID, clientID);
+        }
+        return URLParserState.TRANSPORT;
+    }
+
+    private URLParserState extractTransport()
+    {
+        String transport = buildUntil(TRANSPORT_HOST_SEPARATOR_CHAR);
+        if (transport.trim().equals(""))
+        {
+            _error = "Transport cannot be empty";
+            return URLParserState.ERROR;
+        }
+        else if (!(transport.trim().equals(BrokerDetails.PROTOCOL_TCP) || transport.trim()
+                .equals(BrokerDetails.PROTOCOL_TLS)))
+        {
+            _error = "Transport cannot be " + transport + " value must be tcp or tls";
+            return URLParserState.ERROR;
+        }
+        else
+        {
+            _currentBroker.setProtocol(transport);
+            return URLParserState.TRANSPORT_HOST_SEPARATOR;
+        }
+    }
+
+    private URLParserState extractHost()
+    {
+        char nextSep = 'c';
+        String host;
+        for (int i = _index; i < _url.length; i++)
+        {
+            if (_url[i] == HOST_PORT_SEPARATOR_CHAR)
+            {
+                nextSep = HOST_PORT_SEPARATOR_CHAR;
+                break;
+            }
+            else if (_url[i] == ADDRESS_SEPERATOR_CHAR)
+            {
+                nextSep = ADDRESS_SEPERATOR_CHAR;
+                break;
+            }
+        }
+        if (nextSep == HOST_PORT_SEPARATOR_CHAR)
+        {
+            host = buildUntil(HOST_PORT_SEPARATOR_CHAR);
+            if (host.trim().equals(""))
+            {
+                _error = "Host cannot be empty";
+                return URLParserState.ERROR;
+            }
+            else
+            {
+                _currentBroker.setHost(host);
+                return URLParserState.HOST_PORT_SEPARATOR;
+            }
+        }
+        else if (nextSep == ADDRESS_SEPERATOR_CHAR)
+        {
+            host = buildUntil(ADDRESS_SEPERATOR_CHAR);
+            if (host.trim().equals(""))
+            {
+                _error = "Host cannot be empty";
+                return URLParserState.ERROR;
+            }
+            else
+            {
+                _currentBroker.setHost(host);
+                return URLParserState.ADDRESS_END;
+            }
+        }
+        else
+        {
+            host = String.copyValueOf(_url, _index, _url.length - _index);
+            _currentBroker.setHost(host);
+            _endOfURL = true;
+            return URLParserState.ADDRESS_END;
+        }
+    }
+
+
+    private URLParserState extractPort()
+    {
+
+        StringBuilder b = new StringBuilder();
+        try
+        {
+            char next = _url[_index];
+            while (next != ADDRESS_SEPERATOR_CHAR)
+            {
+                b.append(next);
+                next = _url[++_index];
+            }
+        }
+        catch (ArrayIndexOutOfBoundsException e)
+        {
+            _endOfURL = true;
+        }
+        String portStr = b.toString();
+        if (portStr.trim().equals(""))
+        {
+            _error = "Host cannot be empty";
+            return URLParserState.ERROR;
+        }
+        else
+        {
+            try
+            {
+                int port = Integer.parseInt(portStr);
+                _currentBroker.setPort(port);
+                return URLParserState.ADDRESS_END;
+            }
+            catch (NumberFormatException e)
+            {
+                _error = "Illegal number for port";
+                return URLParserState.ERROR;
+            }
+        }
+    }
+
+    private String buildUntil(char c)
+    {
+        StringBuilder b = new StringBuilder();
+        char next = _url[_index];
+        while (next != c)
+        {
+            b.append(next);
+            next = _url[++_index];
+        }
+        return b.toString();
+    }
+
+    public static void main(String[] args)
+    {
+        String testurl = "qpid:password=pass;username=name@tcp:test1,tcp:fooBroker,keystore=/usr/foo@tls:tlsBroker";
+        try
+        {
+            QpidURLImpl impl = new QpidURLImpl(testurl);
+            for (BrokerDetails d : impl.getAllBrokerDetails())
+            {
+                System.out.println(d);
+            }
+        }
+        catch (Exception e)
+        {
+            e.printStackTrace();
+        }
+    }
 }