summaryrefslogtreecommitdiffstats
path: root/branches/2.0-M2/modules/workspace-impl/src/main
diff options
context:
space:
mode:
authorantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-03-20 11:29:50 +0000
committerantelder <antelder@13f79535-47bb-0310-9956-ffa450edef68>2009-03-20 11:29:50 +0000
commit174374d300ce6001996d70516a6b1f563f3c8985 (patch)
tree928e56bace1942f53c54d3e45749744434d5946a /branches/2.0-M2/modules/workspace-impl/src/main
parent048898980cb3ece6e4800de9579505d290d92c27 (diff)
Delete test branch created by the release plugin
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@756421 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--branches/2.0-M2/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/builder/impl/ContributionDependencyBuilderImpl.java144
-rw-r--r--branches/2.0-M2/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java219
-rw-r--r--branches/2.0-M2/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionInfoProcessor.java225
-rw-r--r--branches/2.0-M2/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/scanner/impl/DirectoryContributionScanner.java107
-rw-r--r--branches/2.0-M2/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/scanner/impl/JarContributionScanner.java121
-rw-r--r--branches/2.0-M2/modules/workspace-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor20
-rw-r--r--branches/2.0-M2/modules/workspace-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.workspace.builder.ContributionBuilder18
-rw-r--r--branches/2.0-M2/modules/workspace-impl/src/main/resources/workspace-validation-messages.properties22
-rw-r--r--branches/2.0-M2/modules/workspace-impl/src/main/resources/workspace-validation-messages_it.properties21
9 files changed, 0 insertions, 897 deletions
diff --git a/branches/2.0-M2/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/builder/impl/ContributionDependencyBuilderImpl.java b/branches/2.0-M2/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/builder/impl/ContributionDependencyBuilderImpl.java
deleted file mode 100644
index bdfd244293..0000000000
--- a/branches/2.0-M2/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/builder/impl/ContributionDependencyBuilderImpl.java
+++ /dev/null
@@ -1,144 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.tuscany.sca.workspace.builder.impl;
-
-import java.util.ArrayList;
-import java.util.Collections;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.logging.Logger;
-
-import org.apache.tuscany.sca.contribution.Contribution;
-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.workspace.Workspace;
-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 ContributionBuilder {
- private static final Logger logger = Logger.getLogger(ContributionDependencyBuilderImpl.class.getName());
-
- /**
- * Constructs a new ContributionDependencyBuilder.
- */
- public ContributionDependencyBuilderImpl(FactoryExtensionPoint factories) {
- }
-
- 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, monitor);
-
- Collections.reverse(dependencies);
-
- contribution.getDependencies().addAll(dependencies);
- }
-
- /**
- * Analyze a contribution and add its dependencies to the given dependency set.
- * @param contribution
- * @param workspace
- * @param dependencies
- * @param set
- * @param monitor
- */
- 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()) {
- boolean resolved = false;
-
- // Go through all contribution candidates and their exports
- List<Export> matchingExports = new ArrayList<Export>();
- for (Contribution dependency: workspace.getContributions()) {
- if (dependency == contribution) {
- // Do not self import
- continue;
- }
- for (Export export: dependency.getExports()) {
-
- // If an export from a contribution matches the import in hand
- // add that contribution to the dependency set
- if (import_.match(export)) {
- resolved = true;
- matchingExports.add(export);
-
- if (!set.contains(dependency)) {
- set.add(dependency);
- dependencies.add(dependency);
-
- // Now add the dependencies of that contribution
- addContributionDependencies(dependency, workspace, dependencies, set, monitor);
- }
- }
- }
- }
-
- if (resolved) {
-
- // Initialize the import's model resolver with a delegating model
- // resolver which will delegate to the matching exports
- import_.setModelResolver(new DefaultImportModelResolver(matchingExports));
-
- } else {
- // Record import resolution issue
- if (!(import_ instanceof DefaultImport)) {
- warning(monitor, "UnresolvedImport", import_, import_);
- }
- }
- }
- }
-
- /**
- * Report a warning.
- *
- * @param problems
- * @param message
- * @param model
- */
- private static void warning(Monitor monitor, String message, Object model, Object... messageParameters) {
- if (monitor != null) {
- Problem problem = monitor.createProblem(ContributionDependencyBuilderImpl.class.getName(), "workspace-validation-messages", Severity.WARNING, model, message, (Object[])messageParameters);
- monitor.problem(problem);
- }
- }
-
-}
diff --git a/branches/2.0-M2/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java b/branches/2.0-M2/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java
deleted file mode 100644
index fd645132a1..0000000000
--- a/branches/2.0-M2/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionContentProcessor.java
+++ /dev/null
@@ -1,219 +0,0 @@
-/*
- * 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.
- */
-package org.apache.tuscany.sca.workspace.processor.impl;
-
-import java.io.File;
-import java.net.URI;
-import java.net.URL;
-import java.util.List;
-
-import org.apache.tuscany.sca.assembly.Composite;
-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.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.processor.ContributionReadException;
-import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
-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.URLArtifactProcessorExtensionPoint;
-import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
-import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver;
-import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint;
-import org.apache.tuscany.sca.contribution.scanner.ContributionScanner;
-import org.apache.tuscany.sca.contribution.scanner.ContributionScannerExtensionPoint;
-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;
-
-/**
- * URLArtifactProcessor that handles contribution files and the artifacts they contain
- * and returns a contribution model.
- *
- * @version $Rev$ $Date$
- */
-public class ContributionContentProcessor implements URLArtifactProcessor<Contribution>{
- private ContributionFactory contributionFactory;
- private ModelResolverExtensionPoint modelResolvers;
- private FactoryExtensionPoint modelFactories;
- private URLArtifactProcessor<Object> artifactProcessor;
- private StAXArtifactProcessor<Object> extensionProcessor;
- // private UtilityExtensionPoint utilities;
- private Monitor monitor;
- private ContributionScannerExtensionPoint scanners;
-
- public ContributionContentProcessor(ExtensionPointRegistry extensionPoints, StAXArtifactProcessor<Object> extensionProcessor, Monitor monitor) {
- this.modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
- this.modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class);
- this.monitor = monitor;
- URLArtifactProcessorExtensionPoint artifactProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
- this.artifactProcessor = new ExtensibleURLArtifactProcessor(artifactProcessors, this.monitor);
- this.extensionProcessor = extensionProcessor;
- this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
- this.scanners = extensionPoints.getExtensionPoint(ContributionScannerExtensionPoint.class);
- }
-
- /*
- public ContributionContentProcessor(FactoryExtensionPoint modelFactories, ModelResolverExtensionPoint modelResolvers,
- URLArtifactProcessor<Object> artifactProcessor, StAXArtifactProcessor<Object> extensionProcessor, Monitor monitor) {
- this.modelFactories = modelFactories;
- this.modelResolvers = modelResolvers;
- hackResolvers(modelResolvers);
- this.artifactProcessor = artifactProcessor;
- this.extensionProcessor = extensionProcessor;
- this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
- this.monitor = monitor;
- }
- */
-
- public String getArtifactType() {
- return ".contribution/content";
- }
-
- public Class<Contribution> getModelType() {
- return Contribution.class;
- }
-
- public Contribution read(URL parentURL, URI contributionURI, URL contributionURL) throws ContributionReadException {
-
- // Create contribution model
- Contribution contribution = contributionFactory.createContribution();
- contribution.setURI(contributionURI.toString());
- contribution.setLocation(contributionURL.toString());
- ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
- contribution.setModelResolver(modelResolver);
- contribution.setUnresolved(true);
-
- // Create a contribution scanner
- ContributionScanner scanner = scanners.getContributionScanner(contributionURL.getProtocol());
- if (scanner == null) {
- if ("file".equals(contributionURL.getProtocol()) && new File(contributionURL.getFile()).isDirectory()) {
- scanner = new DirectoryContributionScanner();
- } else {
- scanner = new JarContributionScanner();
- }
- }
-
- // Scan the contribution and list the artifacts contained in it
- List<Artifact> artifacts = contribution.getArtifacts();
- boolean contributionMetadata = false;
- List<String> artifactURIs = scanner.getArtifacts(contributionURL);
- for (String artifactURI: artifactURIs) {
- URL artifactURL = scanner.getArtifactURL(contributionURL, artifactURI);
-
- // Add the deployed artifact model to the contribution
- Artifact artifact = this.contributionFactory.createArtifact();
- artifact.setURI(artifactURI);
- artifact.setLocation(artifactURL.toString());
- artifacts.add(artifact);
- modelResolver.addModel(artifact);
-
- // Read each artifact
- Object model = artifactProcessor.read(contributionURL, URI.create(artifactURI), artifactURL);
- if (model != null) {
- artifact.setModel(model);
-
- // Add the loaded model to the model resolver
- modelResolver.addModel(model);
-
- // Merge contribution metadata into the contribution model
- if (model instanceof ContributionMetadata) {
- contributionMetadata = true;
- ContributionMetadata c = (ContributionMetadata)model;
- contribution.getImports().addAll(c.getImports());
- contribution.getExports().addAll(c.getExports());
- contribution.getDeployables().addAll(c.getDeployables());
- }
- }
- }
-
- // If no sca-contribution.xml file was provided then just consider
- // all composites in the contribution as deployables
- if (!contributionMetadata) {
- for (Artifact artifact: artifacts) {
- if (artifact.getModel() instanceof Composite) {
- contribution.getDeployables().add((Composite)artifact.getModel());
- }
- }
-
- // Add default contribution import and export
- DefaultImport defaultImport = contributionFactory.createDefaultImport();
- defaultImport.setModelResolver(new DefaultModelResolver());
- contribution.getImports().add(defaultImport);
- DefaultExport defaultExport = contributionFactory.createDefaultExport();
- contribution.getExports().add(defaultExport);
- }
-
- return contribution;
- }
-
- public void resolve(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);
-
- } else {
- extensionProcessor.resolve(export, contributionResolver);
- }
- }
- for (Import import_: contribution.getImports()) {
- extensionProcessor.resolve(import_, contributionResolver);
- }
-
- // Resolve all artifact models
- for (Artifact artifact : contribution.getArtifacts()) {
- Object model = artifact.getModel();
- if (model != null) {
- try {
- artifactProcessor.resolve(model, contributionResolver);
- } catch (Exception e) {
- //FIXME this shouldn't happen
- }
- }
- }
-
- // Resolve deployable composites
- List<Composite> deployables = contribution.getDeployables();
- for (int i = 0, n = deployables.size(); i < n; i++) {
- Composite deployable = deployables.get(i);
- Composite resolved = (Composite)contributionResolver.resolveModel(Composite.class, deployable);
- if (resolved != deployable) {
- deployables.set(i, resolved);
- }
- }
- }
-
-}
diff --git a/branches/2.0-M2/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionInfoProcessor.java b/branches/2.0-M2/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionInfoProcessor.java
deleted file mode 100644
index 6b7fc2f259..0000000000
--- a/branches/2.0-M2/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/processor/impl/ContributionInfoProcessor.java
+++ /dev/null
@@ -1,225 +0,0 @@
-/*
- * 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.
- */
-package org.apache.tuscany.sca.workspace.processor.impl;
-
-import java.io.File;
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.List;
-
-import org.apache.tuscany.sca.assembly.Composite;
-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.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.processor.ContributionReadException;
-import org.apache.tuscany.sca.contribution.processor.ContributionResolveException;
-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.URLArtifactProcessorExtensionPoint;
-import org.apache.tuscany.sca.contribution.resolver.ClassReference;
-import org.apache.tuscany.sca.contribution.resolver.DefaultModelResolver;
-import org.apache.tuscany.sca.contribution.resolver.ExtensibleModelResolver;
-import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.contribution.resolver.ModelResolverExtensionPoint;
-import org.apache.tuscany.sca.contribution.scanner.ContributionScanner;
-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;
-
-/**
- * URLArtifactProcessor that handles contribution files and returns a contribution
- * info model.
- *
- * @version $Rev$ $Date$
- */
-public class ContributionInfoProcessor implements URLArtifactProcessor<Contribution>{
- private ContributionFactory contributionFactory;
- private ModelResolverExtensionPoint modelResolvers;
- 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(FactoryExtensionPoint.class);
- this.modelResolvers = extensionPoints.getExtensionPoint(ModelResolverExtensionPoint.class);
- hackResolvers(modelResolvers);
- URLArtifactProcessorExtensionPoint artifactProcessors = extensionPoints.getExtensionPoint(URLArtifactProcessorExtensionPoint.class);
- this.artifactProcessors = artifactProcessors;
- this.artifactProcessor = new ExtensibleURLArtifactProcessor(artifactProcessors, monitor);
- this.extensionProcessor = extensionProcessor;
- this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
- }
-
- public ContributionInfoProcessor(FactoryExtensionPoint modelFactories, ModelResolverExtensionPoint modelResolvers, URLArtifactProcessor<Object> artifactProcessor) {
- this.modelFactories = modelFactories;
- this.modelResolvers = modelResolvers;
- hackResolvers(modelResolvers);
- this.artifactProcessor = artifactProcessor;
- this.contributionFactory = modelFactories.getFactory(ContributionFactory.class);
- }
-
- public String getArtifactType() {
- return ".contribution/info";
- }
-
- public Class<Contribution> getModelType() {
- return null;
- }
-
- public Contribution read(URL parentURL, URI contributionURI, URL contributionURL) throws ContributionReadException {
-
- // Create contribution model
- Contribution contribution = contributionFactory.createContribution();
- contribution.setURI(contributionURI.toString());
- contribution.setLocation(contributionURL.toString());
- ModelResolver modelResolver = new ExtensibleModelResolver(contribution, modelResolvers, modelFactories);
- contribution.setModelResolver(modelResolver);
- contribution.setUnresolved(true);
-
- // Create a contribution scanner
- ContributionScanner scanner;
- if ("file".equals(contributionURL.getProtocol()) && new File(contributionURL.getFile()).isDirectory()) {
- scanner = new DirectoryContributionScanner();
- } else {
- scanner = new JarContributionScanner();
- }
-
- // Read generated and user sca-contribution.xml files
- boolean contributionMetadata = false;
- for (String path: new String[]{
- Contribution.SCA_CONTRIBUTION_GENERATED_META,
- Contribution.SCA_CONTRIBUTION_META}) {
- URL url = scanner.getArtifactURL(contributionURL, path);
- try {
- // Check if the file actually exists before trying to read it
- URLConnection connection = url.openConnection();
- connection.setUseCaches(false);
- InputStream is = connection.getInputStream();
- is.close();
- } catch (IOException e) {
- continue;
- }
- contributionMetadata = true;
-
- // Read the sca-contribution.xml file
- ContributionMetadata c = (ContributionMetadata)artifactProcessor.read(contributionURL, URI.create(path), url);
- contribution.getImports().addAll(c.getImports());
- contribution.getExports().addAll(c.getExports());
- contribution.getDeployables().addAll(c.getDeployables());
- }
-
- // If no sca-contribution.xml file was provided then consider
- // all composites in the contribution as deployables, and also
- // read any files that are explicitly asssigned artifact processors
- // as they are likely to provide relevant metadata info
- if (!contributionMetadata) {
- List<String> artifactURIs;
- try {
- artifactURIs = scanner.getArtifacts(contributionURL);
- } catch (ContributionReadException e) {
- artifactURIs = null;
- }
- if (artifactURIs != null) {
- for (String artifactURI: artifactURIs) {
- boolean read = false;
- if (artifactURI.endsWith(".composite")) {
- read = true;
- } else {
- int s= artifactURI.lastIndexOf("/");
- String fileName = artifactURI.substring(s + 1);
- if (artifactProcessors.getProcessor(fileName) != null) {
- read = true;
- }
- }
- if (read) {
- URL artifactURL = scanner.getArtifactURL(contributionURL, artifactURI);
-
- // Read each artifact
- Object model = artifactProcessor.read(contributionURL, URI.create(artifactURI), artifactURL);
-
- // In the absence of more info, consider all composites as deployable
- if (model instanceof Composite) {
- contribution.getDeployables().add((Composite)model);
- }
- }
- }
- }
-
- // Add default contribution import and export
- DefaultImport defaultImport = contributionFactory.createDefaultImport();
- defaultImport.setModelResolver(new DefaultModelResolver());
- contribution.getImports().add(defaultImport);
- DefaultExport defaultExport = contributionFactory.createDefaultExport();
- contribution.getExports().add(defaultExport);
- }
-
- return contribution;
- }
-
- public void resolve(Contribution contribution, ModelResolver resolver) throws ContributionResolveException {
-
- // Mark the contribution model resolved
- 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);
-
- } else {
- extensionProcessor.resolve(export, contributionResolver);
- }
- }
- for (Import import_: contribution.getImports()) {
- extensionProcessor.resolve(import_, contributionResolver);
- }
-
- }
-
- /**
- * FIXME Temporary hack for testing the ClassLoaderModelResolver.
- *
- * @param modelResolvers
- */
- private static void hackResolvers(ModelResolverExtensionPoint modelResolvers) {
- Class<?> resolverClass = modelResolvers.getResolver(ClassReference.class);
- if (resolverClass==null || !resolverClass.getName().equals("org.apache.tuscany.sca.contribution.java.impl.ClassLoaderModelResolver")) {
- try {
- Class<?> loaderResolverClass = Class.forName("org.apache.tuscany.sca.contribution.java.impl.ClassLoaderModelResolver", true, ContributionContentProcessor.class.getClassLoader());
- modelResolvers.addResolver(ClassReference.class, (Class<? extends ModelResolver>)loaderResolverClass);
- } catch (ClassNotFoundException e) {
- }
- }
- }
-}
diff --git a/branches/2.0-M2/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/scanner/impl/DirectoryContributionScanner.java b/branches/2.0-M2/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/scanner/impl/DirectoryContributionScanner.java
deleted file mode 100644
index cc51ff5823..0000000000
--- a/branches/2.0-M2/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/scanner/impl/DirectoryContributionScanner.java
+++ /dev/null
@@ -1,107 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.tuscany.sca.workspace.scanner.impl;
-
-import java.io.File;
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URISyntaxException;
-import java.net.URL;
-import java.util.ArrayList;
-import java.util.List;
-
-import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
-import org.apache.tuscany.sca.contribution.scanner.ContributionScanner;
-
-/**
- * Folder contribution processor.
- *
- * @version $Rev$ $Date$
- */
-public class DirectoryContributionScanner implements ContributionScanner {
-
- public DirectoryContributionScanner() {
- }
-
- public String getContributionType() {
- return "application/vnd.tuscany.folder";
- }
-
- public URL getArtifactURL(URL contributionURL, String artifact) throws ContributionReadException {
- File directory = directory(contributionURL);
- File file = new File(directory, artifact);
- try {
- return file.toURI().toURL();
- } catch (MalformedURLException e) {
- throw new ContributionReadException(e);
- }
- }
-
- public List<String> getArtifacts(URL contributionURL) throws ContributionReadException {
- File directory = directory(contributionURL);
- List<String> artifacts = new ArrayList<String>();
- try {
- traverse(artifacts, directory, directory);
- } catch (IOException e) {
- throw new ContributionReadException(e);
- }
- return artifacts;
- }
-
- /**
- * Recursively traverse a root directory
- *
- * @param fileList
- * @param file
- * @param root
- * @throws IOException
- */
- private static void traverse(List<String> fileList, File file, File root) throws IOException {
- if (file.isFile()) {
- fileList.add(root.toURI().relativize(file.toURI()).toString());
- } else if (file.isDirectory()) {
- String uri = root.toURI().relativize(file.toURI()).toString();
- if (uri.endsWith("/")) {
- uri = uri.substring(0, uri.length() - 1);
- }
- fileList.add(uri);
-
- File[] files = file.listFiles();
- for (File f: files) {
- if (!f.getName().startsWith(".")) {
- traverse(fileList, f, root);
- }
- }
- }
- }
-
- private static File directory(URL url) throws ContributionReadException {
- File file;
- try {
- file = new File(url.toURI());
- } catch (URISyntaxException e) {
- throw new ContributionReadException(e);
- }
- if (!file.exists() || !file.isDirectory()) {
- throw new ContributionReadException(url.toString());
- }
- return file;
- }
-}
diff --git a/branches/2.0-M2/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/scanner/impl/JarContributionScanner.java b/branches/2.0-M2/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/scanner/impl/JarContributionScanner.java
deleted file mode 100644
index 71bd9d760d..0000000000
--- a/branches/2.0-M2/modules/workspace-impl/src/main/java/org/apache/tuscany/sca/workspace/scanner/impl/JarContributionScanner.java
+++ /dev/null
@@ -1,121 +0,0 @@
-/*
- * 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.
- */
-
-package org.apache.tuscany.sca.workspace.scanner.impl;
-
-import java.io.IOException;
-import java.net.MalformedURLException;
-import java.net.URL;
-import java.net.URLConnection;
-import java.util.ArrayList;
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-import java.util.jar.JarEntry;
-import java.util.jar.JarInputStream;
-
-import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
-import org.apache.tuscany.sca.contribution.scanner.ContributionScanner;
-
-/**
- * JAR Contribution processor.
- *
- * @version $Rev$ $Date$
- */
-public class JarContributionScanner implements ContributionScanner {
-
- public JarContributionScanner() {
- }
-
- public String getContributionType() {
- return "application/x-compressed";
- }
-
- public URL getArtifactURL(URL contributionURL, String artifact) throws ContributionReadException {
- try {
- URL url;
- if (contributionURL.toString().startsWith("jar:")) {
- url = new URL(contributionURL, artifact.toString());
- } else {
- url = new URL("jar:" + contributionURL.toExternalForm() + "!/" + artifact);
- }
- return url;
- } catch (MalformedURLException e) {
- throw new ContributionReadException(e);
- }
- }
-
- public List<String> getArtifacts(URL contributionURL) throws ContributionReadException {
-
- // Assume the URL references a JAR file
- try {
- URLConnection connection = contributionURL.openConnection();
- connection.setUseCaches(false);
- JarInputStream jar = new JarInputStream(connection.getInputStream());
- try {
- Set<String> names = new HashSet<String>();
- while (true) {
- JarEntry entry = jar.getNextJarEntry();
- if (entry == null) {
- // EOF
- break;
- }
-
- String name = entry.getName();
- if (name.length() != 0 && !name.startsWith(".")) {
-
- // Trim trailing /
- if (name.endsWith("/")) {
- name = name.substring(0, name.length() - 1);
- }
-
- // Add the entry name
- if (!names.contains(name)) {
- names.add(name);
-
- // Add parent folder names to the list too
- for (;;) {
- int s = name.lastIndexOf('/');
- if (s == -1) {
- name = "";
- } else {
- name = name.substring(0, s);
- }
- if (name.length() != 0 && !names.contains(name)) {
- names.add(name);
- } else {
- break;
- }
- }
- }
- }
- }
-
- // Return list of URIs
- List<String> artifacts = new ArrayList<String>(names);
- return artifacts;
-
- } finally {
- jar.close();
- }
- } catch (IOException e) {
- throw new ContributionReadException(e);
- }
- }
-}
diff --git a/branches/2.0-M2/modules/workspace-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor b/branches/2.0-M2/modules/workspace-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
deleted file mode 100644
index 41d0ebe27d..0000000000
--- a/branches/2.0-M2/modules/workspace-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.URLArtifactProcessor
+++ /dev/null
@@ -1,20 +0,0 @@
-# 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.
-
-# Implementation class for the artifact processor extension
-org.apache.tuscany.sca.workspace.processor.impl.ContributionContentProcessor;type=.contribution/content,model=org.apache.tuscany.sca.contribution.Contribution
-org.apache.tuscany.sca.workspace.processor.impl.ContributionInfoProcessor;type=.contribution/info
diff --git a/branches/2.0-M2/modules/workspace-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.workspace.builder.ContributionBuilder b/branches/2.0-M2/modules/workspace-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.workspace.builder.ContributionBuilder
deleted file mode 100644
index 379d0a017e..0000000000
--- a/branches/2.0-M2/modules/workspace-impl/src/main/resources/META-INF/services/org.apache.tuscany.sca.workspace.builder.ContributionBuilder
+++ /dev/null
@@ -1,18 +0,0 @@
-# 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/2.0-M2/modules/workspace-impl/src/main/resources/workspace-validation-messages.properties b/branches/2.0-M2/modules/workspace-impl/src/main/resources/workspace-validation-messages.properties
deleted file mode 100644
index 0c07a3a30f..0000000000
--- a/branches/2.0-M2/modules/workspace-impl/src/main/resources/workspace-validation-messages.properties
+++ /dev/null
@@ -1,22 +0,0 @@
-#
-#
-# 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.
-#
-#
-
-UnresolvedImport = Unresolved import: Import = {0}
diff --git a/branches/2.0-M2/modules/workspace-impl/src/main/resources/workspace-validation-messages_it.properties b/branches/2.0-M2/modules/workspace-impl/src/main/resources/workspace-validation-messages_it.properties
deleted file mode 100644
index 2e8326c062..0000000000
--- a/branches/2.0-M2/modules/workspace-impl/src/main/resources/workspace-validation-messages_it.properties
+++ /dev/null
@@ -1,21 +0,0 @@
-#
-#
-# 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.
-#
-#
-