tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r1137224 - in /tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl: DeployedComposite.java NodeImpl.java
Date Sat, 18 Jun 2011 18:20:10 GMT
Author: antelder
Date: Sat Jun 18 18:20:09 2011
New Revision: 1137224

URL: http://svn.apache.org/viewvc?rev=1137224&view=rev
Log:
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

Modified:
    tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java
    tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java

Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java?rev=1137224&r1=1137223&r2=1137224&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/DeployedComposite.java
Sat Jun 18 18:20:09 2011
@@ -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;
+    }
 }

Modified: tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java?rev=1137224&r1=1137223&r2=1137224&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/domain-node/src/main/java/org/apache/tuscany/sca/impl/NodeImpl.java
Sat Jun 18 18:20:09 2011
@@ -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;
+    }
+
 }



Mime
View raw message