diff options
Diffstat (limited to 'branches/sca-equinox/modules/workspace-impl/src')
5 files changed, 51 insertions, 33 deletions
diff --git a/branches/sca-equinox/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/builder/impl/ContributionDependencyBuilderImpl.java b/branches/sca-equinox/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/builder/impl/ContributionDependencyBuilderImpl.java index 408debdc8e..bdfd244293 100644 --- a/branches/sca-equinox/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/builder/impl/ContributionDependencyBuilderImpl.java +++ b/branches/sca-equinox/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/builder/impl/ContributionDependencyBuilderImpl.java @@ -31,47 +31,45 @@ import org.apache.tuscany.sca.contribution.DefaultImport; import org.apache.tuscany.sca.contribution.Export; import org.apache.tuscany.sca.contribution.Import; import org.apache.tuscany.sca.contribution.resolver.DefaultImportModelResolver; +import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.monitor.Problem; import org.apache.tuscany.sca.monitor.Problem.Severity; -import org.apache.tuscany.sca.monitor.impl.ProblemImpl; import org.apache.tuscany.sca.workspace.Workspace; -import org.apache.tuscany.sca.workspace.builder.ContributionDependencyBuilder; +import org.apache.tuscany.sca.workspace.builder.ContributionBuilder; +import org.apache.tuscany.sca.workspace.builder.ContributionBuilderException; /** * A contribution dependency builder. * * @version $Rev$ $Date$ */ -public class ContributionDependencyBuilderImpl implements ContributionDependencyBuilder { +public class ContributionDependencyBuilderImpl implements ContributionBuilder { private static final Logger logger = Logger.getLogger(ContributionDependencyBuilderImpl.class.getName()); - private Monitor monitor; - /** * Constructs a new ContributionDependencyBuilder. */ - public ContributionDependencyBuilderImpl(Monitor monitor) { - - this.monitor = monitor; + public ContributionDependencyBuilderImpl(FactoryExtensionPoint factories) { } - /** - * Calculate the set of contributions that a contribution depends on. - * @param contribution - * @param workspace - * @return - */ - public List<Contribution> buildContributionDependencies(Contribution contribution, Workspace workspace) { + public String getID() { + return "org.apache.tuscany.sca.workspace.builder.ContributionDependencyBuilder"; + } + + public void build(Contribution contribution, Workspace workspace, Monitor monitor) throws ContributionBuilderException{ + contribution.getDependencies().clear(); + List<Contribution> dependencies = new ArrayList<Contribution>(); Set<Contribution> set = new HashSet<Contribution>(); dependencies.add(contribution); set.add(contribution); - addContributionDependencies(contribution, workspace, dependencies, set); + addContributionDependencies(contribution, workspace, dependencies, set, monitor); Collections.reverse(dependencies); - return dependencies; + + contribution.getDependencies().addAll(dependencies); } /** @@ -80,8 +78,9 @@ public class ContributionDependencyBuilderImpl implements ContributionDependency * @param workspace * @param dependencies * @param set + * @param monitor */ - private void addContributionDependencies(Contribution contribution, Workspace workspace, List<Contribution> dependencies, Set<Contribution> set) { + private void addContributionDependencies(Contribution contribution, Workspace workspace, List<Contribution> dependencies, Set<Contribution> set, Monitor monitor) { // Go through the contribution imports for (Import import_: contribution.getImports()) { @@ -107,7 +106,7 @@ public class ContributionDependencyBuilderImpl implements ContributionDependency dependencies.add(dependency); // Now add the dependencies of that contribution - addContributionDependencies(dependency, workspace, dependencies, set); + addContributionDependencies(dependency, workspace, dependencies, set, monitor); } } } @@ -122,7 +121,7 @@ public class ContributionDependencyBuilderImpl implements ContributionDependency } else { // Record import resolution issue if (!(import_ instanceof DefaultImport)) { - warning("UnresolvedImport", import_, import_); + warning(monitor, "UnresolvedImport", import_, import_); } } } @@ -135,9 +134,9 @@ public class ContributionDependencyBuilderImpl implements ContributionDependency * @param message * @param model */ - private void warning(String message, Object model, Object... messageParameters) { + private static void warning(Monitor monitor, String message, Object model, Object... messageParameters) { if (monitor != null) { - Problem problem = monitor.createProblem(getClass().getName(), "workspace-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters); + Problem problem = monitor.createProblem(ContributionDependencyBuilderImpl.class.getName(), "workspace-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters); monitor.problem(problem); } } diff --git a/branches/sca-equinox/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java b/branches/sca-equinox/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java index 880e95480e..9aa57361fc 100644 --- a/branches/sca-equinox/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java +++ b/branches/sca-equinox/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java @@ -32,7 +32,6 @@ import org.apache.tuscany.sca.contribution.DefaultExport; import org.apache.tuscany.sca.contribution.DefaultImport; import org.apache.tuscany.sca.contribution.Export; import org.apache.tuscany.sca.contribution.Import; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; @@ -46,6 +45,7 @@ import org.apache.tuscany.sca.contribution.scanner.ContributionScanner; import org.apache.tuscany.sca.contribution.service.ContributionReadException; import org.apache.tuscany.sca.contribution.service.ContributionResolveException; import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.core.UtilityExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.workspace.scanner.impl.DirectoryContributionScanner; @@ -60,14 +60,14 @@ import org.apache.tuscany.sca.workspace.scanner.impl.JarContributionScanner; public class ContributionContentProcessor implements URLArtifactProcessor<Contribution>{ private ContributionFactory contributionFactory; private ModelResolverExtensionPoint modelResolvers; - private ModelFactoryExtensionPoint modelFactories; + private FactoryExtensionPoint modelFactories; private URLArtifactProcessor<Object> artifactProcessor; private StAXArtifactProcessor<Object> extensionProcessor; private UtilityExtensionPoint utilities; private Monitor monitor = null; public ContributionContentProcessor(ExtensionPointRegistry extensionPoints, StAXArtifactProcessor<Object> extensionProcessor, Monitor monitor) { - this.modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); + this.modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class); this.modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class); hackResolvers(modelResolvers); this.monitor = monitor; @@ -77,7 +77,7 @@ public class ContributionContentProcessor implements URLArtifactProcessor<Contri this.contributionFactory = modelFactories.getFactory(ContributionFactory.class); } - public ContributionContentProcessor(ModelFactoryExtensionPoint modelFactories, ModelResolverExtensionPoint modelResolvers, + public ContributionContentProcessor(FactoryExtensionPoint modelFactories, ModelResolverExtensionPoint modelResolvers, URLArtifactProcessor<Object> artifactProcessor, StAXArtifactProcessor<Object> extensionProcessor, Monitor monitor) { this.modelFactories = modelFactories; this.modelResolvers = modelResolvers; diff --git a/branches/sca-equinox/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionInfoProcessor.java b/branches/sca-equinox/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionInfoProcessor.java index 6ef0fa753d..21a0382347 100644 --- a/branches/sca-equinox/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionInfoProcessor.java +++ b/branches/sca-equinox/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionInfoProcessor.java @@ -34,7 +34,6 @@ import org.apache.tuscany.sca.contribution.DefaultExport; import org.apache.tuscany.sca.contribution.DefaultImport; import org.apache.tuscany.sca.contribution.Export; import org.apache.tuscany.sca.contribution.Import; -import org.apache.tuscany.sca.contribution.ModelFactoryExtensionPoint; import org.apache.tuscany.sca.contribution.processor.ExtensibleURLArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.StAXArtifactProcessor; import org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor; @@ -48,6 +47,7 @@ import org.apache.tuscany.sca.contribution.scanner.ContributionScanner; import org.apache.tuscany.sca.contribution.service.ContributionReadException; import org.apache.tuscany.sca.contribution.service.ContributionResolveException; import org.apache.tuscany.sca.core.ExtensionPointRegistry; +import org.apache.tuscany.sca.core.FactoryExtensionPoint; import org.apache.tuscany.sca.monitor.Monitor; import org.apache.tuscany.sca.workspace.scanner.impl.DirectoryContributionScanner; import org.apache.tuscany.sca.workspace.scanner.impl.JarContributionScanner; @@ -61,13 +61,13 @@ import org.apache.tuscany.sca.workspace.scanner.impl.JarContributionScanner; public class ContributionInfoProcessor implements URLArtifactProcessor<Contribution>{ private ContributionFactory contributionFactory; private ModelResolverExtensionPoint modelResolvers; - private ModelFactoryExtensionPoint modelFactories; + private FactoryExtensionPoint modelFactories; private URLArtifactProcessorExtensionPoint artifactProcessors; private URLArtifactProcessor<Object> artifactProcessor; private StAXArtifactProcessor<Object> extensionProcessor; public ContributionInfoProcessor(ExtensionPointRegistry extensionPoints, StAXArtifactProcessor<Object> extensionProcessor, Monitor monitor) { - this.modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.class); + this.modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class); this.modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class); hackResolvers(modelResolvers); URLArtifactProcessorExtensionPoint artifactProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class); @@ -77,7 +77,7 @@ public class ContributionInfoProcessor implements URLArtifactProcessor<Contribut this.contributionFactory = modelFactories.getFactory(ContributionFactory.class); } - public ContributionInfoProcessor(ModelFactoryExtensionPoint modelFactories, ModelResolverExtensionPoint modelResolvers, URLArtifactProcessor<Object> artifactProcessor) { + public ContributionInfoProcessor(FactoryExtensionPoint modelFactories, ModelResolverExtensionPoint modelResolvers, URLArtifactProcessor<Object> artifactProcessor) { this.modelFactories = modelFactories; this.modelResolvers = modelResolvers; hackResolvers(modelResolvers); diff --git a/branches/sca-equinox/modules/workspace-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.workspace.builder.ContributionBuilder b/branches/sca-equinox/modules/workspace-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.workspace.builder.ContributionBuilder new file mode 100644 index 0000000000..379d0a017e --- /dev/null +++ b/branches/sca-equinox/modules/workspace-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.workspace.builder.ContributionBuilder @@ -0,0 +1,18 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +org.apache.tuscany.sca.workspace.builder.impl.ContributionDependencyBuilderImpl;id=org.apache.tuscany.sca.workspace.builder.ContributionDependencyBuilder diff --git a/branches/sca-equinox/modules/workspace-impl/src/test/java/org/apache/tuscany/sca/workspace/builder/impl/ContributionDependencyBuilderTestCase.java b/branches/sca-equinox/modules/workspace-impl/src/test/java/org/apache/tuscany/sca/workspace/builder/impl/ContributionDependencyBuilderTestCase.java index f7b6b35679..63f6035433 100644 --- a/branches/sca-equinox/modules/workspace-impl/src/test/java/org/apache/tuscany/sca/workspace/builder/impl/ContributionDependencyBuilderTestCase.java +++ b/branches/sca-equinox/modules/workspace-impl/src/test/java/org/apache/tuscany/sca/workspace/builder/impl/ContributionDependencyBuilderTestCase.java @@ -56,7 +56,7 @@ public class ContributionDependencyBuilderTestCase extends TestCase { public void tearDown() throws Exception { } - public void testAnalyze() { + public void testAnalyze() throws Exception { Workspace workspace = workspaceFactory.createWorkspace(); Contribution importer = contributionFactory.createContribution(); importer.setURI("importer"); @@ -89,8 +89,9 @@ public class ContributionDependencyBuilderTestCase extends TestCase { export.setNamespace("http://another"); another.getExports().add(export); - ContributionDependencyBuilderImpl analyzer = new ContributionDependencyBuilderImpl(null); - List<Contribution> dependencies = analyzer.buildContributionDependencies(importer, workspace); + ContributionDependencyBuilderImpl builder = new ContributionDependencyBuilderImpl(null); + builder.build(importer, workspace, null); + List<Contribution> dependencies = importer.getDependencies(); assertTrue(dependencies.size() == 3); assertTrue(dependencies.contains(importer)); assertTrue(dependencies.contains(imported)); |