diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/domain-hazelcast/src')
4 files changed, 49 insertions, 9 deletions
diff --git a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastDomainRegistryFactory.java b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastDomainRegistryFactory.java index 87c60e4b38..291553705b 100644 --- a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastDomainRegistryFactory.java +++ b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastDomainRegistryFactory.java @@ -40,7 +40,7 @@ public class HazelcastDomainRegistryFactory extends BaseDomainRegistryFactory { protected EndpointRegistry createEndpointRegistry(String endpointRegistryURI, String domainURI) { Properties properties = registry.getExtensionPoint(UtilityExtensionPoint.class).getUtility(RuntimeProperties.class).getProperties(); - return new HazelcastEndpointRegistry(registry, properties, domainURI); + return new HazelcastEndpointRegistry(registry, properties, endpointRegistryURI, domainURI); } public String[] getSupportedSchemes() { diff --git a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java index 004aa81816..aa97ff3a1b 100644 --- a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java +++ b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java @@ -72,8 +72,8 @@ public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements E protected Object shutdownMutex = new Object(); protected Properties properties; - public HazelcastEndpointRegistry(ExtensionPointRegistry registry, Properties properties, String domainURI) { - super(registry, null, null, domainURI); + public HazelcastEndpointRegistry(ExtensionPointRegistry registry, Properties properties, String endpointRegistryURI, String domainURI) { + super(registry, null, endpointRegistryURI, domainURI); this.assemblyFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(AssemblyFactory.class); this.properties = properties; } @@ -157,7 +157,7 @@ public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements E // TUSCANY-3675 - domainRegistryURI properties don't seem to be copied into the // properties collection anywhere config = new XmlConfigBuilder().build(); - RegistryConfig rc = new RegistryConfig(properties); + RegistryConfig rc = RegistryConfig.parseConfigURI(domainRegistryURI); config.setPort(rc.getBindPort()); //config.setPortAutoIncrement(false); diff --git a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryConfig.java b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryConfig.java index bd44e69867..4bf3d6c73a 100644 --- a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryConfig.java +++ b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryConfig.java @@ -20,7 +20,9 @@ package org.apache.tuscany.sca.endpoint.hazelcast; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; +import java.util.Map; import java.util.Properties; @@ -134,4 +136,42 @@ public class RegistryConfig { public String getPassword() { return password; } + + /** + * Parse the config string into a Properties object. + * The config URI has the following format: + * uri:<domainName>?name=value&... + */ + public static RegistryConfig parseConfigURI(String configURI) { + Properties properties = new Properties(); + int c = configURI.indexOf(':'); + if (c > -1) { + configURI = configURI.substring(c+1); + } + int qm = configURI.indexOf('?'); + if (qm < 0) { + properties.setProperty("defaultDomainName", configURI); + } else { + if (qm == 0) { + properties.setProperty("defaultDomainName", "default"); + } else { + properties.setProperty("defaultDomainName", configURI.substring(0, qm)); + } + if (configURI.length() > qm+1) { + Map<String, String> params = new HashMap<String, String>(); + for (String param : configURI.substring(qm+1).split("&")) { + String[] px = param.split("="); + if (px.length == 2) { + params.put(px[0], px[1]); + } else { + params.put(px[0], ""); + } + } + for (String name : params.keySet()) { + properties.setProperty(name, params.get(name)); + } + } + } + return new RegistryConfig(properties); + } } diff --git a/sca-java-2.x/trunk/modules/domain-hazelcast/src/test/java/org/apache/tuscany/sca/endpoint/hazelcast/MultiRegTestCase.java b/sca-java-2.x/trunk/modules/domain-hazelcast/src/test/java/org/apache/tuscany/sca/endpoint/hazelcast/MultiRegTestCase.java index 67ce2bb50b..c4f51d1675 100644 --- a/sca-java-2.x/trunk/modules/domain-hazelcast/src/test/java/org/apache/tuscany/sca/endpoint/hazelcast/MultiRegTestCase.java +++ b/sca-java-2.x/trunk/modules/domain-hazelcast/src/test/java/org/apache/tuscany/sca/endpoint/hazelcast/MultiRegTestCase.java @@ -55,7 +55,7 @@ public class MultiRegTestCase { public void testReplication() throws Exception { System.out.println("Starting reg1"); - HazelcastEndpointRegistry reg1 = new HazelcastEndpointRegistry(extensionPoints, null, null, "bar"); + HazelcastEndpointRegistry reg1 = new HazelcastEndpointRegistry(extensionPoints, (Properties)null, "tuscany:foo?bind=127.0.0.1:9876&multicast=off", "bar"); reg1.start(); System.out.println("Adding ep1"); @@ -64,11 +64,11 @@ public class MultiRegTestCase { reg1.addEndpoint(ep1); System.out.println("Starting reg3"); - HazelcastEndpointRegistry reg2 = new HazelcastEndpointRegistry(extensionPoints, null, "tuscany:foo?listen=127.0.0.1:9877&multicast=off&remotes=127.0.0.1:9876", "bar"); + HazelcastEndpointRegistry reg2 = new HazelcastEndpointRegistry(extensionPoints, (Properties)null, "tuscany:foo?bind=127.0.0.1:9877&multicast=off&wka=127.0.0.1:9876", "bar"); reg2.start(); System.out.println("Starting reg2"); - HazelcastEndpointRegistry reg3 = new HazelcastEndpointRegistry(extensionPoints, null, "tuscany:foo?listen=127.0.0.1:9878&multicast=off&remotes=127.0.0.1:9877", "bar"); + HazelcastEndpointRegistry reg3 = new HazelcastEndpointRegistry(extensionPoints, (Properties)null, "tuscany:foo?bind=127.0.0.1:9878&multicast=off&wka=127.0.0.1:9877", "bar"); reg3.start(); assertExists(reg1, "ep1uri"); @@ -116,13 +116,13 @@ public class MultiRegTestCase { @Test public void testDuplicates() throws Exception { - HazelcastEndpointRegistry reg1 = new HazelcastEndpointRegistry(extensionPoints, null, "tuscany:foo?listen=127.0.0.1:9876&multicast=off", "bar"); + HazelcastEndpointRegistry reg1 = new HazelcastEndpointRegistry(extensionPoints, (Properties)null, "tuscany:foo?bind=127.0.0.1:9876&multicast=off", "bar"); reg1.start(); RuntimeEndpoint ep1 = createEndpoint("ep1uri"); ep1.bind(extensionPoints, reg1); reg1.addEndpoint(ep1); - HazelcastEndpointRegistry reg2 = new HazelcastEndpointRegistry(extensionPoints, null, "tuscany:foo?listen=127.0.0.1:9877&multicast=off&remotes=127.0.0.1:9876", "bar"); + HazelcastEndpointRegistry reg2 = new HazelcastEndpointRegistry(extensionPoints, (Properties)null, "tuscany:foo?bind=127.0.0.1:9877&multicast=off&wka=127.0.0.1:9876", "bar"); reg2.start(); try { |