tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r573852 - in /incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/node/impl: ContributionManagerImpl.java NodeImpl.java
Date Sat, 08 Sep 2007 15:08:21 GMT
Author: antelder
Date: Sat Sep  8 08:08:21 2007
New Revision: 573852

URL: http://svn.apache.org/viewvc?rev=573852&view=rev
Log:
Add methods to start supporting multiple contributions

Modified:
    incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/node/impl/ContributionManagerImpl.java
    incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/node/impl/NodeImpl.java

Modified: incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/node/impl/ContributionManagerImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/node/impl/ContributionManagerImpl.java?rev=573852&r1=573851&r2=573852&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/node/impl/ContributionManagerImpl.java
(original)
+++ incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/node/impl/ContributionManagerImpl.java
Sat Sep  8 08:08:21 2007
@@ -20,27 +20,18 @@
 package org.apache.tuscany.sca.distributed.node.impl;
 
 import java.io.IOException;
+import java.io.InputStream;
 import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-import java.util.concurrent.CopyOnWriteArrayList;
 
-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.contribution.Contribution;
 import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.contribution.resolver.impl.ModelResolverImpl;
 import org.apache.tuscany.sca.contribution.service.ContributionException;
 import org.apache.tuscany.sca.contribution.service.ContributionService;
 import org.apache.tuscany.sca.core.assembly.ActivationException;
-import org.apache.tuscany.sca.core.assembly.RuntimeComponentImpl;
-import org.apache.tuscany.sca.distributed.domain.Domain;
 import org.apache.tuscany.sca.distributed.node.ContributionManager;
-import org.apache.tuscany.sca.host.embedded.impl.EmbeddedSCADomain;
 import org.apache.tuscany.sca.host.embedded.impl.ReallySmallRuntime;
-import org.apache.tuscany.sca.host.embedded.management.variation.ComponentListener;
-import org.apache.tuscany.sca.host.embedded.management.variation.ComponentManager;
 
 public class ContributionManagerImpl implements ContributionManager {
 
@@ -156,4 +147,60 @@
     	}
     }
 
+    public void startContributionJAR(URL contributionJAR) throws ActivationException, ContributionException,
+        IOException, CompositeBuilderException {
+
+        if (contribution == null) {
+            addContributionJAR(contributionJAR);
+        }
+
+        if (contribution != null) {
+            for (Composite composite : contribution.getDeployables()) {
+                nodeRuntime.getCompositeActivator().start(composite);
+            }
+        } else {
+            throw new ActivationException("Contribution " + contributionLocation + " not
added");
+        }
+    }
+
+    public void addContributionJAR(URL contributionJar) throws CompositeBuilderException,
ActivationException {
+
+        ContributionService contributionService = nodeRuntime.getContributionService();
+
+        Contribution contribution = contributeJAR(contributionJar, contributionService);
+
+        // Add the composites to the top level domain
+        for (Composite composite : contribution.getDeployables()) {
+            nodeComposite.getIncludes().add(composite);
+            nodeRuntime.getCompositeBuilder().build(composite);
+        }
+
+        // activate all of the composites just loaded
+        for (Composite composite : contribution.getDeployables()) {
+            nodeRuntime.getCompositeActivator().activate(composite);
+        }
+    }
+
+    protected Contribution contributeJAR(URL contributionJar, ContributionService contributionService)
throws ActivationException {
+        InputStream is;
+        try {
+            is = contributionJar.openStream();
+        } catch (IOException e) {
+            throw new ActivationException(e);
+        }
+        Contribution contribution;
+        try {
+            contribution = contributionService.contribute(contributionJar.toString(), contributionJar,
is, modelResolver);
+        } catch (Exception e) {
+            throw new ActivationException(e);
+        }
+        if (is != null) {
+            try {
+                is.close();
+            } catch (IOException e) {
+                throw new ActivationException(e);
+            }
+        }
+        return contribution;
+    }
 }

Modified: incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/node/impl/NodeImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/node/impl/NodeImpl.java?rev=573852&r1=573851&r2=573852&view=diff
==============================================================================
--- incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/node/impl/NodeImpl.java
(original)
+++ incubator/tuscany/java/sca/modules/distributed-impl/src/main/java/org/apache/tuscany/sca/distributed/node/impl/NodeImpl.java
Sat Sep  8 08:08:21 2007
@@ -107,6 +107,13 @@
         this.isStandalone = true;
         init();
     }
+    public NodeImpl(ClassLoader cl) throws ActivationException {
+      this.domainUri = LOCAL_DOMAIN_URI ; 
+      this.nodeUri = LOCAL_NODE_NAME;
+      this.isStandalone = true;
+      this.domainClassLoader = cl;
+      init();
+  }
     
     public NodeImpl(String domainUri)
       throws ActivationException {
@@ -522,5 +529,6 @@
                 return componentContext.createSelfReference(businessInterface);
             }
         }
-    }  
+    }
+
 }



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org


Mime
View raw message