From 07fd00e4e80df89e0ea34a41700c021ba0c00650 Mon Sep 17 00:00:00 2001 From: slaws Date: Tue, 23 Feb 2010 15:21:10 +0000 Subject: TUSCANY-3473 - where a local call (local interface) is used within a contribution but where the hazelcast registry is in operation I've updated the registry to return the actual endpoint rather than the serialized version so that the endpoint isn't marked as remote and so that the interface contract is intact. This also adds and enables a test case that ensures that this is working. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@915379 13f79535-47bb-0310-9956-ffa450edef68 --- .../endpoint/hazelcast/HazelcastEndpointRegistry.java | 17 ++++++++++++----- 1 file changed, 12 insertions(+), 5 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/HazelcastEndpointRegistry.java b/sca-java-2.x/trunk/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java index d921ec3a48..88a45bbf4c 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 @@ -58,7 +58,7 @@ public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements E private HazelcastInstance hazelcastInstance; protected Map map; - private List localEndpoints = new ArrayList(); + private Map localEndpoints = new HashMap(); public HazelcastEndpointRegistry(ExtensionPointRegistry registry, Map attributes, @@ -138,7 +138,7 @@ public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements E public void addEndpoint(Endpoint endpoint) { map.put(endpoint.getURI(), endpoint); - localEndpoints.add(endpoint.getURI()); + localEndpoints.put(endpoint.getURI(), endpoint); logger.info("Add endpoint - " + endpoint); } @@ -150,8 +150,15 @@ public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements E if (matches(uri, endpoint.getURI())) { if (!isLocal(endpoint)) { endpoint.setRemote(true); + ((RuntimeEndpoint)endpoint).bind(registry, this); + } else { + // get the local version of the endpoint + // this local version won't have been serialized + // won't be marked as remote and will have the + // full interface contract information + endpoint = localEndpoints.get(endpoint.getURI()); } - ((RuntimeEndpoint)endpoint).bind(registry, this); + foundEndpoints.add(endpoint); logger.fine("Found endpoint with matching service - " + endpoint); } @@ -161,7 +168,7 @@ public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements E private boolean isLocal(Endpoint endpoint) { - return localEndpoints.contains(endpoint.getURI()); + return localEndpoints.containsKey(endpoint.getURI()); } public Endpoint getEndpoint(String uri) { @@ -200,7 +207,7 @@ public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements E if (!isLocal(newEp)) { logger.info(" Remote endpoint added: " + newEp); newEp.setRemote(true); - } + } endpointAdded(newEp); } -- cgit v1.2.3