ARTEMIS-882 Supporting lists on URIs
This commit is contained in:
parent
6682072da6
commit
dc472192f4
|
@ -289,7 +289,7 @@ public final class ActiveMQClient {
|
||||||
*/
|
*/
|
||||||
public static ServerLocator createServerLocator(final String url) throws Exception {
|
public static ServerLocator createServerLocator(final String url) throws Exception {
|
||||||
ServerLocatorParser parser = new ServerLocatorParser();
|
ServerLocatorParser parser = new ServerLocatorParser();
|
||||||
return parser.newObject(new URI(url), null);
|
return parser.newObject(parser.expandURI(url), null);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|
|
@ -397,7 +397,9 @@ public final class ServerLocatorImpl implements ServerLocatorInternal, Discovery
|
||||||
|
|
||||||
public static ServerLocator newLocator(String uri) {
|
public static ServerLocator newLocator(String uri) {
|
||||||
try {
|
try {
|
||||||
return newLocator(new URI(uri));
|
ServerLocatorParser parser = new ServerLocatorParser();
|
||||||
|
URI newURI = parser.expandURI(uri);
|
||||||
|
return parser.newObject(newURI, null);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
throw new RuntimeException(e);
|
throw new RuntimeException(e);
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,8 @@ import org.apache.activemq.artemis.utils.IPV6Util;
|
||||||
import org.apache.activemq.artemis.utils.uri.BeanSupport;
|
import org.apache.activemq.artemis.utils.uri.BeanSupport;
|
||||||
import org.apache.activemq.artemis.utils.uri.SchemaConstants;
|
import org.apache.activemq.artemis.utils.uri.SchemaConstants;
|
||||||
|
|
||||||
public class TCPServerLocatorSchema extends AbstractServerLocatorSchema {
|
public class
|
||||||
|
TCPServerLocatorSchema extends AbstractServerLocatorSchema {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getSchemaName() {
|
public String getSchemaName() {
|
||||||
|
@ -45,9 +46,9 @@ public class TCPServerLocatorSchema extends AbstractServerLocatorSchema {
|
||||||
TransportConfiguration[] tcs = new TransportConfiguration[configurations.size()];
|
TransportConfiguration[] tcs = new TransportConfiguration[configurations.size()];
|
||||||
configurations.toArray(tcs);
|
configurations.toArray(tcs);
|
||||||
if (options.isHa()) {
|
if (options.isHa()) {
|
||||||
return ActiveMQClient.createServerLocatorWithHA(tcs);
|
return BeanSupport.setData(uri, ActiveMQClient.createServerLocatorWithHA(tcs), query);
|
||||||
} else {
|
} else {
|
||||||
return ActiveMQClient.createServerLocatorWithoutHA(tcs);
|
return BeanSupport.setData(uri, ActiveMQClient.createServerLocatorWithoutHA(tcs), query);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -204,7 +204,7 @@ public class ActiveMQConnectionFactory implements ConnectionFactoryOptions, Exte
|
||||||
public ActiveMQConnectionFactory(String url) {
|
public ActiveMQConnectionFactory(String url) {
|
||||||
ConnectionFactoryParser cfParser = new ConnectionFactoryParser();
|
ConnectionFactoryParser cfParser = new ConnectionFactoryParser();
|
||||||
try {
|
try {
|
||||||
URI uri = new URI(url);
|
URI uri = cfParser.expandURI(url);
|
||||||
serverLocator = ServerLocatorImpl.newLocator(uri);
|
serverLocator = ServerLocatorImpl.newLocator(uri);
|
||||||
cfParser.populateObject(uri, this);
|
cfParser.populateObject(uri, this);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
|
|
|
@ -0,0 +1,46 @@
|
||||||
|
/**
|
||||||
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
||||||
|
* contributor license agreements. See the NOTICE file distributed with
|
||||||
|
* this work for additional information regarding copyright ownership.
|
||||||
|
* The ASF licenses this file to You under the Apache License, Version 2.0
|
||||||
|
* (the "License"); you may not use this file except in compliance with
|
||||||
|
* the License. You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package org.apache.activemq.artemis.tests.integration.jms;
|
||||||
|
|
||||||
|
import org.apache.activemq.artemis.api.core.client.ActiveMQClient;
|
||||||
|
import org.apache.activemq.artemis.api.core.client.ServerLocator;
|
||||||
|
import org.apache.activemq.artemis.api.jms.ActiveMQJMSClient;
|
||||||
|
import org.apache.activemq.artemis.core.client.impl.ServerLocatorImpl;
|
||||||
|
import org.apache.activemq.artemis.jms.client.ActiveMQConnectionFactory;
|
||||||
|
import org.junit.Assert;
|
||||||
|
import org.junit.Test;
|
||||||
|
|
||||||
|
public class URITest {
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testParseURIs() throws Throwable {
|
||||||
|
ActiveMQConnectionFactory factory = ActiveMQJMSClient.createConnectionFactory("(tcp://localhost:61616,tcp://localhost:61617)?blockOnDurableSend=false", "some name");
|
||||||
|
Assert.assertEquals(2, ((ServerLocatorImpl) factory.getServerLocator()).getInitialConnectors().length);
|
||||||
|
|
||||||
|
ActiveMQConnectionFactory factory2 = new ActiveMQConnectionFactory("(tcp://localhost:61614,tcp://localhost:61616)?blockOnDurableSend=false");
|
||||||
|
Assert.assertEquals(2, ((ServerLocatorImpl) factory2.getServerLocator()).getInitialConnectors().length);
|
||||||
|
|
||||||
|
ServerLocator locator = ServerLocatorImpl.newLocator("(tcp://localhost:61616,tcp://localhost:61617)?blockOnDurableSend=false");
|
||||||
|
Assert.assertEquals(2, ((ServerLocatorImpl) locator).getInitialConnectors().length);
|
||||||
|
|
||||||
|
ServerLocator locator2 = ActiveMQClient.createServerLocator("(tcp://localhost:61616,tcp://localhost:61617)?blockOnDurableSend=false");
|
||||||
|
Assert.assertEquals(2, ((ServerLocatorImpl) locator2).getInitialConnectors().length);
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
Loading…
Reference in New Issue