ARTEMIS-3894 - add conversion from string for list - allow core bridge static connector config via properties
This commit is contained in:
parent
8a6ee31055
commit
7ee820864b
|
@ -550,6 +550,17 @@ public class ConfigurationImpl implements Configuration, Serializable {
|
||||||
}
|
}
|
||||||
}, TransformerConfiguration.class);
|
}, TransformerConfiguration.class);
|
||||||
|
|
||||||
|
beanUtils.getConvertUtils().register(new Converter() {
|
||||||
|
@Override
|
||||||
|
public <T> T convert(Class<T> type, Object value) {
|
||||||
|
List convertedValue = new ArrayList<String>();
|
||||||
|
for (String entry : value.toString().split(",")) {
|
||||||
|
convertedValue.add(entry);
|
||||||
|
}
|
||||||
|
return (T) convertedValue;
|
||||||
|
}
|
||||||
|
}, java.util.List.class);
|
||||||
|
|
||||||
// support 25K or 25m etc like xml config
|
// support 25K or 25m etc like xml config
|
||||||
beanUtils.getConvertUtils().register(new Converter() {
|
beanUtils.getConvertUtils().register(new Converter() {
|
||||||
@Override
|
@Override
|
||||||
|
|
|
@ -44,6 +44,7 @@ import org.apache.activemq.artemis.core.config.amqpBrokerConnectivity.AMQPMirror
|
||||||
import org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration;
|
import org.apache.activemq.artemis.core.config.ha.LiveOnlyPolicyConfiguration;
|
||||||
import org.apache.activemq.artemis.core.deployers.impl.FileConfigurationParser;
|
import org.apache.activemq.artemis.core.deployers.impl.FileConfigurationParser;
|
||||||
import org.apache.activemq.artemis.core.security.Role;
|
import org.apache.activemq.artemis.core.security.Role;
|
||||||
|
import org.apache.activemq.artemis.core.server.ComponentConfigurationRoutingType;
|
||||||
import org.apache.activemq.artemis.core.server.JournalType;
|
import org.apache.activemq.artemis.core.server.JournalType;
|
||||||
import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
|
import org.apache.activemq.artemis.core.server.cluster.impl.MessageLoadBalancingType;
|
||||||
import org.apache.activemq.artemis.core.server.plugin.impl.LoggingActiveMQServerPlugin;
|
import org.apache.activemq.artemis.core.server.plugin.impl.LoggingActiveMQServerPlugin;
|
||||||
|
@ -630,6 +631,38 @@ public class ConfigurationImplTest extends ActiveMQTestBase {
|
||||||
Assert.assertEquals("2", configuration.getConnectionRouters().get(0).getPolicyConfiguration().getProperties().get(ConsistentHashModuloPolicy.MODULO));
|
Assert.assertEquals("2", configuration.getConnectionRouters().get(0).getPolicyConfiguration().getProperties().get(ConsistentHashModuloPolicy.MODULO));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Test
|
||||||
|
public void testCoreBridgeConfiguration() throws Throwable {
|
||||||
|
ConfigurationImpl configuration = new ConfigurationImpl();
|
||||||
|
|
||||||
|
final String queueName = "q";
|
||||||
|
final String forwardingAddress = "fa";
|
||||||
|
|
||||||
|
Properties properties = new InsertionOrderedProperties();
|
||||||
|
|
||||||
|
properties.put("bridgeConfigurations.b1.queueName", queueName);
|
||||||
|
properties.put("bridgeConfigurations.b1.forwardingAddress", forwardingAddress);
|
||||||
|
properties.put("bridgeConfigurations.b1.confirmationWindowSize", "10");
|
||||||
|
properties.put("bridgeConfigurations.b1.routingType", "STRIP"); // enum
|
||||||
|
// this is a List<String> from comma sep value
|
||||||
|
properties.put("bridgeConfigurations.b1.staticConnectors", "a,b");
|
||||||
|
// flip b in place
|
||||||
|
properties.put("bridgeConfigurations.b1.staticConnectors[1]", "c");
|
||||||
|
|
||||||
|
configuration.parsePrefixedProperties(properties, null);
|
||||||
|
|
||||||
|
Assert.assertEquals(1, configuration.getBridgeConfigurations().size());
|
||||||
|
Assert.assertEquals(queueName, configuration.getBridgeConfigurations().get(0).getQueueName());
|
||||||
|
|
||||||
|
Assert.assertEquals(forwardingAddress, configuration.getBridgeConfigurations().get(0).getForwardingAddress());
|
||||||
|
Assert.assertEquals(10, configuration.getBridgeConfigurations().get(0).getConfirmationWindowSize());
|
||||||
|
Assert.assertEquals(2, configuration.getBridgeConfigurations().get(0).getStaticConnectors().size());
|
||||||
|
Assert.assertEquals("a", configuration.getBridgeConfigurations().get(0).getStaticConnectors().get(0));
|
||||||
|
Assert.assertEquals("c", configuration.getBridgeConfigurations().get(0).getStaticConnectors().get(1));
|
||||||
|
|
||||||
|
Assert.assertEquals(ComponentConfigurationRoutingType.STRIP, configuration.getBridgeConfigurations().get(0).getRoutingType());
|
||||||
|
}
|
||||||
|
|
||||||
@Test
|
@Test
|
||||||
public void testSetNestedPropertyOnCollections() throws Throwable {
|
public void testSetNestedPropertyOnCollections() throws Throwable {
|
||||||
ConfigurationImpl configuration = new ConfigurationImpl();
|
ConfigurationImpl configuration = new ConfigurationImpl();
|
||||||
|
|
Loading…
Reference in New Issue