From cbccb75258e1b81c1e585a07e971efff2f617231 Mon Sep 17 00:00:00 2001 From: antelder Date: Fri, 8 Jan 2010 09:24:02 +0000 Subject: Change the Hazelcast registry to support both distributed an in-VM only operation git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@897140 13f79535-47bb-0310-9956-ffa450edef68 --- .../apache/tuscany/sca/endpoint/hazelcast/ConfigURI.java | 6 ++++++ .../endpoint/hazelcast/HazelcastEndpointRegistry.java | 16 ++++++++++------ 2 files changed, 16 insertions(+), 6 deletions(-) (limited to 'sca-java-2.x/trunk/modules/endpoint-hazelcast/src') diff --git a/sca-java-2.x/trunk/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/ConfigURI.java b/sca-java-2.x/trunk/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/ConfigURI.java index c226405696..191005eafd 100644 --- a/sca-java-2.x/trunk/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/ConfigURI.java +++ b/sca-java-2.x/trunk/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/ConfigURI.java @@ -51,8 +51,10 @@ public class ConfigURI { private String multicastAddress = "224.5.12.10"; private int multicastPort = 51482; private List remotes = new ArrayList(); + private String uri; public ConfigURI(String uri) { + this.uri = uri; parseURI(uri); } @@ -154,5 +156,9 @@ public class ConfigURI { public List getRemotes() { return remotes; } + + public String toString() { + return uri; + } } diff --git a/sca-java-2.x/trunk/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java b/sca-java-2.x/trunk/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java index 54c1d1c0a5..a65c1a9c23 100644 --- a/sca-java-2.x/trunk/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java +++ b/sca-java-2.x/trunk/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java @@ -21,6 +21,7 @@ package org.apache.tuscany.sca.endpoint.hazelcast; import java.net.UnknownHostException; import java.util.ArrayList; +import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.concurrent.CopyOnWriteArrayList; @@ -39,7 +40,6 @@ import com.hazelcast.config.TcpIpConfig; import com.hazelcast.config.XmlConfigBuilder; import com.hazelcast.core.Hazelcast; import com.hazelcast.core.HazelcastInstance; -import com.hazelcast.core.IMap; import com.hazelcast.nio.Address; /** @@ -55,7 +55,7 @@ public class HazelcastEndpointRegistry implements EndpointRegistry, LifeCycleLis private ConfigURI configURI; private HazelcastInstance hazelcastInstance; - private IMap map; + private Map map; private List localEndpoints = new ArrayList();; public HazelcastEndpointRegistry(ExtensionPointRegistry registry, @@ -70,12 +70,16 @@ public class HazelcastEndpointRegistry implements EndpointRegistry, LifeCycleLis if (map != null) { throw new IllegalStateException("The registry has already been started"); } - initHazelcastInstance(); - map = hazelcastInstance.getMap(configURI.getDomainName() + "Endpoints"); + if (configURI.toString().startsWith("tuscany:vm:")) { + map = new HashMap(); + } else { + initHazelcastInstance(); + map = hazelcastInstance.getMap(configURI.getDomainName() + "Endpoints"); + } } public void stop() { - if (map != null) { + if (hazelcastInstance != null) { hazelcastInstance.shutdown(); } } @@ -187,7 +191,7 @@ public class HazelcastEndpointRegistry implements EndpointRegistry, LifeCycleLis if (endpointReference.getReference() != null) { Endpoint targetEndpoint = endpointReference.getTargetEndpoint(); - + for (Object v : map.values()) { Endpoint endpoint = (Endpoint)v; logger.fine("Matching against - " + endpoint); -- cgit v1.2.3