diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-06-08 10:43:41 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2009-06-08 10:43:41 +0000 |
commit | 081650ead4099bea3723c041ab2f9c04364e8f6b (patch) | |
tree | f655f273ac3418064de66af6a8e90d7180043831 /java/sca/modules/node-api/src/main | |
parent | fd57cb165e71a45a460f0ede0d83f450e5a041e6 (diff) |
Update the SCAClient impl to work with multiple nodes in a domain
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@782588 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/node-api/src/main')
-rw-r--r-- | java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFinder.java | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFinder.java b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFinder.java index f81906af89..27926a0115 100644 --- a/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFinder.java +++ b/java/sca/modules/node-api/src/main/java/org/apache/tuscany/sca/node/NodeFinder.java @@ -20,22 +20,38 @@ package org.apache.tuscany.sca.node;
import java.net.URI;
+import java.util.ArrayList;
import java.util.HashMap;
+import java.util.List;
import java.util.Map;
public class NodeFinder {
- private static Map<URI, Node> nodes = new HashMap<URI, Node>();
+ private static Map<URI, List<Node>> nodes = new HashMap<URI, List<Node>>();
public static void addNode(URI domainName, Node node) {
- nodes.put(domainName, node);
+ List<Node> domainNodes = nodes.get(domainName);
+ if (domainNodes == null) {
+ domainNodes = new ArrayList<Node>();
+ }
+ domainNodes.add(node);
+ nodes.put(domainName, domainNodes);
}
- public static Node removeNode(URI domainName) {
- return nodes.remove(domainName);
+ public static Node removeNode(Node node) {
+ for (List<Node> domainNodes : nodes.values()) {
+ if (domainNodes.contains(node)) {
+ domainNodes.remove(node);
+ if (domainNodes.size() < 1) {
+ nodes.remove(domainNodes);
+ }
+ return node;
+ }
+ }
+ return null;
}
- public static Node getNode(URI domainURI) {
+ public static List<Node> getNodes(URI domainURI) {
return nodes.get(domainURI);
}
|