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

svn commit: r511711 - 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...

Author: lresende
Date: Sun Feb 25 19:22:36 2007
New Revision: 511711

URL: http://svn.apache.org/viewvc?view=rev&rev=511711
Log:
Merging more updates to the contribution service, also adding folderContribution

Added:
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessor.java
      - copied, changed from r511434, incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessor.java
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/InvalidComponentDefinitionlException.java
      - copied unchanged from r511434, incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/InvalidComponentDefinitionlException.java
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/InvalidFolderContributionURIException.java
    incubator/tuscany/java/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessorTestCase.java
      - copied unchanged from r511434, incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessorTestCase.java
Removed:
    incubator/tuscany/java/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/ContributionProcessorException.java
Modified:
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContentTypeDescriberImpl.java
    incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionDirectoryWatcher.java
    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/main/java/org/apache/tuscany/core/services/deployment/contribution/ScdlContributionProcessor.java
    incubator/tuscany/java/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/ContributionService.java

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContentTypeDescriberImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContentTypeDescriberImpl.java?view=diff&rev=511711&r1=511710&r2=511711
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContentTypeDescriberImpl.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContentTypeDescriberImpl.java Sun Feb 25 19:22:36 2007
@@ -52,6 +52,7 @@
      */
     private void init() {
         contentTypeRegistry.put("SCDL", "application/v.tuscany.scdl");
+        contentTypeRegistry.put("COMPOSITE", "application/v.tuscany.scdl");
         contentTypeRegistry.put("WSDL", "application/v.tuscany.wsdl");
         contentTypeRegistry.put("JAR", "application/x-compressed");
     }

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionDirectoryWatcher.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionDirectoryWatcher.java?view=diff&rev=511711&r1=511710&r2=511711
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionDirectoryWatcher.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionDirectoryWatcher.java Sun Feb 25 19:22:36 2007
@@ -53,7 +53,10 @@
         File[] files = extensionDir.listFiles();
         for (File file : files) {
             try {
-                this.contributionService.contribute(file.toURL());
+                if(file.isDirectory())
+                    this.contributionService.contribute(file.toURL(), false);
+                else
+                    this.contributionService.contribute(file.toURL(), true);
             } catch (DeploymentException de) {
                 //FIXME handle this
                 de.printStackTrace();

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=511711&r1=511710&r2=511711
==============================================================================
--- 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 Sun Feb 25 19:22:36 2007
@@ -44,7 +44,13 @@
 @EagerInit
 @Service(ContributionProcessorRegistry.class)
 public class ContributionProcessorRegistryImpl implements ContributionProcessorRegistry {
+    /**
+     * Processor registry
+     */
     private Map<String, ContributionProcessor> registry = new HashMap<String, ContributionProcessor>();
+    /**
+     * Helper method to describe contentType for each artifact 
+     */
     private ContentTypeDescriber contentTypeDescriber;
 
     public ContributionProcessorRegistryImpl(@Autowire ContentTypeDescriber contentTypeDescriber) {
@@ -66,17 +72,18 @@
     public void processContent(Contribution contribution, URI source, InputStream inputStream)
         throws DeploymentException, IOException {
         
-        URL sourceURL = contribution.getArtifact(source).getLocation();
-        String contentType = this.contentTypeDescriber.getContentType(sourceURL, null);
+        URL locationURL = contribution.getArtifact(source).getLocation();
+        String contentType = this.contentTypeDescriber.getContentType(locationURL, null);
         if (contentType == null) {
             throw new UnsupportedContentTypeException("Invalid contentType: null");
         }
 
-        if (!this.registry.containsKey(contentType)) {
-            throw new UnsupportedContentTypeException(contentType, sourceURL.getPath());
+        ContributionProcessor processor = this.registry.get(contentType);
+        if (processor == null) {
+            throw new UnsupportedContentTypeException(contentType, locationURL.getPath());
         }
 
-        this.registry.get(contentType).processContent(contribution, source, inputStream);
+        processor.processContent(contribution, source, inputStream);
 
     }
 

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=511711&r1=511710&r2=511711
==============================================================================
--- 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 Sun Feb 25 19:22:36 2007
@@ -23,6 +23,8 @@
 import java.net.URI;
 import java.net.URISyntaxException;
 import java.net.URL;
+import java.util.HashMap;
+import java.util.Map;
 import java.util.UUID;
 
 import org.apache.tuscany.core.util.IOHelper;
@@ -45,6 +47,11 @@
      * Registry of available processors. Usually set by injection.
      */
     protected ContributionProcessorRegistry processorRegistry;
+    /**
+     * Contribution registry
+     * This is a registry of processed Contributios index by URI
+     */
+    protected Map<URI, Contribution> contributionRegistry = new HashMap<URI, Contribution>();
 
     public ContributionServiceImpl(@Autowire
     ContributionRepository repository, @Autowire
@@ -54,7 +61,7 @@
         this.processorRegistry = processorRegistry;
     }
 
-    public URI contribute(URL contribution) throws DeploymentException, IOException {
+    public URI contribute(URL contribution, boolean storeInRepository) throws DeploymentException, IOException {
         if (contribution == null) {
             throw new IllegalArgumentException("contribution is null");
         }
@@ -68,13 +75,13 @@
 
         InputStream is = contribution.openConnection().getInputStream();
         try {
-            return contribute(source, is);
+            return contribute(source, is, storeInRepository);
         } finally {
             IOHelper.closeQuietly(is);
         }
     }
 
-    public URI contribute(URI source, InputStream contributionStream) throws DeploymentException, IOException {
+    public URI contribute(URI source, InputStream contributionStream, boolean storeInRepository) throws DeploymentException, IOException {
         if (source == null) {
             throw new IllegalArgumentException("source URI for contribution is null");
         }
@@ -85,23 +92,36 @@
 
         // store the contribution in the contribution repository
         URI contributionURI = URI.create("sca://contribution/" + UUID.randomUUID());
-        URL storedURL = this.contributionRepository.store(source, contributionStream);
+        URL locationURL;
+        if(storeInRepository){
+            locationURL = this.contributionRepository.store(source, contributionStream);
+        }else{
+            locationURL = source.toURL();
+        }
+            
         
         Contribution contribution = null;
         contribution = new Contribution(contributionURI);
-        contribution.setLocation(storedURL);
+        contribution.setLocation(locationURL);
 
-        this.processorRegistry.processContent(contribution, contributionURI, storedURL.openStream());
-
-        if (contribution == null) {
-            // FIXME throw exception
-        }
+        //process the contribution
+        this.processorRegistry.processContent(contribution, contributionURI, locationURL.openStream());
 
+        //store the contribution on the registry
+        this.contributionRegistry.put(contribution.getUri(), contribution);
+        
         return contribution.getUri();
     }
 
+    public Contribution getContribution(URI id) {
+        return this.contributionRegistry.get(id);
+    }
+
     public void remove(URI contribution) throws DeploymentException {
-        // TODO Auto-generated method stub
+        //remove from repository
+        this.contributionRegistry.remove(contribution);
+        //remove from registry
+        this.contributionRegistry.remove(contribution);
     }
 
     public <T> T resolve(URI contribution, Class<T> definitionType, String namespace, String name) {

Copied: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessor.java (from r511434, incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessor.java)
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessor.java?view=diff&rev=511711&p1=incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessor.java&r1=511434&p2=incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessor.java&r2=511711
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessor.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessor.java Sun Feb 25 19:22:36 2007
@@ -47,7 +47,7 @@
     private void traverse(List<URL> fileList, File root) throws IOException {
         if (root.isFile()) {
             fileList.add(root.toURL());
-        } else if (root.isDirectory() && ! root.getName().equals(".svn")) {
+        } else if (root.isDirectory() && !root.getName().equals(".svn")) {
             File[] files = root.listFiles();
             for (int i = 0; i < files.length; i++) {
                 traverse(fileList, files[i]);
@@ -62,7 +62,8 @@
      * @return
      * @throws IOException
      */
-    protected List<URL> getArtifacts(URL rootURL, InputStream sourceInputStream) throws DeploymentException, IOException {
+    protected List<URL> getArtifacts(URL rootURL, InputStream sourceInputStream) 
+        throws DeploymentException, IOException {
         List<URL> artifacts = new ArrayList<URL>();
 
         // Assume the root is a jar file
@@ -70,7 +71,7 @@
         
         try {
             rootFolder = new File(rootURL.toURI());
-            if(rootFolder.isDirectory()){
+            if (rootFolder.isDirectory()) {
                 this.traverse(artifacts, rootFolder);
             }
 
@@ -82,8 +83,9 @@
     }    
     
     
-    public void processContent(Contribution contribution, URI source, InputStream inputStream) throws DeploymentException, IOException {
-        if(contribution == null){
+    public void processContent(Contribution contribution, URI source, InputStream inputStream) 
+        throws DeploymentException, IOException {
+        if (contribution == null) {
             throw new IllegalArgumentException("Invalid null contribution.");
         }
 
@@ -104,7 +106,7 @@
             
 
             //just process scdl for now
-            if("application/v.tuscany.scdl".equals(contentType) || "application/java-vm".equals(contentType) ){
+            if ("application/v.tuscany.scdl".equals(contentType) || "application/java-vm".equals(contentType)) {
                 this.registry.processContent(contribution, source, inputStream);
             }
             // process each artifact
@@ -114,7 +116,8 @@
 
     }
 
-    public void processModel(Contribution contribution, URI source, Object modelObject) throws DeploymentException, IOException {
+    public void processModel(Contribution contribution, URI source, Object modelObject) 
+        throws DeploymentException, IOException {
         // TODO Auto-generated method stub
 
     }

Added: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/InvalidFolderContributionURIException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/InvalidFolderContributionURIException.java?view=auto&rev=511711
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/InvalidFolderContributionURIException.java (added)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/InvalidFolderContributionURIException.java Sun Feb 25 19:22:36 2007
@@ -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.core.services.deployment.contribution;
+
+import org.apache.tuscany.host.deployment.DeploymentException;
+
+/**
+ * Exception that indicates that the supplied XML Document invalid.
+ *
+ */
+public class InvalidFolderContributionURIException extends DeploymentException {
+
+    /**
+     * 
+     */
+    private static final long serialVersionUID = 1564255850052593282L;
+
+    protected InvalidFolderContributionURIException(String componentDefinitionLocatoin) {
+        super(componentDefinitionLocatoin);
+    }
+    
+    protected InvalidFolderContributionURIException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

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=511711&r1=511710&r2=511711
==============================================================================
--- 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 Sun Feb 25 19:22:36 2007
@@ -23,19 +23,21 @@
 import java.io.InputStream;
 import java.net.MalformedURLException;
 import java.net.URI;
+import java.net.URISyntaxException;
 import java.net.URL;
 import java.util.ArrayList;
 import java.util.List;
 import java.util.jar.JarEntry;
 import java.util.jar.JarInputStream;
 
+import org.apache.tuscany.core.services.deployment.ContentTypeDescriberImpl;
+import org.apache.tuscany.core.util.FileHelper;
+import org.apache.tuscany.host.deployment.DeploymentException;
 import org.apache.tuscany.spi.deployer.ContentTypeDescriber;
 import org.apache.tuscany.spi.deployer.ContributionProcessor;
 import org.apache.tuscany.spi.extension.ContributionProcessorExtension;
 import org.apache.tuscany.spi.model.Contribution;
-
-import org.apache.tuscany.core.services.deployment.ContentTypeDescriberImpl;
-import org.apache.tuscany.host.deployment.DeploymentException;
+import org.apache.tuscany.spi.model.DeployedArtifact;
 
 public class JarContributionProcessor extends ContributionProcessorExtension implements ContributionProcessor {
     public static final String CONTENT_TYPE = "application/x-compressed";
@@ -46,8 +48,8 @@
     }
 
     /**
-     * Get a list of selected resources by the extensions
-     *
+     * Get a list of resources inside the jar
+     * 
      * @return
      * @throws IOException
      */
@@ -103,26 +105,38 @@
         sourceURL = forceJarURL(sourceURL);
 
         for (URL artifactURL : getArtifacts(sourceURL, inputStream)) {
-            // FIXME
-            // contribution.addArtifact(artifact)
-
-            ContentTypeDescriber contentTypeDescriber = new ContentTypeDescriberImpl();
-            String contentType = contentTypeDescriber.getContentType(artifactURL, null);
-            System.out.println("Type : " + contentType);
-
-            //just process scdl for now
-            if ("application/v.tuscany.scdl".equals(contentType) || "application/java-vm".equals(contentType)) {
-                this.registry.processContent(contribution, source, inputStream);
+            URI artifactURI;
+            
+            try {
+                artifactURI = new URI(source.toASCIIString() + "/" + FileHelper.getName(artifactURL.getPath()));
+                DeployedArtifact artifact = new DeployedArtifact(artifactURI);
+                artifact.setLocation(artifactURL);
+                contribution.addArtifact(artifact);
+                
+                
+                ContentTypeDescriber contentTypeDescriber = new ContentTypeDescriberImpl();
+                String contentType = contentTypeDescriber.getContentType(artifactURL, null);
+                System.out.println("Type : " + contentType);
+                
+
+                //just process scdl for now
+                if ("application/v.tuscany.scdl".equals(contentType) 
+                        /* || "application/java-vm".equals(contentType) */) {
+                    this.registry.processContent(contribution, artifactURI, artifactURL.openStream());
+                }
+            } catch (URISyntaxException e) {
+                // TODO Auto-generated catch block
+                e.printStackTrace();
             }
-            // process each artifact
-            //this.registry.processContent(contribution, artifactURL, inputStream);
+
+ 
 
         }
 
     }
 
     public void processModel(Contribution contribution, URI source, Object modelObject) throws DeploymentException,
-                                                                                               IOException {
+        IOException {
         // TODO Auto-generated method stub
 
     }

Modified: incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/ScdlContributionProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/ScdlContributionProcessor.java?view=diff&rev=511711&r1=511710&r2=511711
==============================================================================
--- incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/ScdlContributionProcessor.java (original)
+++ incubator/tuscany/java/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/ScdlContributionProcessor.java Sun Feb 25 19:22:36 2007
@@ -22,22 +22,30 @@
 import java.io.IOException;
 import java.io.InputStream;
 import java.net.URI;
+import java.net.URL;
+
 import javax.xml.stream.XMLInputFactory;
 
+import org.apache.tuscany.core.deployer.RootDeploymentContext;
+import org.apache.tuscany.host.deployment.DeploymentException;
 import org.apache.tuscany.spi.annotation.Autowire;
 import org.apache.tuscany.spi.deployer.CompositeClassLoader;
 import org.apache.tuscany.spi.deployer.ContributionProcessor;
+import org.apache.tuscany.spi.deployer.DeploymentContext;
 import org.apache.tuscany.spi.extension.ContributionProcessorExtension;
+import org.apache.tuscany.spi.loader.LoaderException;
 import org.apache.tuscany.spi.loader.LoaderRegistry;
+import org.apache.tuscany.spi.model.ComponentDefinition;
+import org.apache.tuscany.spi.model.CompositeComponentType;
+import org.apache.tuscany.spi.model.CompositeImplementation;
 import org.apache.tuscany.spi.model.Contribution;
 
-import org.apache.tuscany.host.deployment.DeploymentException;
-
 public class ScdlContributionProcessor extends ContributionProcessorExtension implements ContributionProcessor {
     public static final String CONTENT_TYPE = "application/v.tuscany.scdl";
 
+    private final LoaderRegistry registry;
+
     protected XMLInputFactory xmlFactory;
-    //private final LoaderRegistry registry;
 
     @Override
     public String getContentType() {
@@ -46,11 +54,10 @@
 
     public ScdlContributionProcessor(@Autowire LoaderRegistry registry) {
         super();
-        //this.registry = registry;
+        this.registry = registry;
         this.xmlFactory = XMLInputFactory.newInstance("javax.xml.stream.XMLInputFactory", getClass().getClassLoader());
     }
 
-
     public void processContent(Contribution contribution, URI source, InputStream inputStream)
         throws DeploymentException, IOException {
         if (source == null) {
@@ -61,31 +68,33 @@
             throw new IllegalArgumentException("Invalid null source inputstream.");
         }
 
-        //try {
-        CompositeClassLoader cl = new CompositeClassLoader(getClass().getClassLoader());
-        cl.addURL(contribution.getLocation());
-//        DeploymentContext deploymentContext = new RootDeploymentContext(cl,
-//            contribution.getArtifact(source).getLocation(), source, this.xmlFactory, null);
-
-        // CompositeComponentType componentType = this.registry.load(null, null,
-        //     contribution.getArtifact(source).getLocation(), CompositeComponentType.class, deploymentContext);
-
-        //FIXME add this to artifact
-//        CompositeImplementation implementation = new CompositeImplementation();
-//        ComponentDefinition<CompositeImplementation> componentDefinition =
-//            new ComponentDefinition<CompositeImplementation>(implementation);
-
-//        } catch (LoaderException le) {
-//            le.printStackTrace();
-//            throw new ContributionProcessorException("Error processing SCDL",
-//                contribution.getArtifact(source).getLocation().toExternalForm(), le);
-//        }
+        try {
+            URI contributionId = contribution.getUri();
+            URL scdlLocation = contribution.getArtifact(source).getLocation();
+            CompositeClassLoader cl = new CompositeClassLoader(getClass().getClassLoader());
+            cl.addURL(contribution.getLocation());
+            
+            DeploymentContext deploymentContext = new RootDeploymentContext(cl, scdlLocation , contributionId, this.xmlFactory, null);
+
+            CompositeComponentType componentType = this.registry.load(null, scdlLocation, CompositeComponentType.class, deploymentContext);
+
+            CompositeImplementation implementation = new CompositeImplementation();
+            implementation.setComponentType(componentType);
+            ComponentDefinition<CompositeImplementation> componentDefinition = 
+                new ComponentDefinition<CompositeImplementation>(implementation);
+
+            contribution.getArtifact(source).addModelObject(null, null, componentDefinition);
+
+        } catch (LoaderException le) {
+            throw new InvalidComponentDefinitionlException(contribution.getArtifact(source).getLocation()
+                    .toExternalForm(), le);
+        }
     }
 
-    public void processModel(Contribution contribution, URI source, Object modelObject)
-        throws DeploymentException, IOException {
+    public void processModel(Contribution contribution, URI source, Object modelObject) throws DeploymentException,
+            IOException {
         // TODO Auto-generated method stub
 
     }
 
-}
+}
\ No newline at end of file

Modified: incubator/tuscany/java/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/ContributionService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/java/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/ContributionService.java?view=diff&rev=511711&r1=511710&r2=511711
==============================================================================
--- incubator/tuscany/java/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/ContributionService.java (original)
+++ incubator/tuscany/java/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/ContributionService.java Sun Feb 25 19:22:36 2007
@@ -23,6 +23,7 @@
 import java.net.URI;
 import java.net.URL;
 
+
 /**
  * Service interface that manages artifacts contributed to a Tuscany runtime.
  *
@@ -35,22 +36,24 @@
      * URL's path).
      *
      * @param contribution the location of the resource containing the artifact
+     * @param storeInRepository  flag that identifies if you want to copy the contribution to the repository 
      * @return a URI that uniquely identifies this contribution within the SCA Domain
      * @throws DeploymentException if there was a problem with the contribution
      * @throws IOException         if there was a problem reading the resource
      */
-    URI contribute(URL contribution) throws DeploymentException, IOException;
+    URI contribute(URL contribution, boolean storeInRepository) throws DeploymentException, IOException;
 
     /**
      * Contribute an artifact to the SCA Domain.
      *
      * @param source       an identifier for the source of this contribution
      * @param contribution a stream containing the resource being contributed; the stream will not be closed but the
-     *                     read position after the call is undefined
+     *                        read position after the call is undefined
+     * @param storeInRepository  flag that identifies if you want to copy the contribution to the repository
      * @throws DeploymentException if there was a problem with the contribution
      * @throws IOException         if there was a problem reading the stream
      */
-    URI contribute(URI source, InputStream contribution) throws DeploymentException, IOException;
+    URI contribute(URI source, InputStream contribution,  boolean storeInRepository) throws DeploymentException, IOException;
     
     /**
      * Remove a contribution from the SCA domain



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