diff options
Diffstat (limited to 'branches/sca-equinox/modules/contribution/src/main/java/org/apache')
31 files changed, 15 insertions, 982 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/java/org/apache/tuscany/sca/contribution/service/TypeDescriber.java b/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/TypeDescriber.java deleted file mode 100644 index 74f303a5a5..0000000000 --- a/branches/sca-equinox/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/TypeDescriber.java +++ /dev/null @@ -1,38 +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.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); -} |