diff options
author | edwardsmj <edwardsmj@13f79535-47bb-0310-9956-ffa450edef68> | 2009-05-08 12:02:46 +0000 |
---|---|---|
committer | edwardsmj <edwardsmj@13f79535-47bb-0310-9956-ffa450edef68> | 2009-05-08 12:02:46 +0000 |
commit | a05b13a7419efe5d96bb69ea2e21137e6225818a (patch) | |
tree | 9d124e8fafeed8ec17a56c12b0950253bfa2c9c6 /java/sca/modules/workspace-impl/src/main | |
parent | 35b26fdd32a8ba41e266d3e7c88626fedc32fe34 (diff) |
Updates and additions to add preResolve phase to contribution processing (See TUSCANY-3012)
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@772950 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'java/sca/modules/workspace-impl/src/main')
-rw-r--r-- | java/sca/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java | 74 |
1 files changed, 55 insertions, 19 deletions
diff --git a/java/sca/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java b/java/sca/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java index da8f957d9e..3e7723f48f 100644 --- a/java/sca/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java +++ b/java/sca/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java @@ -37,6 +37,7 @@ import org.apache.tuscany.sca.contribution.processor.ContributionResolveExceptio import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; +import org.apache.tuscany.sca.contribution.processor.ExtendedURLArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessorExtensionPoint; import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver; import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver; @@ -56,7 +57,7 @@ import org.apache.tuscany.sca.workspace.scanner.impl.JarContributionScanner; * * @version $Rev$ $Date$ */ -public class ContributionContentProcessor implements URLArtifactProcessor<Contribution>{ +public class ContributionContentProcessor implements ExtendedURLArtifactProcessor<Contribution>{ private ContributionFactory contributionFactory; private ModelResolverExtensionPoint modelResolvers; private FactoryExtensionPoint modelFactories; @@ -65,6 +66,8 @@ public class ContributionContentProcessor implements URLArtifactProcessor<Contri // private UtilityExtensionPoint utilities; private Monitor monitor; private ContributionScannerExtensionPoint scanners; + // Marks pre-resolve phase completed + private boolean preResolved = false; public ContributionContentProcessor(ExtensionPointRegistry extensionPoints, StAXArtifactProcessor<Object> extensionProcessor, Monitor monitor) { this.modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class); @@ -173,27 +176,32 @@ public class ContributionContentProcessor implements URLArtifactProcessor<Contri return contribution; } - public void resolve(Contribution contribution, ModelResolver resolver) throws ContributionResolveException { - + /** + * A pre-resolution step, which is required for Contributions to handle the resolution of imports and exports so that + * at resolve time, imports can be followed to exports and anything exported that is required can be resolved on demand + * without the need to have already resolved the whole of the Contribution containing the export + * @param contribution - the Contribution + * @param resolver - the Resolver to use + * @throws ContributionResolveException + */ + public void preResolve(Contribution contribution, ModelResolver resolver) throws ContributionResolveException { // Resolve the contribution model itself ModelResolver contributionResolver = contribution.getModelResolver(); contribution.setUnresolved(false); contributionResolver.addModel(contribution); - // Resolve imports and exports - for (Export export: contribution.getExports()) { - if (export instanceof DefaultExport) { - - // Initialize the default export's resolver - export.setModelResolver(contributionResolver); + // Resolve Exports + resolveExports(contribution, contributionResolver); + // Resolve Imports + resolveImports(contribution, contributionResolver); + + preResolved = true; + } // end method preResolve + + public void resolve(Contribution contribution, ModelResolver resolver) throws ContributionResolveException { - } else { - extensionProcessor.resolve(export, contributionResolver); - } - } - for (Import import_: contribution.getImports()) { - extensionProcessor.resolve(import_, contributionResolver); - } + if( !preResolved ) preResolve( contribution, resolver); + ModelResolver contributionResolver = contribution.getModelResolver(); // Resolve all artifact models for (Artifact artifact : contribution.getArtifacts()) { @@ -215,7 +223,35 @@ public class ContributionContentProcessor implements URLArtifactProcessor<Contri if (resolved != deployable) { deployables.set(i, resolved); } - } - } + } // end for + } // end method resolve + + /** + * Resolves the Exports of the contribution + * @param contribution + * @param resolver + */ + private void resolveExports(Contribution contribution, ModelResolver resolver) throws ContributionResolveException { + for (Export export: contribution.getExports()) { + if (export instanceof DefaultExport) { + // Initialize the default export's resolver + export.setModelResolver(resolver); + } else { + extensionProcessor.resolve(export, resolver); + } // end if + } // end for + + } // end method resolveExports + + /** + * Resolves the Imports of the contribution + * @param contribution + * @param resolver + */ + private void resolveImports(Contribution contribution, ModelResolver resolver) throws ContributionResolveException { + for (Import import_: contribution.getImports()) { + extensionProcessor.resolve(import_, resolver); + } // end for + } // end method resolveImports -} +} // end class ContributionContentProcessor |