diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-03-18 12:25:22 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-03-18 12:25:22 +0000 |
commit | e6dd2473820de18188524ddb6f31e8b9bb4ebfa2 (patch) | |
tree | 4e859e15e179e2805d07dc53ab38a38fccc4e60e /sca-java-2.x/trunk/modules/endpoint-hazelcast | |
parent | 8424b53e9dda12b0b39819e827badd3fd0a1f6a0 (diff) |
Add a method to get the Hazelcast member owning an endpoint
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@924744 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/endpoint-hazelcast')
-rw-r--r-- | sca-java-2.x/trunk/modules/endpoint-hazelcast/src/main/java/org/apache/tuscany/sca/endpoint/hazelcast/HazelcastEndpointRegistry.java | 21 |
1 files changed, 21 insertions, 0 deletions
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 e794fde8e6..35cab29479 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 @@ -27,8 +27,10 @@ import java.util.List; import java.util.Map;
import java.util.logging.Logger;
+import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.assembly.Endpoint;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.core.LifeCycleListener;
import org.apache.tuscany.sca.runtime.BaseEndpointRegistry;
import org.apache.tuscany.sca.runtime.DomainRegistryURI;
@@ -65,6 +67,7 @@ public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements E protected Map<Object, Object> endpointMap;
private Map<String, Endpoint> localEndpoints = new HashMap<String, Endpoint>();
private MultiMap<String, String> endpointOwners;
+ private AssemblyFactory assemblyFactory;
public HazelcastEndpointRegistry(ExtensionPointRegistry registry,
Map<String, String> attributes,
@@ -72,6 +75,7 @@ public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements E String domainURI) {
super(registry, attributes, domainRegistryURI, domainURI);
this.configURI = new DomainRegistryURI(domainRegistryURI);
+ this.assemblyFactory = registry.getExtensionPoint(FactoryExtensionPoint.class).getFactory(AssemblyFactory.class);
}
public HazelcastInstance getHazelcastInstance() {
@@ -292,4 +296,21 @@ public class HazelcastEndpointRegistry extends BaseEndpointRegistry implements E }
}
}
+
+ public Member getOwningMember(String serviceURI) {
+ for (String memberAddr : endpointOwners.keySet()) {
+ for (String service : endpointOwners.get(memberAddr)) {
+ Endpoint ep = assemblyFactory.createEndpoint();
+ ep.setURI(service);
+ if (ep.matches(serviceURI)) {
+ for (Member m : hazelcastInstance.getCluster().getMembers()) {
+ if (memberAddr.equals(m.getInetSocketAddress().toString())) {
+ return m;
+ }
+ }
+ }
+ }
+ }
+ return null;
+ }
}
|