summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastDomainRegistryFactory.java2
-rw-r--r--sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java6
-rw-r--r--sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/RegistryConfig.java40
-rw-r--r--sca-java-2.x/trunk/modules/domain-hazelcast/src/test/java/org/apache/tuscany/sca/endpoint/hazelcast/MultiRegTestCase.java10
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TwoNodesTestCase.java6
-rw-r--r--sca-java-2.x/trunk/testing/itest/nodes/one-jvm-hazelcast-client/src/test/java/itest/ClientTestCase.java11
6 files changed, 56 insertions, 19 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 {
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TwoNodesTestCase.java b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TwoNodesTestCase.java
index b59683b138..6205b26a8a 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TwoNodesTestCase.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/test/java/org/apache/tuscany/sca/runtime/TwoNodesTestCase.java
@@ -34,12 +34,10 @@ public class TwoNodesTestCase {
@Test
public void testInstallDeployable() throws NoSuchServiceException, NoSuchDomainException, ContributionReadException, ActivationException, ValidationException {
-// Node node1 = NodeFactory.newInstance().createNode("uri:TwoNodesTestCase?multicast=off&bind=127.0.0.1:44331");
- Node node1 = TuscanyRuntime.newInstance().createNode("uri:TwoNodesTestCase");
+ Node node1 = TuscanyRuntime.newInstance().createNode("uri:TwoNodesTestCase?multicast=off&bind=127.0.0.1:44331");
node1.installContribution("helloworld", "src/test/resources/sample-helloworld.jar", null, null, true);
-// Node node2 = NodeFactory.newInstance().createNode("uri:TwoNodesTestCase?multicast=off&bind=127.0.0.1:44332&wka=127.0.0.1:44331");
- Node node2 = TuscanyRuntime.newInstance().createNode("uri:TwoNodesTestCase");
+ Node node2 = TuscanyRuntime.newInstance().createNode("uri:TwoNodesTestCase?multicast=off&bind=127.0.0.1:44332&wka=127.0.0.1:44331");
Helloworld helloworldService = node2.getService(Helloworld.class, "HelloworldComponent");
Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
diff --git a/sca-java-2.x/trunk/testing/itest/nodes/one-jvm-hazelcast-client/src/test/java/itest/ClientTestCase.java b/sca-java-2.x/trunk/testing/itest/nodes/one-jvm-hazelcast-client/src/test/java/itest/ClientTestCase.java
index cf99c970db..a00c84edb6 100644
--- a/sca-java-2.x/trunk/testing/itest/nodes/one-jvm-hazelcast-client/src/test/java/itest/ClientTestCase.java
+++ b/sca-java-2.x/trunk/testing/itest/nodes/one-jvm-hazelcast-client/src/test/java/itest/ClientTestCase.java
@@ -24,11 +24,9 @@ import static org.junit.Assert.assertNotNull;
import static org.junit.Assert.assertTrue;
import static org.junit.Assert.fail;
-import java.net.URI;
-
+import org.apache.tuscany.sca.Node;
+import org.apache.tuscany.sca.TuscanyRuntime;
import org.apache.tuscany.sca.core.assembly.impl.RuntimeEndpointImpl;
-import org.apache.tuscany.sca.node.Node;
-import org.apache.tuscany.sca.node.NodeFactory;
import org.junit.AfterClass;
import org.junit.BeforeClass;
import org.junit.Test;
@@ -46,8 +44,9 @@ public class ClientTestCase{
@BeforeClass
public static void setUpBeforeClass() throws Exception {
- node = NodeFactory.newInstance(domainURI).createNode((String)null, new String[]{"../helloworld-service/target/classes", "../helloworld-client/target/classes"});
- node.start();
+ node = TuscanyRuntime.newInstance().createNode(domainURI);
+ node.installContribution("../helloworld-service/target/classes");
+ node.installContribution("../helloworld-client/target/classes");
}
@Test