activemq-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From dej...@apache.org
Subject svn commit: r984826 - in /activemq/trunk: activemq-core/src/main/java/org/apache/activemq/broker/ activemq-core/src/main/java/org/apache/activemq/network/ activemq-core/src/main/java/org/apache/activemq/transport/ activemq-core/src/main/java/org/apache...
Date Thu, 12 Aug 2010 15:16:48 GMT
Author: dejanb
Date: Thu Aug 12 15:16:47 2010
New Revision: 984826

URL: http://svn.apache.org/viewvc?rev=984826&view=rev
Log:
https://issues.apache.org/activemq/browse/AMQ-2598 - URISupport.parseParameters() now supports
composite urls

Modified:
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DiscoveryNetworkConnector.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/TransportFactory.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgentFactory.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/rendezvous/RendezvousDiscoveryAgentFactory.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/peer/PeerTransportFactory.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/SslTransportFactory.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/udp/UdpTransportFactory.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java
    activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/URISupport.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/discovery/DiscoveryTransportNoBrokerTest.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TcpFaultyTransportFactory.java
    activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/URISupportTest.java
    activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/discovery/http/HTTPDiscoveryAgentFactory.java

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java?rev=984826&r1=984825&r2=984826&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/BrokerService.java
Thu Aug 12 15:16:47 2010
@@ -327,7 +327,7 @@ public class BrokerService implements Se
     public NetworkConnector addNetworkConnector(NetworkConnector connector) throws Exception
{
         connector.setBrokerService(this);
         URI uri = getVmConnectorURI();
-        Map<String, String> map = new HashMap<String, String>(URISupport.parseParamters(uri));
+        Map<String, String> map = new HashMap<String, String>(URISupport.parseParameters(uri));
         map.put("network", "true");
         uri = URISupport.createURIWithQuery(uri, URISupport.createQueryString(map));
         connector.setLocalUri(uri);
@@ -2065,7 +2065,7 @@ public class BrokerService implements Se
                 setTransportConnectors(al);
             }
             URI uri = getVmConnectorURI();
-            Map<String, String> map = new HashMap<String, String>(URISupport.parseParamters(uri));
+            Map<String, String> map = new HashMap<String, String>(URISupport.parseParameters(uri));
             map.put("network", "true");
             map.put("async", "false");
             uri = URISupport.createURIWithQuery(uri, URISupport.createQueryString(map));

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java?rev=984826&r1=984825&r2=984826&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/broker/TransportConnection.java
Thu Aug 12 15:16:47 2010
@@ -1201,7 +1201,7 @@ public class TransportConnection impleme
                 IntrospectionSupport.setProperties(config, props, "");
                 config.setBrokerName(broker.getBrokerName());
                 URI uri = broker.getVmConnectorURI();
-                HashMap<String, String> map = new HashMap<String, String>(URISupport.parseParamters(uri));
+                HashMap<String, String> map = new HashMap<String, String>(URISupport.parseParameters(uri));
                 map.put("network", "true");
                 map.put("async", "false");
                 uri = URISupport.createURIWithQuery(uri, URISupport.createQueryString(map));

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DiscoveryNetworkConnector.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DiscoveryNetworkConnector.java?rev=984826&r1=984825&r2=984826&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DiscoveryNetworkConnector.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/network/DiscoveryNetworkConnector.java
Thu Aug 12 15:16:47 2010
@@ -63,12 +63,7 @@ public class DiscoveryNetworkConnector e
     public void setUri(URI discoveryURI) throws IOException {
         setDiscoveryAgent(DiscoveryAgentFactory.createDiscoveryAgent(discoveryURI));
         try {
-            CompositeData data = URISupport.parseComposite(discoveryURI);
-            parameters = new HashMap<String, String>();
-            parameters.putAll(data.getParameters());
-            for (URI uri : data.getComponents()) {
-                parameters.putAll(URISupport.parseParamters(uri));
-            }
+            parameters = URISupport.parseParameters(discoveryURI);
             // allow discovery agent to grab it's parameters
             IntrospectionSupport.setProperties(getDiscoveryAgent(), parameters);
         } catch (URISyntaxException e) {
@@ -102,6 +97,7 @@ public class DiscoveryNetworkConnector e
             }
             URI connectUri = uri;
             try {
+                connectUri = URISupport.removeQuery(connectUri);
                 connectUri = URISupport.applyParameters(connectUri, parameters);
             } catch (URISyntaxException e) {
                 LOG.warn("could not apply query parameters: " + parameters + " to: " + connectUri,
e);

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/TransportFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/TransportFactory.java?rev=984826&r1=984825&r2=984826&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/TransportFactory.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/TransportFactory.java
Thu Aug 12 15:16:47 2010
@@ -136,7 +136,7 @@ public abstract class TransportFactory {
 
     public Transport doConnect(URI location) throws Exception {
         try {
-            Map<String, String> options = new HashMap<String, String>(URISupport.parseParamters(location));
+            Map<String, String> options = new HashMap<String, String>(URISupport.parseParameters(location));
             WireFormat wf = createWireFormat(options);
             Transport transport = createTransport(location, wf);
             Transport rc = configure(transport, wf, options);
@@ -151,7 +151,7 @@ public abstract class TransportFactory {
 
     public Transport doCompositeConnect(URI location) throws Exception {
         try {
-            Map<String, String> options = new HashMap<String, String>(URISupport.parseParamters(location));
+            Map<String, String> options = new HashMap<String, String>(URISupport.parseParameters(location));
             WireFormat wf = createWireFormat(options);
             Transport transport = createTransport(location, wf);
             Transport rc = compositeConfigure(transport, wf, options);

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgentFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgentFactory.java?rev=984826&r1=984825&r2=984826&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgentFactory.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/multicast/MulticastDiscoveryAgentFactory.java
Thu Aug 12 15:16:47 2010
@@ -46,7 +46,7 @@ public class MulticastDiscoveryAgentFact
                         
             // allow MDA's params to be set via query arguments  
             // (e.g., multicast://default?group=foo             
-            Map options = URISupport.parseParamters(uri);         
+            Map options = URISupport.parseParameters(uri);         
             IntrospectionSupport.setProperties(mda, options);
             
             return mda;

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/rendezvous/RendezvousDiscoveryAgentFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/rendezvous/RendezvousDiscoveryAgentFactory.java?rev=984826&r1=984825&r2=984826&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/rendezvous/RendezvousDiscoveryAgentFactory.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/discovery/rendezvous/RendezvousDiscoveryAgentFactory.java
Thu Aug 12 15:16:47 2010
@@ -30,7 +30,7 @@ public class RendezvousDiscoveryAgentFac
 
     protected DiscoveryAgent doCreateDiscoveryAgent(URI uri) throws IOException {
         try {
-            Map options = URISupport.parseParamters(uri);
+            Map options = URISupport.parseParameters(uri);
             RendezvousDiscoveryAgent rc = new RendezvousDiscoveryAgent();
             rc.setGroup(uri.getHost());
             IntrospectionSupport.setProperties(rc, options);

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/peer/PeerTransportFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/peer/PeerTransportFactory.java?rev=984826&r1=984825&r2=984826&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/peer/PeerTransportFactory.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/peer/PeerTransportFactory.java
Thu Aug 12 15:16:47 2010
@@ -69,7 +69,7 @@ public class PeerTransportFactory extend
                 broker = ID_GENERATOR.generateSanitizedId();
             }
 
-            final Map<String, String> brokerOptions = new HashMap<String, String>(URISupport.parseParamters(location));
+            final Map<String, String> brokerOptions = new HashMap<String, String>(URISupport.parseParameters(location));
             if (!brokerOptions.containsKey("persistent")) {
                 brokerOptions.put("persistent", "false");
             }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/SslTransportFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/SslTransportFactory.java?rev=984826&r1=984825&r2=984826&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/SslTransportFactory.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/SslTransportFactory.java
Thu Aug 12 15:16:47 2010
@@ -71,7 +71,7 @@ public class SslTransportFactory extends
      */
     public TransportServer doBind(final URI location) throws IOException {
         try {
-            Map<String, String> options = new HashMap<String, String>(URISupport.parseParamters(location));
+            Map<String, String> options = new HashMap<String, String>(URISupport.parseParameters(location));
 
             ServerSocketFactory serverSocketFactory = createServerSocketFactory();
             SslTransportServer server = new SslTransportServer(this, location, (SSLServerSocketFactory)serverSocketFactory);

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java?rev=984826&r1=984825&r2=984826&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/tcp/TcpTransportFactory.java
Thu Aug 12 15:16:47 2010
@@ -49,7 +49,7 @@ public class TcpTransportFactory extends
 
     public TransportServer doBind(final URI location) throws IOException {
         try {
-            Map<String, String> options = new HashMap<String, String>(URISupport.parseParamters(location));
+            Map<String, String> options = new HashMap<String, String>(URISupport.parseParameters(location));
 
             ServerSocketFactory serverSocketFactory = createServerSocketFactory();
             TcpTransportServer server = createTcpTransportServer(location, serverSocketFactory);

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/udp/UdpTransportFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/udp/UdpTransportFactory.java?rev=984826&r1=984825&r2=984826&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/udp/UdpTransportFactory.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/udp/UdpTransportFactory.java
Thu Aug 12 15:16:47 2010
@@ -53,7 +53,7 @@ public class UdpTransportFactory extends
     
     public TransportServer doBind(final URI location) throws IOException {
         try {
-            Map<String, String> options = new HashMap<String, String>(URISupport.parseParamters(location));
+            Map<String, String> options = new HashMap<String, String>(URISupport.parseParameters(location));
             if (options.containsKey("port")) {
                 throw new IllegalArgumentException("The port property cannot be specified
on a UDP server transport - please use the port in the URI syntax");
             }

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java?rev=984826&r1=984825&r2=984826&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java
(original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/transport/vm/VMTransportFactory.java
Thu Aug 12 15:16:47 2010
@@ -77,7 +77,7 @@ public class VMTransportFactory extends 
             // form
             try {
                 host = extractHost(location);
-                options = URISupport.parseParamters(location);
+                options = URISupport.parseParameters(location);
                 String config = (String)options.remove("brokerConfig");
                 if (config != null) {
                     brokerURI = new URI(config);

Modified: activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/URISupport.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/URISupport.java?rev=984826&r1=984825&r2=984826&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/URISupport.java (original)
+++ activemq/trunk/activemq-core/src/main/java/org/apache/activemq/util/URISupport.java Thu
Aug 12 15:16:47 2010
@@ -124,8 +124,21 @@ public class URISupport {
         }
     }
 
-    public static Map<String, String> parseParamters(URI uri) throws URISyntaxException
{
-        return uri.getQuery() == null ? emptyMap() : parseQuery(stripPrefix(uri.getQuery(),
"?"));
+    public static Map<String, String> parseParameters(URI uri) throws URISyntaxException
{
+        if (uri.getQuery() != null) {
+            return uri.getQuery() == null ? emptyMap() : parseQuery(stripPrefix(uri.getQuery(),
"?"));
+        } else {
+            CompositeData data = URISupport.parseComposite(uri);
+            Map<String, String> parameters = new HashMap<String, String>();
+            parameters.putAll(data.getParameters());
+            for (URI component : data.getComponents()) {
+                parameters.putAll(component.getQuery() == null ? emptyMap() : parseQuery(stripPrefix(component.getQuery(),
"?")));
+            }
+            if (parameters.isEmpty()) 
+                parameters = emptyMap();
+            
+            return parameters;
+        }
     }
 
     public static URI applyParameters(URI uri, Map<String, String> queryParameters)
throws URISyntaxException {

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/discovery/DiscoveryTransportNoBrokerTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/discovery/DiscoveryTransportNoBrokerTest.java?rev=984826&r1=984825&r2=984826&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/discovery/DiscoveryTransportNoBrokerTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/discovery/DiscoveryTransportNoBrokerTest.java
Thu Aug 12 15:16:47 2010
@@ -131,7 +131,7 @@ public class DiscoveryTransportNoBrokerT
         assertEquals("expected added URI after discovery event", compositeTransport.getTransportURIs().length,
1);
         
         URI discoveredServiceURI = compositeTransport.getTransportURIs()[0];
-        Map<String, String> parameters = URISupport.parseParamters(discoveredServiceURI);
+        Map<String, String> parameters = URISupport.parseParameters(discoveredServiceURI);
         assertTrue("unable to add parameter to discovered service", parameters.containsKey(extraParameterName));
         assertEquals("incorrect value for parameter added to discovered service", parameters.get(extraParameterName),
extraParameterValue);
     }

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TcpFaultyTransportFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TcpFaultyTransportFactory.java?rev=984826&r1=984825&r2=984826&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TcpFaultyTransportFactory.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/transport/tcp/TcpFaultyTransportFactory.java
Thu Aug 12 15:16:47 2010
@@ -80,7 +80,7 @@ public class TcpFaultyTransportFactory e
 
     public TransportServer doBind(final URI location) throws IOException {
         try {
-            Map<String, String> options = new HashMap<String, String>(URISupport.parseParamters(location));
+            Map<String, String> options = new HashMap<String, String>(URISupport.parseParameters(location));
 
             ServerSocketFactory serverSocketFactory = createServerSocketFactory();
             TcpFaultyTransportServer server = createTcpFaultyTransportServer(location, serverSocketFactory);

Modified: activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/URISupportTest.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/URISupportTest.java?rev=984826&r1=984825&r2=984826&view=diff
==============================================================================
--- activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/URISupportTest.java
(original)
+++ activemq/trunk/activemq-core/src/test/java/org/apache/activemq/util/URISupportTest.java
Thu Aug 12 15:16:47 2010
@@ -56,7 +56,7 @@ public class URISupportTest extends Test
         CompositeData data = URISupport.parseComposite(new URI("test:(part1://host?part1=true)?outside=true"));
         assertEquals(1, data.getComponents().length);
         assertEquals(1, data.getParameters().size());
-        Map part1Params = URISupport.parseParamters(data.getComponents()[0]);
+        Map part1Params = URISupport.parseParameters(data.getComponents()[0]);
         assertEquals(1, part1Params.size());
         assertTrue(part1Params.containsKey("part1"));
     }
@@ -64,7 +64,7 @@ public class URISupportTest extends Test
     public void testParsingURI() throws Exception {
         URI source = new URI("tcp://localhost:61626/foo/bar?cheese=Edam&x=123");
         
-        Map map = URISupport.parseParamters(source);
+        Map map = URISupport.parseParameters(source);
     
         assertEquals("Size: " + map, 2, map.size());
         assertMapKey(map, "cheese", "Edam");
@@ -96,10 +96,24 @@ public class URISupportTest extends Test
         URI source = new URI("vm://localhost");
         URI dest = URISupport.createURIWithQuery(source, "network=true&one=two");
         
-        assertEquals("correct param count", 2, URISupport.parseParamters(dest).size());
+        assertEquals("correct param count", 2, URISupport.parseParameters(dest).size());
         assertEquals("same uri, host", source.getHost(), dest.getHost());
         assertEquals("same uri, scheme", source.getScheme(), dest.getScheme());
         assertFalse("same uri, ssp", dest.getQuery().equals(source.getQuery()));
     }
     
+    public void testParsingParams() throws Exception {
+        URI uri = new URI("static:(http://localhost:61617?proxyHost=localhost&proxyPort=80)");
+        Map<String,String>parameters = URISupport.parseParameters(uri);
+        verifyParams(parameters);
+        uri = new URI("static://http://localhost:61617?proxyHost=localhost&proxyPort=80");
+        parameters = URISupport.parseParameters(uri);
+        verifyParams(parameters);
+    }
+    
+    private void verifyParams(Map<String,String> parameters) {
+        assertEquals(parameters.get("proxyHost"), "localhost");
+        assertEquals(parameters.get("proxyPort"), "80");
+    }
+    
 }

Modified: activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/discovery/http/HTTPDiscoveryAgentFactory.java
URL: http://svn.apache.org/viewvc/activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/discovery/http/HTTPDiscoveryAgentFactory.java?rev=984826&r1=984825&r2=984826&view=diff
==============================================================================
--- activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/discovery/http/HTTPDiscoveryAgentFactory.java
(original)
+++ activemq/trunk/activemq-optional/src/main/java/org/apache/activemq/transport/discovery/http/HTTPDiscoveryAgentFactory.java
Thu Aug 12 15:16:47 2010
@@ -31,7 +31,7 @@ public class HTTPDiscoveryAgentFactory e
     protected DiscoveryAgent doCreateDiscoveryAgent(URI uri) throws IOException {
         try {
             
-            Map options = URISupport.parseParamters(uri);
+            Map options = URISupport.parseParameters(uri);
             uri = URISupport.removeQuery(uri);
             
             HTTPDiscoveryAgent rc = new HTTPDiscoveryAgent();



Mime
View raw message