diff options
Diffstat (limited to 'sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany')
-rw-r--r-- | sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java | 35 |
1 files changed, 22 insertions, 13 deletions
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<Endpoint> getEndpoints() { - return new ArrayList(endpointMap.values()); + ArrayList<Endpoint> eps = new ArrayList(); + for (Object ep : endpointMap.values()) { + eps.add(localizeEndpoint((Endpoint)ep)); + } + return eps; } public void removeEndpoint(Endpoint endpoint) { |