summaryrefslogtreecommitdiffstats
path: root/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service
diff options
context:
space:
mode:
Diffstat (limited to 'tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service')
-rw-r--r--tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionException.java45
-rw-r--r--tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListener.java58
-rw-r--r--tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListenerExtensionPoint.java44
-rw-r--r--tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionReadException.java94
-rw-r--r--tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRepository.java128
-rw-r--r--tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionResolveException.java41
-rw-r--r--tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRuntimeException.java44
-rw-r--r--tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionService.java137
-rw-r--r--tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionWriteException.java61
-rw-r--r--tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/DefaultContributionListenerExtensionPoint.java118
-rw-r--r--tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ExtensibleContributionListener.java77
-rw-r--r--tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/TypeDescriber.java38
-rw-r--r--tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnrecognizedElementException.java48
-rw-r--r--tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnsupportedContentTypeException.java42
-rw-r--r--tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnsupportedPackageTypeException.java39
15 files changed, 1014 insertions, 0 deletions
diff --git a/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionException.java b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionException.java
new file mode 100644
index 0000000000..e183206894
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionException.java
@@ -0,0 +1,45 @@
+/*
+ * 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;
+
+/**
+ * Base class for exceptions raised by contribution services.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContributionException extends Exception {
+
+ private static final long serialVersionUID = 4432880414927652578L;
+
+ protected ContributionException() {
+ super();
+ }
+
+ protected ContributionException(String message) {
+ super(message);
+ }
+
+ protected ContributionException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ContributionException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListener.java b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListener.java
new file mode 100644
index 0000000000..5158eaf85c
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListener.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.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/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListenerExtensionPoint.java b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListenerExtensionPoint.java
new file mode 100644
index 0000000000..ce2b4b13c3
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionListenerExtensionPoint.java
@@ -0,0 +1,44 @@
+/*
+ * 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/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionReadException.java b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionReadException.java
new file mode 100644
index 0000000000..33399dcc2f
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionReadException.java
@@ -0,0 +1,94 @@
+/*
+ * 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;
+
+/**
+ * Denotes an exception while reading artifacts inside an SCA contribution.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContributionReadException extends ContributionException {
+ public static final int UNDEFINED = -1;
+ private static final long serialVersionUID = -7459051598906813461L;
+ private String resourceURI;
+ private int line = UNDEFINED;
+ private int column = UNDEFINED;
+
+ public ContributionReadException(String message) {
+ super(message);
+ }
+
+ public ContributionReadException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ContributionReadException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Returns the location of the resource that was being read.
+ *
+ * @return the location of the resource that was being read
+ */
+ public String getResourceURI() {
+ return resourceURI;
+ }
+
+ /**
+ * Sets the location of the resource that was being read.
+ *
+ * @param resourceURI the location of the resource that was being read
+ */
+ public void setResourceURI(String resourceURI) {
+ this.resourceURI = resourceURI;
+ }
+
+ /**
+ * Returns the line inside the resource that was being read.
+ * @return the line inside the resource that was being read
+ */
+ public int getLine() {
+ return line;
+ }
+
+ /**
+ * Sets the line inside the resource that was being read.
+ * @param line the line inside the resource that was being read
+ */
+ public void setLine(int line) {
+ this.line = line;
+ }
+
+ /**
+ * Returns the column inside the resource that was being read.
+ * @return the column inside the resource that was being read
+ */
+ public int getColumn() {
+ return column;
+ }
+
+ /**
+ * Sets the column inside the resource that was being read.
+ * @param column the column inside the resource that was being read
+ */
+ public void setColumn(int column) {
+ this.column = column;
+ }
+}
diff --git a/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRepository.java b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRepository.java
new file mode 100644
index 0000000000..d7d8216f66
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRepository.java
@@ -0,0 +1,128 @@
+/*
+ * 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/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionResolveException.java b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionResolveException.java
new file mode 100644
index 0000000000..ecb774ac0c
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionResolveException.java
@@ -0,0 +1,41 @@
+/*
+ * 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;
+
+/**
+ * Denotes a problem while resolving models inside an SCA contribution.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContributionResolveException extends ContributionException {
+ private static final long serialVersionUID = -7459051598906813461L;
+
+ public ContributionResolveException(String message) {
+ super(message);
+ }
+
+ public ContributionResolveException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ContributionResolveException(Throwable cause) {
+ super(cause);
+ }
+
+}
diff --git a/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRuntimeException.java b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRuntimeException.java
new file mode 100644
index 0000000000..4bf29a3993
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionRuntimeException.java
@@ -0,0 +1,44 @@
+/*
+ * 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;
+
+/**
+ * Base class for runtime exceptions raised by contribution services.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContributionRuntimeException extends RuntimeException {
+ private static final long serialVersionUID = 7711215366287498896L;
+
+ protected ContributionRuntimeException() {
+ super();
+ }
+
+ protected ContributionRuntimeException(String message) {
+ super(message);
+ }
+
+ protected ContributionRuntimeException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ContributionRuntimeException(Throwable cause) {
+ super(cause);
+ }
+}
diff --git a/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionService.java b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionService.java
new file mode 100644
index 0000000000..dcdb8733b8
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionService.java
@@ -0,0 +1,137 @@
+/*
+ * 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/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionWriteException.java b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionWriteException.java
new file mode 100644
index 0000000000..8bfdedf180
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ContributionWriteException.java
@@ -0,0 +1,61 @@
+/*
+ * 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;
+
+
+/**
+ * Denotes an exception while writing artifacts inside an SCA contribution.
+ *
+ * @version $Rev$ $Date$
+ */
+public class ContributionWriteException extends ContributionException {
+ private static final long serialVersionUID = -7459051598906813461L;
+ private String resourceURI;
+
+ public ContributionWriteException(String message) {
+ super(message);
+ }
+
+ public ContributionWriteException(String message, Throwable cause) {
+ super(message, cause);
+ }
+
+ public ContributionWriteException(Throwable cause) {
+ super(cause);
+ }
+
+ /**
+ * Returns the location of the resource that was being written.
+ *
+ * @return the location of the resource that was being written
+ */
+ public String getResourceURI() {
+ return resourceURI;
+ }
+
+ /**
+ * Sets the location of the resource that was being written.
+ *
+ * @param resourceURI the location of the resource that was being written
+ */
+ public void setResourceURI(String resourceURI) {
+ this.resourceURI = resourceURI;
+ }
+
+}
diff --git a/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/DefaultContributionListenerExtensionPoint.java b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/DefaultContributionListenerExtensionPoint.java
new file mode 100644
index 0000000000..1ab80e344b
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/DefaultContributionListenerExtensionPoint.java
@@ -0,0 +1,118 @@
+/*
+ * 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.contribution.ModelFactoryExtensionPoint;
+import org.apache.tuscany.sca.core.ExtensionPointRegistry;
+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 ModelFactoryExtensionPoint modelFactories;
+
+ /**
+ * Constructs a new DefaultContributionListenerExtensionPoint.
+ *
+ */
+ public DefaultContributionListenerExtensionPoint(ModelFactoryExtensionPoint modelFactories) {
+ this.modelFactories = modelFactories;
+ }
+
+ /**
+ * Constructs a new DefaultContributionListenerExtensionPoint.
+ *
+ */
+ public DefaultContributionListenerExtensionPoint(ExtensionPointRegistry extensionPoints) {
+ this.modelFactories = extensionPoints.getExtensionPoint(ModelFactoryExtensionPoint.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);
+ } 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(ModelFactoryExtensionPoint.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/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ExtensibleContributionListener.java b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ExtensibleContributionListener.java
new file mode 100644
index 0000000000..fc0dc3aa99
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/ExtensibleContributionListener.java
@@ -0,0 +1,77 @@
+/*
+ * 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/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/TypeDescriber.java b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/TypeDescriber.java
new file mode 100644
index 0000000000..74f303a5a5
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/TypeDescriber.java
@@ -0,0 +1,38 @@
+/*
+ * 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);
+}
diff --git a/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnrecognizedElementException.java b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnrecognizedElementException.java
new file mode 100644
index 0000000000..ff21c894de
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnrecognizedElementException.java
@@ -0,0 +1,48 @@
+/*
+ * 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 javax.xml.namespace.QName;
+
+/**
+ * Exception that indicates an element was encountered that could not be handled.
+ *
+ * @version $Rev$ $Date$
+ */
+public class UnrecognizedElementException extends ContributionReadException {
+ private static final long serialVersionUID = 2549543622209829032L;
+ private final QName element;
+
+ /**
+ * Constructor that indicates which element could not be handled.
+ * @param element the element that could not be handled
+ */
+ public UnrecognizedElementException(QName element) {
+ super("Unrecognized element: " + element);
+ this.element = element;
+ }
+
+ /**
+ * Returns the element that could not be handled.
+ * @return the element that could not be handled.
+ */
+ public QName getElement() {
+ return element;
+ }
+}
diff --git a/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnsupportedContentTypeException.java b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnsupportedContentTypeException.java
new file mode 100644
index 0000000000..0660d69897
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnsupportedContentTypeException.java
@@ -0,0 +1,42 @@
+/*
+ * 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;
+
+/**
+ * Exception thrown to indicate that a Content-Type is not supported by this SCA Domain.
+ * The Content-Type value supplied will be returned as the message text for this exception.
+ *
+ * FIXME Don't use as it's deprecated and replaced by UnsupportedPackageTypeException.
+ *
+ * @version $Rev$ $Date$
+ */
+@Deprecated
+public class UnsupportedContentTypeException extends ContributionException {
+ private static final long serialVersionUID = -1831797280021355672L;
+
+ /**
+ * Constructs a new UnsupportedContentTypeException.
+ *
+ * @param message
+ */
+ public UnsupportedContentTypeException(String message) {
+ super(message);
+ }
+
+}
diff --git a/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnsupportedPackageTypeException.java b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnsupportedPackageTypeException.java
new file mode 100644
index 0000000000..33c847a049
--- /dev/null
+++ b/tags/java/sca/1.5.1/modules/contribution/src/main/java/org/apache/tuscany/sca/contribution/service/UnsupportedPackageTypeException.java
@@ -0,0 +1,39 @@
+/*
+ * 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;
+
+/**
+ * Exception thrown to indicate that a Content-Type is not supported by this SCA Domain.
+ * The Content-Type value supplied will be returned as the message text for this exception.
+ *
+ * @version $Rev$ $Date$
+ */
+public class UnsupportedPackageTypeException extends ContributionException {
+ private static final long serialVersionUID = -1831797280021355672L;
+
+ /**
+ * Constructs a new UnsupportedPackageTypeException.
+ *
+ * @param message
+ */
+ public UnsupportedPackageTypeException(String message) {
+ super(message);
+ }
+
+}