You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by rf...@apache.org on 2007/02/06 22:57:30 UTC

svn commit: r504315 - in /incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi: deployer/ContributionProcessor.java model/Contribution.java model/ContributionImport.java model/DeployedArtifact.java

Author: rfeng
Date: Tue Feb  6 13:57:29 2007
New Revision: 504315

URL: http://svn.apache.org/viewvc?view=rev&rev=504315
Log:
Add the model for deployed contributions and artifacts

Added:
    incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Contribution.java   (with props)
    incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ContributionImport.java   (with props)
    incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DeployedArtifact.java   (with props)
Modified:
    incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionProcessor.java

Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionProcessor.java?view=diff&rev=504315&r1=504314&r2=504315
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionProcessor.java (original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionProcessor.java Tue Feb  6 13:57:29 2007
@@ -18,16 +18,56 @@
  */
 package org.apache.tuscany.spi.deployer;
 
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+
+import org.apache.tuscany.host.deployment.DeploymentException;
+import org.apache.tuscany.spi.contribution.Contribution;
+
 /**
  * Interface for services that can process contributions.
- *
+ * 
  * @version $Rev$ $Date$
  */
 public interface ContributionProcessor {
     /**
      * Returns the content type that this implementation can handle.
-     *
+     * 
      * @return the content type that this implementation can handle
      */
     String getContentType();
+
+    /**
+     * Process a contribution or an artifact in the contribution from the input
+     * stream. The processor might add artifacts or model objects to the
+     * contribution object.
+     * 
+     * @param contribution The contribution model that will be used to hold the
+     *            results from the processing
+     * @param inputStream The input stream for the contribution. The stream will
+     *            not be closed but the read position after the call is
+     *            undefined
+     * @param source The URI for the contribution/artifact
+     * @throws DeploymentException if there was a problem with the contribution
+     * @throws IOException if there was a problem reading the stream
+     */
+    void processContent(Contribution contribution, URI source, InputStream inputStream) throws DeploymentException,
+        IOException;
+
+    /**
+     * Process a contribution from another model object. It will be used for the
+     * case that one artifact has other inline artifacts, for example, the WSDL
+     * with inline schemas. The schema contribution processor should be able to
+     * load the schema model from the WSDL definition.
+     * 
+     * @param contribution The contribution model that will be used to hold the
+     *            results from the processing
+     * @param source The URI for the contribution/artifact
+     * @param modelObject A model object for further processing by the processor
+     * @throws DeploymentException
+     * @throws IOException
+     */
+    void processModel(Contribution contribution, URI source, Object modelObject) throws DeploymentException,
+        IOException;
 }

Added: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Contribution.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Contribution.java?view=auto&rev=504315
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Contribution.java (added)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Contribution.java Tue Feb  6 13:57:29 2007
@@ -0,0 +1,74 @@
+/*
+ * 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.spi.model;
+
+import java.net.URI;
+import java.util.ArrayList;
+import java.util.List;
+
+import javax.xml.namespace.QName;
+
+/**
+ * The representation of a deployed contribution
+ */
+public class Contribution extends ModelObject {
+    public static final String SCA_CONTRIBUTION_META = "META-INF/sca-contribution.xml";
+    public static final String SCA_CONTRIBUTION_GENERATED_META = "META-INF/sca-contribution-generated.xml";
+
+    protected URI uri;
+    protected List<String> exports = new ArrayList<String>();
+    protected List<ContributionImport> imports = new ArrayList<ContributionImport>();
+    protected List<QName> runnables = new ArrayList<QName>();
+    
+    /**
+     * A list of artifacts in the contribution
+     */
+    protected List<DeployedArtifact> artifacts = new ArrayList<DeployedArtifact>();
+
+
+    public URI getUri() {
+        return uri;
+    }
+
+    public void setUri(URI uri) {
+        this.uri = uri;
+    }
+
+    public List<String> getExports() {
+        return exports;
+    }
+
+    public List<ContributionImport> getImports() {
+        return imports;
+    }
+
+    public List<QName> getRunnables() {
+        return runnables;
+    }
+
+    public List<DeployedArtifact> getArtifacts() {
+        return artifacts;
+    }
+    
+    public void addArtifact(DeployedArtifact artifact) {
+        artifact.setContribution(this);
+        artifacts.add(artifact);
+    }
+}

Propchange: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Contribution.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Contribution.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ContributionImport.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ContributionImport.java?view=auto&rev=504315
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ContributionImport.java (added)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ContributionImport.java Tue Feb  6 13:57:29 2007
@@ -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.spi.model;
+
+import java.net.URI;
+
+/**
+ * The representation of an import for the contribution
+ */
+public class ContributionImport extends ModelObject {
+    private String namespace; // The namespace to be imported
+    private URI location; // Optional location to hint the where it should be imported
+    
+    // TODO: We might need the field to point to the imported artifact/model
+
+    public URI getLocation() {
+        return location;
+    }
+
+    public void setLocation(URI location) {
+        this.location = location;
+    }
+
+    public String getNamespace() {
+        return namespace;
+    }
+
+    public void setNamespace(String namespace) {
+        this.namespace = namespace;
+    }
+}

Propchange: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ContributionImport.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/ContributionImport.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date

Added: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DeployedArtifact.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DeployedArtifact.java?view=auto&rev=504315
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DeployedArtifact.java (added)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DeployedArtifact.java Tue Feb  6 13:57:29 2007
@@ -0,0 +1,81 @@
+/*
+ * 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.spi.model;
+
+import java.net.URI;
+import java.util.HashMap;
+import java.util.Map;
+
+/**
+ * Representation of a deployed artifact
+ */
+public class DeployedArtifact extends ModelObject {
+    protected Contribution contribution;
+    protected URI uri;
+    /**
+     * The map keeps all the model objects loaded/introspected from this artifact. The objects
+     * are keyed by the java type of the model such as javax.wsdl.ModelObject. The value is also
+     * a map with namespace as the key and the model object as the value.
+     */
+    protected Map<Class, Map<String, Object>> modelObjects = new HashMap<Class, Map<String, Object>>();
+
+    public Contribution getContribution() {
+        return contribution;
+    }
+
+    public void setContribution(Contribution contribution) {
+        this.contribution = contribution;
+    }
+
+    public URI getUri() {
+        return uri;
+    }
+
+    public void setUri(URI uri) {
+        this.uri = uri;
+    }
+
+    public Map<Class, Map<String, Object>> getModelObjects() {
+        return modelObjects;
+    }
+
+    public Map<String, Object> getModelObjects(Class type) {
+        return modelObjects.get(type);
+    }
+
+    public Object getModelObject(Class type, String namespace) {
+        Map<String, Object> map = modelObjects.get(type);
+        if (map == null) {
+            return null;
+        } else {
+            return map.get(namespace);
+        }
+    }
+
+    public void addModelObject(Class type, String namespace, Object modelObject) {
+        Map<String, Object> map = modelObjects.get(type);
+        if (map == null) {
+            map = new HashMap<String, Object>();
+            modelObjects.put(type, map);
+        }
+        map.put(namespace, modelObject);
+    }
+
+}

Propchange: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DeployedArtifact.java
------------------------------------------------------------------------------
    svn:eol-style = native

Propchange: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DeployedArtifact.java
------------------------------------------------------------------------------
    svn:keywords = Rev Date



---------------------------------------------------------------------
To unsubscribe, e-mail: tuscany-commits-unsubscribe@ws.apache.org
For additional commands, e-mail: tuscany-commits-help@ws.apache.org