summaryrefslogtreecommitdiffstats
path: root/branches/sca-equinox/modules/contribution/src
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2008-10-13 16:31:59 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2008-10-13 16:31:59 +0000
commitfa49d1ac49867136d3f62a401cc6c9ad10b2b66f (patch)
tree30e54c612b82f73d2bed793a16287759a83921f5 /branches/sca-equinox/modules/contribution/src
parent00ac1c9de1e634b51cede3c5e2a449b7fff86543 (diff)
Refactored contribution exceptions, moved them to the contribution.processor package which is exported out of the contribution module. Removed unused implementation classes. Moved test cases from contribution-impl to contribution. Also renamed a few test cases that had compile errors as easymock is not on the classpath.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@704156 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to '')
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ArtifactProcessor.java1
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionException.java (renamed from branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionException.java)2
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionReadException.java (renamed from branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionReadException.java)3
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionResolveException.java (renamed from branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionResolveException.java)3
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionRuntimeException.java (renamed from branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRuntimeException.java)2
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionWriteException.java (renamed from branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionWriteException.java)3
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultPackageProcessorExtensionPoint.java129
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java3
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java3
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java2
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensiblePackageProcessor.java99
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java4
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXAttributeProcessor.java3
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleURLArtifactProcessor.java3
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/PackageProcessor.java70
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/PackageProcessorExtensionPoint.java50
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessor.java2
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessor.java2
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessor.java1
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnrecognizedElementException.java (renamed from branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnrecognizedElementException.java)2
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnsupportedContentTypeException.java (renamed from branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnsupportedContentTypeException.java)3
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnsupportedPackageTypeException.java (renamed from branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnsupportedPackageTypeException.java)3
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScanner.java2
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java2
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListener.java58
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListenerExtensionPoint.java44
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRepository.java128
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionService.java137
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/DefaultContributionListenerExtensionPoint.java118
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ExtensibleContributionListener.java77
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.PackageProcessorExtensionPoint18
-rw-r--r--branches/sca-equinox/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListenerExtensionPoint18
-rw-r--r--branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/processor/URLartifactProcessorExtensionPointTestCase.java113
-rw-r--r--branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverTestCase.java91
-rw-r--r--branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java133
-rw-r--r--branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/TestModelResolver.java58
-rw-r--r--branches/sca-equinox/modules/contribution/src/test/resources/deployables/sample-calculator.jarbin0 -> 26901 bytes
-rw-r--r--branches/sca-equinox/modules/contribution/src/test/resources/repository/sample-calculator.jarbin0 -> 29164 bytes
-rw-r--r--branches/sca-equinox/modules/contribution/src/test/resources/test.composite (renamed from branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/TypeDescriber.java)60
-rw-r--r--branches/sca-equinox/modules/contribution/src/test/resources/test.ext0
40 files changed, 432 insertions, 1018 deletions
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ArtifactProcessor.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ArtifactProcessor.java
index b5f536c431..5be0b188f4 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ArtifactProcessor.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ArtifactProcessor.java
@@ -19,7 +19,6 @@
package org.apache.tuscany.sca.contribution.processor;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
/**
* Base interface for artifact processors.
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionException.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionException.java
index e183206894..3b99eba586 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionException.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionException.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.sca.contribution.service;
+package org.apache.tuscany.sca.contribution.processor;
/**
* Base class for exceptions raised by contribution services.
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionReadException.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionReadException.java
index 33399dcc2f..6fd7d0c91e 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionReadException.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionReadException.java
@@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.sca.contribution.service;
+package org.apache.tuscany.sca.contribution.processor;
+
/**
* Denotes an exception while reading artifacts inside an SCA contribution.
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionResolveException.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionResolveException.java
index ecb774ac0c..fe1a09d398 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionResolveException.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionResolveException.java
@@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.sca.contribution.service;
+package org.apache.tuscany.sca.contribution.processor;
+
/**
* Denotes a problem while resolving models inside an SCA contribution.
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRuntimeException.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionRuntimeException.java
index 4bf29a3993..0039dd9f8b 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRuntimeException.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionRuntimeException.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.sca.contribution.service;
+package org.apache.tuscany.sca.contribution.processor;
/**
* Base class for runtime exceptions raised by contribution services.
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionWriteException.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionWriteException.java
index 8bfdedf180..286c9dc791 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionWriteException.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ContributionWriteException.java
@@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.sca.contribution.service;
+package org.apache.tuscany.sca.contribution.processor;
+
/**
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultPackageProcessorExtensionPoint.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultPackageProcessorExtensionPoint.java
deleted file mode 100644
index 589bcc9d92..0000000000
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultPackageProcessorExtensionPoint.java
+++ /dev/null
@@ -1,129 +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.contribution.processor;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.lang.reflect.Constructor;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-import java.util.HashMap;
-import java.util.List;
-import java.util.Map;
-import java.util.Set;
-
-import org.apache.tuscany.sca.contribution.service.ContributionException;
-import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
-import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
-
-/**
- * Default implementation of a package processor extension point.
- *
- * @version $Rev$ $Date$
- */
-public class DefaultPackageProcessorExtensionPoint implements PackageProcessorExtensionPoint {
-
- private Map<String, PackageProcessor> processors = new HashMap<String, PackageProcessor>();
- private boolean loaded;
-
- public DefaultPackageProcessorExtensionPoint() {
- }
-
- public void addPackageProcessor(PackageProcessor processor) {
- processors.put(processor.getPackageType(), processor);
- }
-
- public void removePackageProcessor(PackageProcessor processor) {
- processors.remove(processor.getPackageType());
- }
-
- public PackageProcessor getPackageProcessor(String contentType) {
- loadProcessors();
- return processors.get(contentType);
- }
-
- private void loadProcessors() {
- if (loaded)
- return;
-
- // Get the processor service declarations
- Set<ServiceDeclaration> processorDeclarations;
- try {
- processorDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(PackageProcessor.class.getName());
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
-
- for (ServiceDeclaration processorDeclaration: processorDeclarations) {
- Map<String, String> attributes = processorDeclaration.getAttributes();
-
- // Load a URL artifact processor
- String packageType = attributes.get("type");
-
- // Create a processor wrapper and register it
- PackageProcessor processor = new LazyPackageProcessor(packageType, processorDeclaration);
- addPackageProcessor(processor);
- }
-
- loaded = true;
- }
-
- /**
- * A facade for package processors.
- */
- private static class LazyPackageProcessor implements PackageProcessor {
-
- private ServiceDeclaration processorDeclaration;
- private String packageType;
- private PackageProcessor processor;
-
- private LazyPackageProcessor(String packageType, ServiceDeclaration processorDeclaration) {
- this.processorDeclaration = processorDeclaration;
- this.packageType = packageType;
- }
-
- public URL getArtifactURL(URL packageSourceURL, URI artifact) throws MalformedURLException {
- return getProcessor().getArtifactURL(packageSourceURL, artifact);
- }
-
- public List<URI> getArtifacts(URL packageSourceURL, InputStream inputStream) throws ContributionException, IOException {
- return getProcessor().getArtifacts(packageSourceURL, inputStream);
- }
-
- public String getPackageType() {
- return packageType;
- }
-
- @SuppressWarnings("unchecked")
- private PackageProcessor getProcessor() {
- if (processor == null) {
- try {
- Class<PackageProcessor> processorClass = (Class<PackageProcessor>)processorDeclaration.loadClass();
- Constructor<PackageProcessor> constructor = processorClass.getConstructor();
- processor = constructor.newInstance();
- } catch (Exception e) {
- throw new IllegalStateException(e);
- }
- }
- return processor;
- }
- }
-}
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java
index e2995b3868..70e36fba82 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXArtifactProcessorExtensionPoint.java
@@ -32,9 +32,6 @@ import javax.xml.stream.XMLStreamWriter;
import org.apache.tuscany.sca.assembly.AssemblyFactory;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.contribution.service.ContributionReadException;
-import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
-import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java
index 5fbe2b3a52..bd9b106e88 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultStAXAttributeProcessorExtensionPoint.java
@@ -31,9 +31,6 @@ import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.contribution.service.ContributionReadException;
-import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
-import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
import org.apache.tuscany.sca.core.ExtensionPointRegistry;
import org.apache.tuscany.sca.core.FactoryExtensionPoint;
import org.apache.tuscany.sca.core.UtilityExtensionPoint;
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java
index e4c6152bc4..baa9d458b9 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/DefaultURLArtifactProcessorExtensionPoint.java
@@ -29,8 +29,6 @@ import javax.xml.stream.XMLInputFactory;
import javax.xml.stream.XMLOutputFactory;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-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;
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensiblePackageProcessor.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensiblePackageProcessor.java
deleted file mode 100644
index 3c1f76f295..0000000000
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensiblePackageProcessor.java
+++ /dev/null
@@ -1,99 +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.contribution.processor;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-import java.util.List;
-
-import org.apache.tuscany.sca.contribution.service.ContributionException;
-import org.apache.tuscany.sca.contribution.service.TypeDescriber;
-import org.apache.tuscany.sca.contribution.service.UnsupportedPackageTypeException;
-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;
-
-/**
- * Implementation of an extensible package processor.
- *
- * Takes a package processor extension point and delegates to the proper package
- * processor from the extension point based on the package's content type.
- *
- * @version $Rev$ $Date$
- */
-public class ExtensiblePackageProcessor implements PackageProcessor {
-
- private PackageProcessorExtensionPoint processors;
- private TypeDescriber packageTypeDescriber;
- private Monitor monitor;
-
- public ExtensiblePackageProcessor(PackageProcessorExtensionPoint processors,
- TypeDescriber packageTypeDescriber,
- Monitor monitor) {
- this.processors = processors;
- this.packageTypeDescriber = packageTypeDescriber;
- this.monitor = monitor;
- }
-
- /**
- * Marshals errors into the monitor
- *
- * @param problems
- * @param message
- * @param model
- */
- protected void error(String message, Object model, Object... messageParameters) {
- if (monitor != null) {
- Problem problem = monitor.createProblem(this.getClass().getName(), "contribution-validation-messages", Severity.ERROR, model, message, (Object[])messageParameters);
- monitor.problem(problem);
- }
- }
-
- public List<URI> getArtifacts(URL packageSourceURL, InputStream inputStream)
- throws ContributionException, IOException {
- String packageType = this.packageTypeDescriber.getType(packageSourceURL, null);
- if (packageType == null) {
- error("UnsupportedPackageTypeException", packageTypeDescriber, packageSourceURL.toString());
- throw new UnsupportedPackageTypeException("Unsupported contribution package type: " + packageSourceURL.toString());
- }
-
- PackageProcessor packageProcessor = this.processors.getPackageProcessor(packageType);
- if (packageProcessor == null) {
- error("UnsupportedPackageTypeException", packageTypeDescriber, packageType);
- throw new UnsupportedPackageTypeException("Unsupported contribution package type: " + packageType);
- }
-
- return packageProcessor.getArtifacts(packageSourceURL, inputStream);
- }
-
- public URL getArtifactURL(URL packageSourceURL, URI artifact) throws MalformedURLException {
- String contentType = this.packageTypeDescriber.getType(packageSourceURL, null);
- PackageProcessor packageProcessor = this.processors.getPackageProcessor(contentType);
- return packageProcessor.getArtifactURL(packageSourceURL, artifact);
- }
-
- public String getPackageType() {
- return null;
- }
-}
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java
index 29cd14d70f..8c7c938fb2 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXArtifactProcessor.java
@@ -35,10 +35,6 @@ import javax.xml.stream.XMLStreamWriter;
import org.apache.tuscany.sca.contribution.Constants;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.contribution.service.ContributionReadException;
-import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
-import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
-import org.apache.tuscany.sca.contribution.service.UnrecognizedElementException;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.Problem.Severity;
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXAttributeProcessor.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXAttributeProcessor.java
index 58fd32e25a..b3356ea957 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXAttributeProcessor.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleStAXAttributeProcessor.java
@@ -34,9 +34,6 @@ import javax.xml.stream.XMLStreamWriter;
import org.apache.tuscany.sca.contribution.Constants;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.contribution.service.ContributionReadException;
-import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
-import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.Problem.Severity;
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleURLArtifactProcessor.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleURLArtifactProcessor.java
index c50fcc1f5e..7f6ebbd0ba 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleURLArtifactProcessor.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/ExtensibleURLArtifactProcessor.java
@@ -22,9 +22,6 @@ import java.net.URI;
import java.net.URL;
import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-import org.apache.tuscany.sca.contribution.service.ContributionReadException;
-import org.apache.tuscany.sca.contribution.service.ContributionResolveException;
-import org.apache.tuscany.sca.contribution.service.UnrecognizedElementException;
import org.apache.tuscany.sca.monitor.Monitor;
import org.apache.tuscany.sca.monitor.Problem;
import org.apache.tuscany.sca.monitor.Problem.Severity;
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/PackageProcessor.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/PackageProcessor.java
deleted file mode 100644
index f17f31edb1..0000000000
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/PackageProcessor.java
+++ /dev/null
@@ -1,70 +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.contribution.processor;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.MalformedURLException;
-import java.net.URI;
-import java.net.URL;
-import java.util.List;
-
-import org.apache.tuscany.sca.contribution.service.ContributionException;
-
-/**
- * Interface for contribution package processors
- *
- * Package processors understand the format of the contribution and how to get the
- * artifacts in the contribution.
- *
- * @version $Rev$ $Date$
- */
-public interface PackageProcessor {
-
- /**
- * Returns the type of package supported by this package processor.
- *
- * @return the package type
- */
- String getPackageType();
-
- /**
- * Returns a list of artifacts in the contribution.
- *
- * @param packageSourceURL Contribution package location URL
- * @param inputStream Optional content of the package
- * @return List of artifact URIs
- * @throws ContributionException
- * @throws IOException
- */
- List<URI> getArtifacts(URL packageSourceURL, InputStream inputStream) throws ContributionException, IOException;
-
- /**
- * Return the URL for an artifact in the package.
- *
- * This is needed for archives such as jar files that have specific URL schemes
- * for the artifacts they contain.
- *
- * @param packageSourceURL Contribution package location URL
- * @param artifact The relative URI for the artifact
- * @return The artifact URL
- */
- URL getArtifactURL(URL packageSourceURL, URI artifact) throws MalformedURLException;
-
-}
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/PackageProcessorExtensionPoint.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/PackageProcessorExtensionPoint.java
deleted file mode 100644
index ed99239b19..0000000000
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/PackageProcessorExtensionPoint.java
+++ /dev/null
@@ -1,50 +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.contribution.processor;
-
-/**
- * An extension point for package processors
- *
- * @version $Rev$ $Date$
- */
-public interface PackageProcessorExtensionPoint {
-
- /**
- * Register a PackageProcessor using the package type as the key.
- *
- * @param processor The package processor
- */
- void addPackageProcessor(PackageProcessor processor);
-
- /**
- * Unregister a PackageProcessor.
- *
- * @param processor The package processor
- */
- void removePackageProcessor(PackageProcessor processor);
-
- /**
- * Returns the PackageProcessor for the given package type.
- *
- * @param packageType The package type
- * @return The package processor
- */
- PackageProcessor getPackageProcessor(String packageType);
-
-} \ No newline at end of file
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessor.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessor.java
index fcf9347564..1bf9b4d494 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessor.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXArtifactProcessor.java
@@ -24,8 +24,6 @@ import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
-import org.apache.tuscany.sca.contribution.service.ContributionReadException;
-import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
/**
* An artifact processor that can read models from a StAX XMLStreamReader.
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessor.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessor.java
index e8edb743a4..b25bf0d669 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessor.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/StAXAttributeProcessor.java
@@ -24,8 +24,6 @@ import javax.xml.stream.XMLStreamException;
import javax.xml.stream.XMLStreamReader;
import javax.xml.stream.XMLStreamWriter;
-import org.apache.tuscany.sca.contribution.service.ContributionReadException;
-import org.apache.tuscany.sca.contribution.service.ContributionWriteException;
/**
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessor.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessor.java
index 2ecddf5465..c44ca0c66a 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessor.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/URLArtifactProcessor.java
@@ -22,7 +22,6 @@ package org.apache.tuscany.sca.contribution.processor;
import java.net.URI;
import java.net.URL;
-import org.apache.tuscany.sca.contribution.service.ContributionReadException;
/**
* An artifact processor that can read models from a URL.
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnrecognizedElementException.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnrecognizedElementException.java
index ff21c894de..4c6f0b7282 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnrecognizedElementException.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnrecognizedElementException.java
@@ -16,7 +16,7 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.sca.contribution.service;
+package org.apache.tuscany.sca.contribution.processor;
import javax.xml.namespace.QName;
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnsupportedContentTypeException.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnsupportedContentTypeException.java
index 0660d69897..8a166e42f0 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnsupportedContentTypeException.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnsupportedContentTypeException.java
@@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.sca.contribution.service;
+package org.apache.tuscany.sca.contribution.processor;
+
/**
* Exception thrown to indicate that a Content-Type is not supported by this SCA Domain.
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnsupportedPackageTypeException.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnsupportedPackageTypeException.java
index 33c847a049..ce94cef6a0 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnsupportedPackageTypeException.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/processor/UnsupportedPackageTypeException.java
@@ -16,7 +16,8 @@
* specific language governing permissions and limitations
* under the License.
*/
-package org.apache.tuscany.sca.contribution.service;
+package org.apache.tuscany.sca.contribution.processor;
+
/**
* Exception thrown to indicate that a Content-Type is not supported by this SCA Domain.
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScanner.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScanner.java
index 2d03381c8a..69db8f40cb 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScanner.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/ContributionScanner.java
@@ -21,7 +21,7 @@ package org.apache.tuscany.sca.contribution.scanner;
import java.net.URL;
import java.util.List;
-import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
/**
* Interface for contribution package scanners
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java
index 7610cb5aba..cf3c77d5eb 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java
+++ b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/scanner/DefaultContributionScannerExtensionPoint.java
@@ -27,7 +27,7 @@ import java.util.List;
import java.util.Map;
import java.util.Set;
-import org.apache.tuscany.sca.contribution.service.ContributionReadException;
+import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListener.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListener.java
deleted file mode 100644
index 5158eaf85c..0000000000
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListener.java
+++ /dev/null
@@ -1,58 +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.contribution.service;
-
-import java.util.EventListener;
-
-import org.apache.tuscany.sca.contribution.Contribution;
-
-/**
- * A listener interface used to listen to contribution repository events.
- *
- * @version $Rev$ $Date$
- */
-public interface ContributionListener extends EventListener {
-
- /**
- * Notifies the listener that a contribution has been added.
- *
- * @param repository The contribution repository
- * @param contribution The new contribution
- */
- void contributionAdded(ContributionRepository repository, Contribution contribution);
-
- /**
- * Notifies the listener that a contribution has been removed.
- *
- * @param repository The contribution repository
- * @param contribution The removed contribution.
- */
- void contributionRemoved(ContributionRepository repository, Contribution contribution);
-
- /**
- * Notifies the listener that a contribution has been updated.
- *
- * @param repository The contribution repository
- * @param oldContribution The old contribution
- * @param contribution The new contribution
- */
- void contributionUpdated(ContributionRepository repository, Contribution oldContribution, Contribution contribution);
-
-}
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListenerExtensionPoint.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListenerExtensionPoint.java
deleted file mode 100644
index ce2b4b13c3..0000000000
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListenerExtensionPoint.java
+++ /dev/null
@@ -1,44 +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.contribution.service;
-
-import java.util.List;
-
-public interface ContributionListenerExtensionPoint {
-
- /**
- * Adds a contribution repository listener extension.
- * @param listener The listener to add
- */
- void addContributionListener(ContributionListener listener);
-
- /**
- * Removes a contribution repository listener extension.
- * @param listener The listener to remove
- */
- void removeContributionListener(ContributionListener listener);
-
- /**
- * Returns the contribution repository listeners.
- * @return
- */
- List<ContributionListener> getContributionListeners();
-
-}
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRepository.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRepository.java
deleted file mode 100644
index d7d8216f66..0000000000
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRepository.java
+++ /dev/null
@@ -1,128 +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.contribution.service;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URI;
-import java.net.URL;
-import java.util.List;
-
-import org.apache.tuscany.sca.contribution.Contribution;
-
-/**
- * Contribution repository
- *
- * @version $Rev$ $Date$
- */
-public interface ContributionRepository {
-
- /**
- * Get the URI of the SCA domain
- *
- * @return The domain URI
- */
- URI getDomain();
-
- /**
- * Copies a contribution to the repository.
- *
- * @param contribution A URl pointing to the contribution being copied to
- * the repository
- * @param sourceURL URL of the source. this would be used to calculate the right
- * filename to be stored on the repository when a inputStream is being
- * provided
- * @param contributionStream InputStream with the content of the
- * distribution
- * @return A URL pointing to the content of the contribution in the
- * repository
- * @throws IOException
- */
- URL store(String contribution, URL sourceURL, InputStream contributionStream) throws IOException;
- /**
- * Copy a contribution from the source URL to the repository
- *
- * @param contribution A URl pointing to the contribution being copied to
- * the repository
- * @param sourceURL URL of the source. this would be used to calculate the right
- * filename to be stored on the repository when a inputStream is being
- * provided
- * @return A URL pointing to the content of the contribution in the
- * repository
- * @throws IOException
- */
- URL store(String contribution, URL sourceURL) throws IOException;
-
- /**
- * Look up the contribution by URI
- *
- * @param contribution The URI of the contribution
- * @return A URL pointing to the content of the contribution in the
- * repository, it will be null if the contribution cannot be found
- * in the repository
- */
- URL find(String contribution);
-
- /**
- * Remove a contribution from the repository
- *
- * @param contribution The URI of the contribution to be removed
- */
- void remove(String contribution);
-
- /**
- * Get list of URIs for all the contributions in the repository
- *
- * @return A list of contribution URIs
- */
- List<String> list();
-
- /**
- * Returns the contributions available in the repository.
- * @return The list of contributions.
- */
- List<Contribution> getContributions();
-
- /**
- * Adds a contribution to the repository.
- * @param contribution The new contribution.
- */
- void addContribution(Contribution contribution);
-
- /**
- * Removes a contribution from the repository.
- * @param contribution The contribution to remove
- */
- void removeContribution(Contribution contribution);
-
- /**
- * Updates a contribution in the repository
- * @param contribution The contribution to update
- */
- void updateContribution(Contribution contribution);
-
- /**
- * Returns the contribution with the given URI.
- * @param uri the URI of the contribution
- * @return The contribution
- */
- Contribution getContribution(String uri);
-
-}
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionService.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionService.java
deleted file mode 100644
index dcdb8733b8..0000000000
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionService.java
+++ /dev/null
@@ -1,137 +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.contribution.service;
-
-import java.io.IOException;
-import java.io.InputStream;
-import java.net.URL;
-
-import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.contribution.Contribution;
-import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
-
-/**
- * Service interface that manages artifacts contributed to a Tuscany runtime.
- *
- * @version $Rev$ $Date$
- */
-public interface ContributionService {
- /**
- * Contribute an artifact to the SCA Domain. The type of the contribution is
- * determined by the Content-Type of the resource or, if that is undefined,
- * by some implementation-specific means (such as mapping an extension in
- * the URL's path).
- *
- * @param contributionURI The URI that is used as the contribution unique ID.
- * @param sourceURL The location of the resource containing the artifact
- * @param storeInRepository Flag that identifies if you want to copy the
- * contribution to the repository
- * @return The contribution model representing the contribution
- * @throws ContributionException if there was a problem with the contribution
- * @throws IOException if there was a problem reading the resource
- */
- Contribution contribute(String contributionURI, URL sourceURL, boolean storeInRepository) throws ContributionException,
- IOException;
-
- /**
- * Contribute an artifact to the SCA Domain. The type of the contribution is
- * determined by the Content-Type of the resource or, if that is undefined,
- * by some implementation-specific means (such as mapping an extension in
- * the URL's path).
- *
- * @param contributionURI The URI that is used as the contribution unique ID.
- * @param sourceURL The location of the resource containing the artifact
- * @param modelResolver The model resolver to use to resolve models in the
- * scope of this contribution
- * @param storeInRepository Flag that identifies if you want to copy the
- * contribution to the repository
- * @return The contribution model representing the contribution
- * @throws ContributionException if there was a problem with the contribution
- * @throws IOException if there was a problem reading the resource
- */
- Contribution contribute(String contributionURI, URL sourceURL, ModelResolver modelResolver, boolean storeInRepository) throws ContributionException,
- IOException;
-
- /**
- * Contribute an artifact to the SCA Domain.
- *
- * @param contributionURI The URI that is used as the contribution unique ID.
- * @param sourceURL The location of the resource containing the artifact.
- * This is used to identify what name should be used when storing
- * the contribution on the repository
- * @param contributionContent A stream containing the resource being
- * contributed; the stream will not be closed but the read
- * position after the call is undefined
- * @return The contribution model representing the contribution
- * @throws ContributionException if there was a problem with the contribution
- * @throws IOException if there was a problem reading the stream
- */
- Contribution contribute(String contributionURI, URL sourceURL, InputStream contributionContent)
- throws ContributionException, IOException;
-
- /**
- * Contribute an artifact to the SCA Domain.
- *
- * @param contributionURI The URI that is used as the contribution unique ID.
- * @param sourceURL The location of the resource containing the artifact.
- * This is used to identify what name should be used when storing
- * the contribution on the repository
- * @param modelResolver The model resolver to use to resolve models in the
- * scope of this contribution
- * @param contributionContent A stream containing the resource being
- * contributed; the stream will not be closed but the read
- * position after the call is undefined
- * @return The contribution model representing the contribution
- * @throws ContributionException if there was a problem with the contribution
- * @throws IOException if there was a problem reading the stream
- */
- Contribution contribute(String contributionURI, URL sourceURL, InputStream contributionContent, ModelResolver modelResolver)
- throws ContributionException, IOException;
-
- /**
- * Get the model for an installed contribution
- *
- * @param contribution The URI of an installed contribution
- * @return The model for the contribution or null if there is no such
- * contribution
- */
- Contribution getContribution(String contribution);
-
- /**
- * Adds or updates a deployment composite using a supplied composite
- * ("composite by value" - a data structure, not an existing resource in the
- * domain) to the contribution identified by a supplied contribution URI.
- * The added or updated deployment composite is given a relative URI that
- * matches the "name" attribute of the composite, with a ".composite"
- * suffix.
- *
- * @param contribution The contribution to where
- * @param composite
- * @throws ContributionException
- */
- void addDeploymentComposite(Contribution contribution, Composite composite) throws ContributionException;
-
- /**
- * Remove a contribution from the SCA domain
- *
- * @param contribution The URI of the contribution
- * @throws DeploymentException
- */
- void remove(String contribution) throws ContributionException;
-} \ No newline at end of file
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/DefaultContributionListenerExtensionPoint.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/DefaultContributionListenerExtensionPoint.java
deleted file mode 100644
index 202fea0e34..0000000000
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/DefaultContributionListenerExtensionPoint.java
+++ /dev/null
@@ -1,118 +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.contribution.service;
-
-import java.io.IOException;
-import java.lang.reflect.Constructor;
-import java.lang.reflect.InvocationTargetException;
-import java.util.List;
-import java.util.Set;
-import java.util.concurrent.CopyOnWriteArrayList;
-
-import org.apache.tuscany.sca.core.ExtensionPointRegistry;
-import org.apache.tuscany.sca.core.FactoryExtensionPoint;
-import org.apache.tuscany.sca.extensibility.ServiceDeclaration;
-import org.apache.tuscany.sca.extensibility.ServiceDiscovery;
-
-/**
- * Default implementation of a contribution listener extension point.
- *
- * @version $Rev$ $Date$
- */
-public class DefaultContributionListenerExtensionPoint implements ContributionListenerExtensionPoint {
-
- private List<ContributionListener> listeners = new CopyOnWriteArrayList<ContributionListener>();
- private boolean loadedListeners;
- private FactoryExtensionPoint modelFactories;
-
- /**
- * Constructs a new DefaultContributionListenerExtensionPoint.
- *
- */
- public DefaultContributionListenerExtensionPoint(FactoryExtensionPoint modelFactories) {
- this.modelFactories = modelFactories;
- }
-
- /**
- * Constructs a new DefaultContributionListenerExtensionPoint.
- *
- */
- public DefaultContributionListenerExtensionPoint(ExtensionPointRegistry extensionPoints) {
- this.modelFactories = extensionPoints.getExtensionPoint(FactoryExtensionPoint.class);
- }
-
- public void addContributionListener(ContributionListener listener) {
- listeners.add(listener);
- }
-
- public List<ContributionListener> getContributionListeners() {
- loadListeners();
- return listeners;
- }
-
- public void removeContributionListener(ContributionListener listener) {
- listeners.remove(listener);
- }
-
- /**
- * Dynamically load listeners declared under META-INF/services
- */
- @SuppressWarnings("unchecked")
- private synchronized void loadListeners() {
- if (loadedListeners)
- return;
-
- // Get the listener service declarations
- Set<ServiceDeclaration> listenerDeclarations;
- try {
- listenerDeclarations = ServiceDiscovery.getInstance().getServiceDeclarations(ContributionListener.class.getName());
- } catch (IOException e) {
- throw new IllegalStateException(e);
- }
-
- // Load and instantiate the listeners
- for (ServiceDeclaration listenerDeclaration: listenerDeclarations) {
- ContributionListener listener;
- try {
- Class<ContributionListener> listenerClass = (Class<ContributionListener>)listenerDeclaration.loadClass();
- try {
- Constructor<ContributionListener> constructor = listenerClass.getConstructor(FactoryExtensionPoint.class);
- try {
- listener = constructor.newInstance(modelFactories);
- } catch (InvocationTargetException e) {
- throw new IllegalArgumentException(e);
- }
- } catch (NoSuchMethodException e) {
- listener = listenerClass.newInstance();
- }
- } catch (ClassNotFoundException e) {
- throw new IllegalArgumentException(e);
- } catch (InstantiationException e) {
- throw new IllegalArgumentException(e);
- } catch (IllegalAccessException e) {
- throw new IllegalArgumentException(e);
- }
- addContributionListener(listener);
- }
-
- loadedListeners = true;
- }
-
-}
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ExtensibleContributionListener.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ExtensibleContributionListener.java
deleted file mode 100644
index fc0dc3aa99..0000000000
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ExtensibleContributionListener.java
+++ /dev/null
@@ -1,77 +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.contribution.service;
-
-import org.apache.tuscany.sca.contribution.Contribution;
-
-public class ExtensibleContributionListener implements ContributionListener {
- private final ContributionListenerExtensionPoint listeners;
-
- /**
- * Default constructor receiving the listener extension point
- *
- * @param listeners
- */
- public ExtensibleContributionListener(ContributionListenerExtensionPoint listeners) {
- this.listeners = listeners;
- }
-
- /**
- * Process "contributionAdded" event to all registered listeners
- */
- public void contributionAdded(ContributionRepository repository, Contribution contribution) {
- for (ContributionListener listener : listeners.getContributionListeners()) {
- try {
- listener.contributionAdded(repository, contribution);
- } catch (Exception e) {
- // ignore, continue to the next listener
- }
- }
- }
-
- /**
- * Process "contributionRemoved" event to all registered listeners
- */
- public void contributionRemoved(ContributionRepository repository, Contribution contribution) {
- for (ContributionListener listener : listeners.getContributionListeners()) {
- try {
- listener.contributionRemoved(repository, contribution);
- } catch (Exception e) {
- // ignore, continue to the next listener
- }
-
- }
- }
-
- /**
- * Process "contributionUpdated" event to all registered listeners
- */
- public void contributionUpdated(ContributionRepository repository, Contribution oldContribution, Contribution contribution) {
- for (ContributionListener listener : listeners.getContributionListeners()) {
- try {
- listener.contributionUpdated(repository, oldContribution, contribution);
- } catch (Exception e) {
- // ignore, continue to the next listener
- }
-
- }
- }
-
-}
diff --git a/branches/sca-equinox/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.PackageProcessorExtensionPoint b/branches/sca-equinox/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.PackageProcessorExtensionPoint
deleted file mode 100644
index 7609eda0d1..0000000000
--- a/branches/sca-equinox/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.processor.PackageProcessorExtensionPoint
+++ /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.contribution.processor.DefaultPackageProcessorExtensionPoint
diff --git a/branches/sca-equinox/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListenerExtensionPoint b/branches/sca-equinox/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListenerExtensionPoint
deleted file mode 100644
index 6e61bebf79..0000000000
--- a/branches/sca-equinox/modules/contribution/src/main/resources/META-INF/services/org.apache.tuscany.sca.contribution.service.ContributionListenerExtensionPoint
+++ /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.contribution.service.DefaultContributionListenerExtensionPoint
diff --git a/branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/processor/URLartifactProcessorExtensionPointTestCase.java b/branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/processor/URLartifactProcessorExtensionPointTestCase.java
new file mode 100644
index 0000000000..14b6b956da
--- /dev/null
+++ b/branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/processor/URLartifactProcessorExtensionPointTestCase.java
@@ -0,0 +1,113 @@
+/*
+ * 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.contribution.processor;
+
+import static junit.framework.Assert.assertNotNull;
+
+import java.net.URI;
+import java.net.URL;
+
+import org.apache.tuscany.sca.contribution.resolver.ModelResolver;
+import org.apache.tuscany.sca.core.DefaultExtensionPointRegistry;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+import org.junit.BeforeClass;
+import org.junit.Test;
+
+/**
+ * URL Artifact Processor Extension Point test case
+ * Verifies the right registration and lookup for processors that handle filename and file types
+ *
+ * @version $Rev$ $Date$
+ */
+public class URLartifactProcessorExtensionPointTestCase {
+
+ private static URLArtifactProcessorExtensionPoint artifactProcessors;
+
+ @BeforeClass
+ public static void setUp() throws Exception {
+ ExtensionPointRegistry extensionPoints = new DefaultExtensionPointRegistry();
+ artifactProcessors = new DefaultURLArtifactProcessorExtensionPoint(extensionPoints);
+ artifactProcessors.addArtifactProcessor(new FileTypeArtifactProcessor());
+ artifactProcessors.addArtifactProcessor(new FileNameArtifactProcessor());
+ }
+
+ @Test
+ public final void testFileTypeProcessor() {
+ assertNotNull(artifactProcessors.getProcessor(".m1"));
+ }
+
+ @Test
+ public final void testFileNameProcessor() {
+ assertNotNull(artifactProcessors.getProcessor("file.m2"));
+
+ }
+
+ /**
+ * Internal mock classes
+ *
+ */
+
+ private class M1 {
+ }
+
+ private class M2 {
+ }
+
+ private static class FileTypeArtifactProcessor implements URLArtifactProcessor<M1> {
+ public FileTypeArtifactProcessor() {
+ }
+
+ public M1 read(URL contributionURL, URI uri, URL url) throws ContributionReadException {
+ return null;
+ }
+
+ public void resolve(M1 m1, ModelResolver resolver) throws ContributionResolveException {
+ }
+
+ public String getArtifactType() {
+ return ".m1";
+ }
+
+ public Class<M1> getModelType() {
+ return M1.class;
+ }
+ }
+
+ private static class FileNameArtifactProcessor implements URLArtifactProcessor<M2> {
+ public FileNameArtifactProcessor() {
+ }
+
+ public M2 read(URL contributionURL, URI uri, URL url) throws ContributionReadException {
+ return null;
+ }
+
+ public void resolve(M2 m2, ModelResolver resolver) throws ContributionResolveException {
+ }
+
+ public String getArtifactType() {
+ return "file.m2";
+ }
+
+ public Class<M2> getModelType() {
+ return M2.class;
+ }
+ }
+
+}
diff --git a/branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverTestCase.java b/branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverTestCase.java
new file mode 100644
index 0000000000..f5b04f503c
--- /dev/null
+++ b/branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/DefaultModelResolverTestCase.java
@@ -0,0 +1,91 @@
+/*
+ * 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.contribution.resolver;
+
+import static junit.framework.Assert.assertTrue;
+
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.DefaultContributionFactory;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test the default model resolver implementation.
+ *
+ * @version $Rev$ $Date$
+ */
+public class DefaultModelResolverTestCase {
+
+ private ModelResolver resolver;
+ private ContributionFactory factory;
+
+ @Before
+ public void setUp() throws Exception {
+ resolver = new DefaultModelResolver();
+ factory = new DefaultContributionFactory();
+ }
+
+ @Test
+ public void testResolved() {
+ Model a = new Model("a");
+ resolver.addModel(a);
+ Model x = new Model("a");
+ x = resolver.resolveModel(Model.class, x);
+ assertTrue(x == a);
+ }
+
+ @Test
+ public void testUnresolved() {
+ Model x = new Model("a");
+ Model y = resolver.resolveModel(Model.class, x);
+ assertTrue(x == y);
+ }
+
+ @Test
+ public void testResolvedArtifact() {
+ Artifact artifact = factory.createArtifact();
+ artifact.setURI("foo/bar");
+ resolver.addModel(artifact);
+ Artifact x = factory.createArtifact();
+ x.setURI("foo/bar");
+ x = resolver.resolveModel(Artifact.class, x);
+ assertTrue(x == artifact);
+ }
+
+ class Model {
+ private String name;
+
+ Model(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return name.equals(((Model)obj).name);
+ }
+ }
+
+}
diff --git a/branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java b/branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java
new file mode 100644
index 0000000000..5c6080d699
--- /dev/null
+++ b/branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/ExtensibleModelResolverTestCase.java
@@ -0,0 +1,133 @@
+/*
+* 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.contribution.resolver;
+
+import static junit.framework.Assert.assertTrue;
+
+import org.apache.tuscany.sca.contribution.Artifact;
+import org.apache.tuscany.sca.contribution.ContributionFactory;
+import org.apache.tuscany.sca.contribution.DefaultContributionFactory;
+import org.apache.tuscany.sca.core.DefaultFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+import org.junit.Before;
+import org.junit.Test;
+
+/**
+ * Test DefaultArtifactResolver.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ExtensibleModelResolverTestCase {
+ private ExtensibleModelResolver resolver;
+
+ private ContributionFactory factory;
+
+ @Before
+ public void setUp() throws Exception {
+
+ ModelResolverExtensionPoint resolvers = new DefaultModelResolverExtensionPoint();
+ resolvers.addResolver(Model.class, TestModelResolver.class);
+
+ FactoryExtensionPoint factories = new DefaultFactoryExtensionPoint();
+
+ resolver = new ExtensibleModelResolver(null, resolvers, factories, null);
+
+ factory = new DefaultContributionFactory();
+ }
+
+ @Test
+ public void testResolvedDefault() {
+ OtherModel a = new OtherModel("a");
+ resolver.addModel(a);
+ OtherModel x = new OtherModel("a");
+ x = resolver.resolveModel(OtherModel.class, x);
+ assertTrue(x == a);
+ }
+
+ @Test
+ public void testResolvedRegisteredClass() {
+ Model a = new Model("a");
+ resolver.addModel(a);
+ Model x = new Model("a");
+ x = resolver.resolveModel(Model.class, x);
+ assertTrue(x == a);
+ }
+
+ @Test
+ public void testUnresolvedDefault() {
+ OtherModel x = new OtherModel("a");
+ OtherModel y = resolver.resolveModel(OtherModel.class, x);
+ assertTrue(x == y);
+ }
+
+ @Test
+ public void testUnresolved() {
+ Model x = new Model("a");
+ Model y = resolver.resolveModel(Model.class, x);
+ assertTrue(x == y);
+ }
+
+ @Test
+ public void testResolvedArtifact() {
+ Artifact artifact = factory.createArtifact();
+ artifact.setURI("foo/bar");
+ resolver.addModel(artifact);
+ Artifact x = factory.createArtifact();
+ x.setURI("foo/bar");
+ x = resolver.resolveModel(Artifact.class, x);
+ assertTrue(x == artifact);
+ }
+
+ private class Model {
+ private String name;
+
+ Model(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return name.equals(((Model)obj).name);
+ }
+ }
+
+ private class OtherModel {
+ private String name;
+
+ OtherModel(String name) {
+ this.name = name;
+ }
+
+ @Override
+ public int hashCode() {
+ return name.hashCode();
+ }
+
+ @Override
+ public boolean equals(Object obj) {
+ return name.equals(((OtherModel)obj).name);
+ }
+ }
+}
diff --git a/branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/TestModelResolver.java b/branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/TestModelResolver.java
new file mode 100644
index 0000000000..cd586d3b2c
--- /dev/null
+++ b/branches/sca-equinox/modules/contribution/src/test/java/org/apache/tuscany/sca/contribution/resolver/TestModelResolver.java
@@ -0,0 +1,58 @@
+/*
+ * 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.contribution.resolver;
+
+import java.util.HashMap;
+import java.util.Map;
+
+import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.core.FactoryExtensionPoint;
+
+/**
+ * A test implementation of a model resolver, based on a map.
+ *
+ * @version $Rev$ $Date$
+ */
+public class TestModelResolver implements ModelResolver {
+
+ private Map<Object, Object> map = new HashMap<Object, Object>();
+
+ public TestModelResolver(Contribution contribution, FactoryExtensionPoint modelFactories) {
+ }
+
+ public <T> T resolveModel(Class<T> modelClass, T unresolved) {
+ Object resolved = map.get(unresolved);
+ if (resolved != null) {
+ // Return the resolved object
+ return modelClass.cast(resolved);
+ }
+ // Return the unresolved object
+ return unresolved;
+ }
+
+ public void addModel(Object resolved) {
+ map.put(resolved, resolved);
+ }
+
+ public Object removeModel(Object resolved) {
+ return map.remove(resolved);
+ }
+
+}
diff --git a/branches/sca-equinox/modules/contribution/src/test/resources/deployables/sample-calculator.jar b/branches/sca-equinox/modules/contribution/src/test/resources/deployables/sample-calculator.jar
new file mode 100644
index 0000000000..0ca3a1b781
--- /dev/null
+++ b/branches/sca-equinox/modules/contribution/src/test/resources/deployables/sample-calculator.jar
Binary files differ
diff --git a/branches/sca-equinox/modules/contribution/src/test/resources/repository/sample-calculator.jar b/branches/sca-equinox/modules/contribution/src/test/resources/repository/sample-calculator.jar
new file mode 100644
index 0000000000..9c46c679d2
--- /dev/null
+++ b/branches/sca-equinox/modules/contribution/src/test/resources/repository/sample-calculator.jar
Binary files differ
diff --git a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/TypeDescriber.java b/branches/sca-equinox/modules/contribution/src/test/resources/test.composite
index 74f303a5a5..1e09549194 100644
--- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/TypeDescriber.java
+++ b/branches/sca-equinox/modules/contribution/src/test/resources/test.composite
@@ -1,38 +1,22 @@
-/*
- * 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.contribution.service;
-
-import java.net.URL;
-
-/**
- * Provide content type for a given resource
- *
- * @version $Rev$ $Date$
- */
-public interface TypeDescriber {
- /**
- * Get the content type for the specified resource
- *
- * @param resourceURL The resource URL
- * @param defaultType The default content type
- * @return The content type
- */
- String getType(URL resourceURL, String defaultType);
-}
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.
+-->
+<composite>
+ This file just needs to exist
+</composite> \ No newline at end of file
diff --git a/branches/sca-equinox/modules/contribution/src/test/resources/test.ext b/branches/sca-equinox/modules/contribution/src/test/resources/test.ext
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/branches/sca-equinox/modules/contribution/src/test/resources/test.ext