tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r1131053 - in /tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment: Deployer.java impl/DeployerImpl.java
Date Fri, 03 Jun 2011 14:16:09 GMT
Author: antelder
Date: Fri Jun  3 14:16:09 2011
New Revision: 1131053

URL: http://svn.apache.org/viewvc?rev=1131053&view=rev
Log:
Add a method to Deployer to get a contributions dependencies from a set of contribution metadata

Modified:
    tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java
    tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java

Modified: tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java?rev=1131053&r1=1131052&r2=1131053&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java
Fri Jun  3 14:16:09 2011
@@ -36,6 +36,7 @@ import org.apache.tuscany.sca.assembly.b
 import org.apache.tuscany.sca.assembly.builder.CompositeBuilderException;
 import org.apache.tuscany.sca.contribution.Artifact;
 import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionMetadata;
 import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
 import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
 import org.apache.tuscany.sca.contribution.processor.ContributionWriteException;
@@ -220,4 +221,13 @@ public interface Deployer extends LifeCy
     void resolve(Contribution c, List<Contribution> dependentContributions, Monitor
monitor) throws ContributionResolveException, CompositeBuilderException;
 
     public  Contribution cloneSystemContribution(Monitor monitor);
+
+    /**
+     * Get a contributions dependencies from meta data without having to load a Contribution

+     * @param possibles a Map with key contributionURI and value the contribution metaData
+     * @param targetURI the contributionURI to find the dependencies of
+     * @param monitor
+     * @return the list of contribution URIs
+     */
+    public List<String> getDependencies(Map<String, ContributionMetadata> possibles,
String targetURI, Monitor monitor);
 }

Modified: tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java?rev=1131053&r1=1131052&r2=1131053&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java
Fri Jun  3 14:16:09 2011
@@ -26,6 +26,7 @@ import java.net.URL;
 import java.util.ArrayList;
 import java.util.Collection;
 import java.util.Collections;
+import java.util.HashMap;
 import java.util.HashSet;
 import java.util.List;
 import java.util.Map;
@@ -57,6 +58,7 @@ import org.apache.tuscany.sca.common.xml
 import org.apache.tuscany.sca.contribution.Artifact;
 import org.apache.tuscany.sca.contribution.Contribution;
 import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.ContributionMetadata;
 import org.apache.tuscany.sca.contribution.DefaultImport;
 import org.apache.tuscany.sca.contribution.Export;
 import org.apache.tuscany.sca.contribution.Import;
@@ -89,9 +91,9 @@ import org.apache.tuscany.sca.monitor.Mo
 import org.apache.tuscany.sca.monitor.MonitorFactory;
 import org.apache.tuscany.sca.monitor.ValidationException;
 import org.apache.tuscany.sca.runtime.BaseDomainRegistry;
+import org.apache.tuscany.sca.runtime.ContributionDescription;
 import org.apache.tuscany.sca.runtime.DomainRegistry;
 import org.apache.tuscany.sca.runtime.EndpointReferenceBinder;
-import org.apache.tuscany.sca.runtime.ContributionDescription;
 import org.apache.tuscany.sca.xsd.XSDFactory;
 import org.apache.tuscany.sca.xsd.XSDefinition;
 
@@ -227,7 +229,7 @@ public class DeployerImpl implements Dep
                     // push context here as the "stack" in this case is a list of nexted
contributions
                     // through which imports have been chased which may not make much sense
to the 
                     // user so just report the contribution in error
-                    monitor.pushContext("Contribution: " + contribution.getLocation());
+                    monitor.pushContext("Contribution: " + contribution.getURI());
                     Monitor.error(monitor, this, DEPLOYER_IMPL_VALIDATION_MESSAGES, "UnresolvedImport",
import_);
                     monitor.popContext();
                 }
@@ -249,6 +251,27 @@ public class DeployerImpl implements Dep
 
         contribution.getDependencies().addAll(dependencies);
     }
+    
+    public List<String> getDependencies(Map<String, ContributionMetadata> possibles,
String targetURI, Monitor monitor) {   
+        Map<String, Contribution> contributions = new HashMap<String, Contribution>();
+        for (String curi : possibles.keySet()) {
+            Contribution c = contributionFactory.createContribution();
+            c.setURI(curi);
+            c.mergeMetaData(possibles.get(curi));
+            contributions.put(curi, c);
+        }
+
+        Contribution tc = contributions.remove(targetURI);
+        buildDependencies(tc, new ArrayList<Contribution>(contributions.values()),
monitor);
+        
+        List<String> dcuris = new ArrayList<String>();
+        for (Contribution dc : tc.getDependencies()) {
+            dcuris.add(dc.getURI());
+        }
+        dcuris.remove(targetURI);
+        return dcuris;
+    }
+    
 
     /**
      * Pre-resolve phase for contributions, to set up handling of imports and exports prior
to full resolution



Mime
View raw message