summaryrefslogtreecommitdiffstats
path: root/sca-java-2.x/trunk/modules/domain-node/src
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2011-03-04 13:08:02 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2011-03-04 13:08:02 +0000
commitcfa2416a6c75e850285f2d82427cb2eeb3f669e4 (patch)
tree3622639a3193f8cc5b466480c20776945c5e1ae9 /sca-java-2.x/trunk/modules/domain-node/src
parentdc0367752d9be0707346c8a3c56f3407eba416de (diff)
Update to use a map instead of a list to store the start composites to make the lookup easier
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1077928 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules/domain-node/src')
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/InstalledContribution.java23
-rw-r--r--sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java11
2 files changed, 13 insertions, 21 deletions
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/InstalledContribution.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/InstalledContribution.java
index 750a13f81a..d3a2526ab9 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/InstalledContribution.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/InstalledContribution.java
@@ -34,7 +34,7 @@ public class InstalledContribution {
private String url;
private Contribution contribution;
private List<Composite> defaultDeployables = new ArrayList<Composite>();
- private List<DeployedComposite> startededComposites = new ArrayList<DeployedComposite>();
+ private Map<String, DeployedComposite> startedComposites = new HashMap<String, DeployedComposite>();
private Map<String, DeployedComposite> stoppedComposites = new HashMap<String, DeployedComposite>();
private List<String> dependentContributionURIs;
@@ -60,33 +60,30 @@ public class InstalledContribution {
public List<Composite> getDefaultDeployables() {
return defaultDeployables;
}
- public List<DeployedComposite> getDeployedComposites() {
- return startededComposites;
+ public List<String> getStartedCompositeURIs() {
+ return new ArrayList<String>(startedComposites.keySet());
}
public List<String> getDependentContributionURIs() {
return dependentContributionURIs;
}
public void stop(String compositeURI) throws ActivationException {
- for (DeployedComposite dc : getDeployedComposites()) {
- if (compositeURI.equals(dc.getURI())) {
- getDeployedComposites().remove(dc);
- dc.stop();
- stoppedComposites.put(compositeURI, dc);
- return;
- }
+ DeployedComposite dc = startedComposites.remove(compositeURI);
+ if (dc == null) {
+ throw new IllegalStateException("composite not deployed: " + compositeURI);
}
- throw new IllegalStateException("composite not deployed: " + compositeURI);
+ dc.stop();
+ stoppedComposites.put(compositeURI, dc);
}
public void start(DeployedComposite composite) {
- startededComposites.add(composite);
+ startedComposites.put(composite.getURI(), composite);
}
public boolean restart(String compositeURI) throws ActivationException {
DeployedComposite dc = stoppedComposites.remove(compositeURI);
if (dc != null) {
dc.start();
- startededComposites.add(dc);
+ startedComposites.put(dc.getURI(), dc);
}
return dc != null;
}
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
index 2e0c4fea02..19e05f9408 100644
--- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
+++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
@@ -232,10 +232,9 @@ public class NodeImpl implements Node {
removedContributionURIs.addAll(removeContribution(dependent));
}
installedContributions.remove(contributionURI);
- for (DeployedComposite dc : ic.getDeployedComposites()) {
- dc.stop();
+ for (String compositeURI : ic.getStartedCompositeURIs()) {
+ ic.stop(compositeURI);
}
- ic.getDeployedComposites().clear();
}
return removedContributionURIs;
}
@@ -404,15 +403,11 @@ public class NodeImpl implements Node {
}
public List<String> getStartedCompositeURIs(String contributionURI) {
- ArrayList<String> compositeURIs = new ArrayList<String>();
InstalledContribution ic = installedContributions.get(contributionURI);
if (ic == null) {
throw new IllegalArgumentException("no contribution found for: " + contributionURI);
}
- for (DeployedComposite dc : ic.getDeployedComposites()) {
- compositeURIs.add(dc.getURI());
- }
- return compositeURIs;
+ return ic.getStartedCompositeURIs();
}
public List<String> getInstalledContributionURIs() {