diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-06-18 18:20:09 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2011-06-18 18:20:09 +0000 |
commit | c5d3f9f932075ecc7f45b866d8f1cf86537b49e0 (patch) | |
tree | 04fb993d7f75d40287b2472a4042a5e88c7f4d5f /sca-java-2.x/trunk/modules | |
parent | 7550f843640527f1ece148b804d3b3c7348027ad (diff) |
Add a method to restart started composites that depend on another composite. That so you can updated a composite and have everything thats using it pick up the changes
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1137224 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules')
2 files changed, 42 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java index 9c1d7276a8..f3f10f38d7 100644 --- a/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java +++ b/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java @@ -27,8 +27,10 @@ import java.util.Map; import javax.xml.namespace.QName; +import org.apache.tuscany.sca.assembly.Component; import org.apache.tuscany.sca.assembly.Composite; import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException; +import org.apache.tuscany.sca.assembly.impl.CompositeImpl; import org.apache.tuscany.sca.context.CompositeContext; import org.apache.tuscany.sca.contribution.Contribution; import org.apache.tuscany.sca.contribution.processor.ContributionResolveException; @@ -139,4 +141,28 @@ public class DeployedComposite { public List<String> getContributionURIs() { return usedContributionURIs; } + + public boolean uses(String contributionURI, String compositeURI) { + // TODO: builtComposite or composite? + return compositeUses(builtComposite, contributionURI, compositeURI); + } + + protected boolean compositeUses(Composite c, String contributionURI, String compositeURI) { + if (contributionURI.equals(c.getContributionURI()) && compositeURI.equals(c.getURI())) { + return true; + } + for (Composite include : ((CompositeImpl)c).getFusedIncludes()) { + if (compositeUses(include, contributionURI, compositeURI)) { + return true; + } + } + for (Component comp : c.getComponents()) { + if (comp.getImplementation() instanceof Composite) { + if (compositeUses((Composite)comp.getImplementation(), contributionURI, compositeURI)) { + return true; + } + } + } + return false; + } } 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 5855805ca4..aaafb16b85 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 @@ -442,4 +442,20 @@ public class NodeImpl implements Node { return domainRegistry.getRunningNodeName(contributionURI, compositeURI); } + public List<String> updateUsingComposites(String contributionURI, String compositeURI) throws ActivationException, ContributionReadException, ValidationException { + List<String> updated = new ArrayList<String>(); + for (DeployedComposite dc : new ArrayList<DeployedComposite>(startedComposites.values())) { + if (dc.uses(contributionURI, compositeURI)) { + String dcConttributionURI = dc.getContributionURIs().get(0); + String dcCompositeURI = dc.getURI(); + stopComposite(dcConttributionURI, dcCompositeURI); + String key = dcConttributionURI + "/" + dcCompositeURI; + stoppedComposites.remove(key); + updated.add(key); + startComposite(dcConttributionURI, dcCompositeURI); + } + } + return updated; + } + } |