tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From lrese...@apache.org
Subject svn commit: r510108 - in /incubator/tuscany/java/sca/kernel: core/src/main/java/org/apache/tuscany/core/services/deployment/ core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/ core/src/test/java/org/apache/tuscany/core/service...
Date Wed, 21 Feb 2007 17:24:21 GMT
Author: lresende
Date: Wed Feb 21 09:24:20 2007
New Revision: 510108

URL: http://svn.apache.org/viewvc?view=rev&rev=510108
Log:
Merging contribution model updates

Modified:
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionProcessorRegistryImpl.java
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionServiceImpl.java
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/JarContributionProcessor.java
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/deployment/contribution/JarContributionProcessorTestCase.java
    incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ArtifactResolver.java
    incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ContributionProcessor.java
    incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Contribution.java
    incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DeployedArtifact.java

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionProcessorRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionProcessorRegistryImpl.java?view=diff&rev=510108&r1=510107&r2=510108
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionProcessorRegistryImpl.java
(original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionProcessorRegistryImpl.java
Wed Feb 21 09:24:20 2007
@@ -21,6 +21,7 @@
 
 import java.io.IOException;
 import java.io.InputStream;
+import java.net.URI;
 import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
@@ -62,22 +63,23 @@
         registry.remove(contentType);
     }
 
-    public void processContent(Contribution contribution, URL source, InputStream inputStream)
+    public void processContent(Contribution contribution, URI source, InputStream inputStream)
         throws DeploymentException, IOException {
-        String contentType = this.contentTypeBuilder.getContentType(source, null);
+        URL sourceURL = contribution.getArtifact(source).getLocation();
+        String contentType = this.contentTypeBuilder.getContentType(sourceURL, null);
         if (contentType == null) {
             throw new UnsupportedContentTypeException("Invalid contentType: null");
         }
 
         if (!this.registry.containsKey(contentType)) {
-            throw new UnsupportedContentTypeException(contentType, source.getPath());
+            throw new UnsupportedContentTypeException(contentType, sourceURL.getPath());
         }
 
         this.registry.get(contentType).processContent(contribution, source, inputStream);
 
     }
 
-    public void processModel(Contribution contribution, URL source, Object modelObject) throws
DeploymentException,
+    public void processModel(Contribution contribution, URI source, Object modelObject) throws
DeploymentException,
         IOException {
     }
 }

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionServiceImpl.java?view=diff&rev=510108&r1=510107&r2=510108
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionServiceImpl.java
(original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionServiceImpl.java
Wed Feb 21 09:24:20 2007
@@ -46,8 +46,9 @@
      */
     protected ContributionProcessorRegistry processorRegistry;
 
-    public ContributionServiceImpl(@Autowire ContributionRepository repository, 
-                                   @Autowire ContributionProcessorRegistry processorRegistry)
{
+    public ContributionServiceImpl(@Autowire
+    ContributionRepository repository, @Autowire
+    ContributionProcessorRegistry processorRegistry) {
         super();
         this.contributionRepository = repository;
         this.processorRegistry = processorRegistry;
@@ -85,16 +86,11 @@
         // store the contribution in the contribution repository
         URL storedURL = this.contributionRepository.store(source, contributionStream);
         Contribution contribution = null;
-        try {
-            // start processing valid contribution
-            contribution = new Contribution();
-            contribution.setUri(new URI("sca://contribution/" + UUID.randomUUID()));
-
-            this.processorRegistry.processContent(contribution, storedURL, contributionStream);
+        // start processing valid contribution
+        contribution = new Contribution(URI.create("sca://contribution/" + UUID.randomUUID()));
+        contribution.setLocation(storedURL);
 
-        } catch (URISyntaxException urie) {
-            // FIXME
-        }
+        this.processorRegistry.processContent(contribution, contribution.getUri(), contributionStream);
 
         if (contribution == null) {
             // FIXME throw exception

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/JarContributionProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/JarContributionProcessor.java?view=diff&rev=510108&r1=510107&r2=510108
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/JarContributionProcessor.java
(original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/JarContributionProcessor.java
Wed Feb 21 09:24:20 2007
@@ -22,6 +22,7 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.MalformedURLException;
+import java.net.URI;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
@@ -79,9 +80,9 @@
 
     }
 
-    public void processContent(Contribution contribution, URL sourceURL, InputStream inputStream)
+    public void processContent(Contribution contribution, URI source, InputStream inputStream)
         throws DeploymentException, IOException {
-        if (sourceURL == null) {
+        if (source == null) {
             throw new IllegalArgumentException("Invalid null source uri.");
         }
 
@@ -89,6 +90,7 @@
             throw new IllegalArgumentException("Invalid null source inputstream.");
         }
 
+        URL sourceURL = contribution.getArtifact(source).getLocation();
         sourceURL = forceJarURL(sourceURL);
 
         for (URL artifactURL : getArtifacts(sourceURL, inputStream)) {
@@ -114,7 +116,7 @@
 
     }
 
-    public void processModel(Contribution contribution, URL source, Object modelObject) throws
DeploymentException,
+    public void processModel(Contribution contribution, URI source, Object modelObject) throws
DeploymentException,
         IOException {
         // TODO Auto-generated method stub
 

Modified: incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/deployment/contribution/JarContributionProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/deployment/contribution/JarContributionProcessorTestCase.java?view=diff&rev=510108&r1=510107&r2=510108
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/deployment/contribution/JarContributionProcessorTestCase.java
(original)
+++ incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/deployment/contribution/JarContributionProcessorTestCase.java
Wed Feb 21 09:24:20 2007
@@ -18,11 +18,13 @@
  */
 package org.apache.tuscany.core.services.deployment.contribution;
 
+import java.net.URI;
 import java.net.URL;
 
 import junit.framework.TestCase;
 
 import org.apache.tuscany.spi.deployer.ContributionProcessorRegistry;
+import org.apache.tuscany.spi.model.Contribution;
 import org.easymock.EasyMock;
 
 public class JarContributionProcessorTestCase extends TestCase {
@@ -42,6 +44,8 @@
         jarContribution.start();
         EasyMock.verify(mockRegistry);
         URL jarURL = getClass().getResource(JarContributionProcessorTestCase.JAR_CONTRIBUTION);
-        jarContribution.processContent(null, jarURL, jarURL.openStream());
+        Contribution contribution = new Contribution(URI.create("sca://contributions/001"));
+        contribution.setLocation(jarURL);
+        jarContribution.processContent(contribution, contribution.getUri(), jarURL.openStream());
     }
 }

Modified: incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ArtifactResolver.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ArtifactResolver.java?view=diff&rev=510108&r1=510107&r2=510108
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ArtifactResolver.java
(original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/deployer/ArtifactResolver.java
Wed Feb 21 09:24:20 2007
@@ -20,6 +20,7 @@
 package org.apache.tuscany.spi.deployer;
 
 import java.net.URI;
+import java.net.URL;
 import java.util.Map;
 
 
@@ -69,14 +70,14 @@
      * <li>Reference a list of WSDLs using
      * {http://www.w3.org/2004/08/wsdl-instance}wsdlLocation
      * </ul>
-     * 
      * @param targetNamespace The target namespace of the referenced artifact,
      *            if the targetNamespace is null, then it's not specified
      * @param location The URI of the referenced artifact, it can be absolute or
      *            relative
      * @param baseURI The URI of the owning artifact
+     * 
      * @return The URI of the resolved artifact
      */
-    URI resolve(URI contribution, String targetNamespace, String location, String baseURI,
DeploymentContext context);
+    URL resolve(URI contribution, String targetNamespace, String location, String baseURI);
 
 }

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=510108&r1=510107&r2=510108
==============================================================================
--- 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
Wed Feb 21 09:24:20 2007
@@ -20,7 +20,7 @@
 
 import java.io.IOException;
 import java.io.InputStream;
-import java.net.URL;
+import java.net.URI;
 
 import org.apache.tuscany.host.deployment.DeploymentException;
 import org.apache.tuscany.spi.model.Contribution;
@@ -45,7 +45,7 @@
      * @throws DeploymentException if there was a problem with the contribution
      * @throws IOException if there was a problem reading the stream
      */
-    void processContent(Contribution contribution, URL source, InputStream inputStream) throws
DeploymentException,
+    void processContent(Contribution contribution, URI source, InputStream inputStream) throws
DeploymentException,
         IOException;
 
     /**
@@ -56,11 +56,11 @@
      * 
      * @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 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, URL source, Object modelObject) throws DeploymentException,
+    void processModel(Contribution contribution, URI source, Object modelObject) throws DeploymentException,
         IOException;
 }

Modified: 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=diff&rev=510108&r1=510107&r2=510108
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Contribution.java
(original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/Contribution.java
Wed Feb 21 09:24:20 2007
@@ -20,8 +20,12 @@
 package org.apache.tuscany.spi.model;
 
 import java.net.URI;
+import java.net.URL;
 import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
 import java.util.List;
+import java.util.Map;
 
 import javax.xml.namespace.QName;
 
@@ -30,11 +34,10 @@
  *
  * @version $Rev$ $Date$
  */
-public class Contribution extends ModelObject {
+public class Contribution extends DeployedArtifact {
     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>();
@@ -42,17 +45,21 @@
     /**
      * A list of artifacts in the contribution
      */
-    protected List<DeployedArtifact> artifacts = new ArrayList<DeployedArtifact>();
+    protected Map<URI, DeployedArtifact> artifacts = new HashMap<URI, DeployedArtifact>();
 
 
+    /**
+     * @param uri
+     */
+    public Contribution(URI uri) {
+        super(uri);
+        artifacts.put(uri, this);
+    }
+    
     public URI getUri() {
         return uri;
     }
 
-    public void setUri(URI uri) {
-        this.uri = uri;
-    }
-
     public List<String> getExports() {
         return exports;
     }
@@ -65,12 +72,30 @@
         return runnables;
     }
 
-    public List<DeployedArtifact> getArtifacts() {
-        return artifacts;
+    public Map<URI, DeployedArtifact> getArtifacts() {
+        return Collections.unmodifiableMap(artifacts);
     }
     
     public void addArtifact(DeployedArtifact artifact) {
         artifact.setContribution(this);
-        artifacts.add(artifact);
+        artifacts.put(artifact.getUri(), artifact);
+    }
+    
+    public DeployedArtifact getArtifact(URI uri) {
+        return artifacts.get(uri);
+    }
+
+    /**
+     * @return the location
+     */
+    public URL getLocation() {
+        return location;
+    }
+
+    /**
+     * @param location the location to set
+     */
+    public void setLocation(URL location) {
+        this.location = location;
     }
 }

Modified: 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=diff&rev=510108&r1=510107&r2=510108
==============================================================================
--- incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DeployedArtifact.java
(original)
+++ incubator/tuscany/java/sca/kernel/spi/src/main/java/org/apache/tuscany/spi/model/DeployedArtifact.java
Wed Feb 21 09:24:20 2007
@@ -20,6 +20,7 @@
 package org.apache.tuscany.spi.model;
 
 import java.net.URI;
+import java.net.URL;
 import java.util.HashMap;
 import java.util.Map;
 
@@ -30,7 +31,8 @@
  */
 public class DeployedArtifact extends ModelObject {
     protected Contribution contribution;
-    protected URI uri;
+    protected final URI uri;
+    protected URL location;
     /**
      * 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
@@ -38,6 +40,14 @@
      */
     protected Map<Class, Map<String, Object>> modelObjects = new HashMap<Class,
Map<String, Object>>();
 
+    /**
+     * @param uri
+     */
+    public DeployedArtifact(URI uri) {
+        super();
+        this.uri = uri;
+    }
+
     public Contribution getContribution() {
         return contribution;
     }
@@ -46,14 +56,14 @@
         this.contribution = contribution;
     }
 
+    /**
+     * Get the absolute URI as the unique id for the artifact
+     * @return
+     */
     public URI getUri() {
         return uri;
     }
 
-    public void setUri(URI uri) {
-        this.uri = uri;
-    }
-
     public Map<Class, Map<String, Object>> getModelObjects() {
         return modelObjects;
     }
@@ -78,6 +88,20 @@
             modelObjects.put(type, map);
         }
         map.put(namespace, modelObject);
+    }
+
+    /**
+     * @return the location
+     */
+    public URL getLocation() {
+        return location;
+    }
+
+    /**
+     * @param location the location to set
+     */
+    public void setLocation(URL location) {
+        this.location = location;
     }
 
 }



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


Mime
View raw message