diff options
author | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-07-03 06:23:46 +0000 |
---|---|---|
committer | antelder <antelder@13f79535-47bb-0310-9956-ffa450edef68> | 2010-07-03 06:23:46 +0000 |
commit | efe9a1562dcad578b80c02a628c045c9febd01f2 (patch) | |
tree | 58145881a90b5c96a1b4a85639e23c4a90cb93d9 /sca-java-2.x/trunk/modules | |
parent | 509a623eca50a7e4dae5eb33dbdafa9378081318 (diff) |
Add a method to Deployer to resolve a contributions dependencies
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@960159 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-java-2.x/trunk/modules')
2 files changed, 84 insertions, 0 deletions
diff --git a/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java b/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java index 9c5d19816c..dba21e7197 100644 --- a/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java +++ b/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/Deployer.java @@ -193,4 +193,15 @@ public interface Deployer extends LifeCycleListener { * Get the system definitions */ Definitions getSystemDefinitions(); + + /** + * Resolve a contributions dependencies + * + * @param c + * @param allContributions + * @param monitor + * @throws ContributionResolveException + * @throws CompositeBuilderException + */ + void resolve(Contribution c, List<Contribution> dependentContributions, Monitor monitor) throws ContributionResolveException, CompositeBuilderException; } diff --git a/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java b/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java index ecf2adfb85..cf94c5a8b7 100644 --- a/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java +++ b/sca-java-2.x/trunk/modules/deployment/src/main/java/org/apache/tuscany/sca/deployment/impl/DeployerImpl.java @@ -549,6 +549,79 @@ public class DeployerImpl implements Deployer { return domainComposite; } + + public void resolve(Contribution c, List<Contribution> dependentContributions, Monitor monitor) throws ContributionResolveException, CompositeBuilderException { + init(); + List<Contribution> contributionList = new ArrayList<Contribution>(); + contributionList.add(c); + + Contribution systemContribution = cloneSystemContribution(monitor); + Definitions systemDefinitions = systemContribution.getArtifacts().get(0).getModel(); + // Build an aggregated SCA definitions model. Must be done before we try and + // resolve any contributions or composites as they may depend on the full + // definitions.xml picture + + // get all definitions.xml artifacts from contributions and aggregate + // into the system contribution. In turn add a default import into + // each contribution so that, for unresolved items, the resolution + // processing will look in the system contribution + ProcessorContext context = new ProcessorContext(monitor); + for (Contribution contribution : contributionList) { + monitor.pushContext("Contribution: " + contribution.getURI()); + try { + // aggregate definitions + for (Artifact artifact : contribution.getArtifacts()) { + if (!"META-INF/definitions.xml".equals(artifact.getURI())) { + continue; + } + Object model = artifact.getModel(); + if (model instanceof Definitions) { + try { + monitor.pushContext("Definitions: " + artifact.getLocation()); + DefinitionsUtil.aggregate((Definitions)model, systemDefinitions, monitor); + } finally { + monitor.popContext(); + } + } + } + + // create a default import and wire it up to the system contribution + // model resolver. This is the trick that makes the resolution processing + // skip over to the system contribution if resolution is unsuccessful + // in the current contribution + DefaultImport defaultImport = contributionFactory.createDefaultImport(); + defaultImport.setModelResolver(systemContribution.getModelResolver()); + contribution.getImports().add(defaultImport); + } finally { + monitor.popContext(); + } + } + + ExtensibleModelResolver modelResolver = + new ExtensibleModelResolver(new Contributions(contributionList), modelResolvers, modelFactories); + + // now resolve and add the system contribution + contributionProcessor.resolve(systemContribution, modelResolver, context); + contributionList.add(systemContribution); + + // pre-resolve the contributions + contributionsPreresolve(contributionList, modelResolver, context); + + // Build the contribution dependencies + Set<Contribution> resolved = new HashSet<Contribution>(); + + for (Contribution contribution : contributionList) { + buildDependencies(contribution, dependentContributions, monitor); + + // Resolve contributions + for (Contribution dependency : contribution.getDependencies()) { + if (!resolved.contains(dependency)) { + resolved.add(dependency); + contributionProcessor.resolve(dependency, modelResolver, context); + } + } + } + } public Artifact loadArtifact(URI uri, URL location, Monitor monitor) throws ContributionReadException { init(); |