From c2aa33764648853cb341ad0b9d09e0c6862b04a7 Mon Sep 17 00:00:00 2001 From: antelder Date: Mon, 6 Jun 2011 12:39:55 +0000 Subject: Add a method to the DomainRegistry to get the contribution uri for the composite taht contains a running component git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1132615 13f79535-47bb-0310-9956-ffa450edef68 --- .../hazelcast/HazelcastDomainRegistry.java | 31 +++++++++++++++++++--- .../client/HazelcastClientEndpointRegistry.java | 2 ++ 2 files changed, 29 insertions(+), 4 deletions(-) diff --git a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java index c6e3060c21..4bf120a641 100644 --- a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java +++ b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/HazelcastDomainRegistry.java @@ -101,7 +101,10 @@ public class HazelcastDomainRegistry extends BaseDomainRegistry implements Domai // key contributionURI, value map key compositeURI value compositeXML protected Map> runningComposites; + // key member, value map key contributionURI value list of compositeURI protected Map>> runningCompositeOwners; + // key componentName, value contributionURI + protected Map runningComponentContributions; protected Map endpointWsdls; protected Map localEndpoints = new ConcurrentHashMap(); @@ -148,8 +151,9 @@ public class HazelcastDomainRegistry extends BaseDomainRegistry implements Domai runningComposites = hazelcastInstance.getMap(domainURI + "/RunningComposites"); runningCompositeOwners = hazelcastInstance.getMap(domainURI + "/RunningCompositeOwners"); - - contributionDescriptions = hazelcastInstance.getMap(domainURI + "/InstalledContributions"); + runningComponentContributions = hazelcastInstance.getMap(domainURI + "/RunningComponentContributions"); + + contributionDescriptions = hazelcastInstance.getMap(domainURI + "/ContributionDescriptions"); ((IMap)contributionDescriptions).addEntryListener(new EntryListener() { public void entryAdded(EntryEvent event) { } @@ -287,6 +291,14 @@ public class HazelcastDomainRegistry extends BaseDomainRegistry implements Domai String localMemberAddr = hazelcastInstance.getCluster().getLocalMember().getInetSocketAddress().toString(); String endpointURI = endpoint.getURI(); String wsdl = getWsdl(endpoint); + String componentName = endpoint.getComponent().getName(); + String curi = null; + if (endpoint instanceof RuntimeEndpoint) { + Composite dc = ((RuntimeEndpoint)endpoint).getCompositeContext().getDomainComposite(); + if (dc != null) { + curi = dc.getContributionURI(); + } + } Transaction txn = hazelcastInstance.getTransaction(); txn.begin(); try { @@ -294,6 +306,9 @@ public class HazelcastDomainRegistry extends BaseDomainRegistry implements Domai endpointMap.put(endpointURI, endpoint); endpointWsdls.put(endpointURI, wsdl); endpointOwners.put(localMemberAddr, endpointURI); + if (curi != null) { + runningComponentContributions.put(componentName, curi); + } txn.commit(); } catch (Throwable e) { txn.rollback(); @@ -395,13 +410,14 @@ public class HazelcastDomainRegistry extends BaseDomainRegistry implements Domai synchronized (shutdownMutex) { String localMemberAddr = hazelcastInstance.getCluster().getLocalMember().getInetSocketAddress().toString(); String endpointURI = endpoint.getURI(); - + String componentName = endpoint.getComponent().getName(); Transaction txn = hazelcastInstance.getTransaction(); txn.begin(); try { endpointOwners.remove(localMemberAddr, endpointURI); endpointMap.remove(endpointURI); endpointWsdls.remove(endpointURI); + runningComponentContributions.remove(componentName); txn.commit(); } catch (Throwable e) { txn.rollback(); @@ -468,7 +484,8 @@ public class HazelcastDomainRegistry extends BaseDomainRegistry implements Domai if (endpointOwners.containsKey(memberAddr)) { Collection keys = endpointOwners.remove(memberAddr); for (Object k : keys) { - endpointMap.remove(k); + Endpoint endpoint = (Endpoint)endpointMap.remove(k); + runningComponentContributions.remove(endpoint.getComponent().getName()); endpointWsdls.remove(k); } } @@ -699,4 +716,10 @@ public class HazelcastDomainRegistry extends BaseDomainRegistry implements Domai } throw new IllegalArgumentException("member not found: " + memberName); } + + @Override + public String getContainingCompositesContributionURI(String componentName) { + int x = runningComponentContributions.size(); + return runningComponentContributions.get(componentName); + } } diff --git a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/client/HazelcastClientEndpointRegistry.java b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/client/HazelcastClientEndpointRegistry.java index 264c67c7ca..05fc47b884 100644 --- a/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/client/HazelcastClientEndpointRegistry.java +++ b/sca-java-2.x/trunk/modules/domain-hazelcast/src/main/java/org/apache/tuscany/sca/registry/hazelcast/client/HazelcastClientEndpointRegistry.java @@ -61,6 +61,8 @@ public class HazelcastClientEndpointRegistry extends HazelcastDomainRegistry { endpointMap = hazelcastClient.getMap(rc.getUserid() + "/Endpoints"); endpointOwners = hazelcastClient.getMultiMap(rc.getUserid() + "/EndpointOwners"); endpointWsdls = hazelcastClient.getMap(rc.getUserid() + "/EndpointWsdls"); + runningComponentContributions = hazelcastClient.getMap(rc.getUserid() + "/RunningComponentContributions"); + contributionDescriptions = hazelcastClient.getMap(rc.getUserid() + "/ContributionDescriptions"); } @Override -- cgit v1.2.3