From a225821e4c6430d83d4118ce782dca12b79133d7 Mon Sep 17 00:00:00 2001 From: antelder Date: Fri, 14 Jan 2011 07:40:46 +0000 Subject: Update to use local version of Endpoint if a local Endpoint exists git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1058877 13f79535-47bb-0310-9956-ffa450edef68 --- .../hazelcast/HazelcastEndpointRegistry.java | 35 ++++++++++++++-------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'sca-java-2.x/trunk/modules/domain-hazelcast/src') 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 6d696dfaaa..004aa81816 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 @@ -224,23 +224,28 @@ public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements E Endpoint endpoint = (Endpoint)v; logger.fine("Matching against - " + endpoint); if (endpoint.matches(uri)) { - 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()); - } - + endpoint = localizeEndpoint(endpoint); foundEndpoints.add(endpoint); logger.fine("Found endpoint with matching service - " + endpoint); } } return foundEndpoints; } + + private Endpoint localizeEndpoint(Endpoint endpoint) { + if (endpoint == null) return null; + 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()); + } + return endpoint; + } private boolean isLocal(Endpoint endpoint) { @@ -248,11 +253,15 @@ public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements E } public Endpoint getEndpoint(String uri) { - return (Endpoint)endpointMap.get(uri); + return localizeEndpoint((Endpoint)endpointMap.get(uri)); } public List getEndpoints() { - return new ArrayList(endpointMap.values()); + ArrayList eps = new ArrayList(); + for (Object ep : endpointMap.values()) { + eps.add(localizeEndpoint((Endpoint)ep)); + } + return eps; } public void removeEndpoint(Endpoint endpoint) { -- cgit v1.2.3