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/25 04:40:23 UTC

svn commit: r511434 - in /incubator/tuscany/branches/sca-java-integration/sca: kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/ kernel/core/src/te...

Author: lresende
Date: Sat Feb 24 19:40:22 2007
New Revision: 511434

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

Added:
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessor.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/InvalidComponentDefinitionlException.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessorTestCase.java
Removed:
    incubator/tuscany/branches/sca-java-integration/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/ContributionProcessorException.java
Modified:
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContentTypeDescriberImpl.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionDirectoryWatcher.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionProcessorRegistryImpl.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionServiceImpl.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/JarContributionProcessor.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/ScdlContributionProcessor.java
    incubator/tuscany/branches/sca-java-integration/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/ContributionService.java
    incubator/tuscany/branches/sca-java-integration/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLContributionProcessor.java

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContentTypeDescriberImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContentTypeDescriberImpl.java?view=diff&rev=511434&r1=511433&r2=511434
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContentTypeDescriberImpl.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContentTypeDescriberImpl.java Sat Feb 24 19:40:22 2007
@@ -51,6 +51,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/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionDirectoryWatcher.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionDirectoryWatcher.java?view=diff&rev=511434&r1=511433&r2=511434
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionDirectoryWatcher.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionDirectoryWatcher.java Sat Feb 24 19:40:22 2007
@@ -50,7 +50,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/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionProcessorRegistryImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionProcessorRegistryImpl.java?view=diff&rev=511434&r1=511433&r2=511434
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionProcessorRegistryImpl.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionProcessorRegistryImpl.java Sat Feb 24 19:40:22 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/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionServiceImpl.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionServiceImpl.java?view=diff&rev=511434&r1=511433&r2=511434
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionServiceImpl.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/ContributionServiceImpl.java Sat Feb 24 19:40:22 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) {

Added: 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/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessor.java?view=auto&rev=511434
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessor.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessor.java Sat Feb 24 19:40:22 2007
@@ -0,0 +1,122 @@
+/*
+ * 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 java.io.File;
+import java.io.IOException;
+import java.io.InputStream;
+import java.net.URI;
+import java.net.URISyntaxException;
+import java.net.URL;
+import java.util.ArrayList;
+import java.util.List;
+
+import org.apache.tuscany.core.services.deployment.ContentTypeDescriberImpl;
+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;
+
+public class FolderContributionProcessor extends ContributionProcessorExtension implements ContributionProcessor {
+    public static final String CONTENT_TYPE = "application/v.tuscany.folder";
+
+    @Override
+    public String getContentType() {
+        return CONTENT_TYPE;
+    }
+
+    
+    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")) {
+            File[] files = root.listFiles();
+            for (int i = 0; i < files.length; i++) {
+                traverse(fileList, files[i]);
+            }
+        }
+    }
+
+    
+    /**
+     * Get a list of files from the directory
+     * 
+     * @return
+     * @throws 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
+        File rootFolder;
+        
+        try {
+            rootFolder = new File(rootURL.toURI());
+            if(rootFolder.isDirectory()){
+                this.traverse(artifacts, rootFolder);
+            }
+
+        } catch (URISyntaxException e) {
+            throw new InvalidFolderContributionURIException(rootURL.toExternalForm(), e);
+        }
+
+        return artifacts;
+    }    
+    
+    
+    public void processContent(Contribution contribution, URI source, InputStream inputStream) throws DeploymentException, IOException {
+        if(contribution == null){
+            throw new IllegalArgumentException("Invalid null contribution.");
+        }
+
+        if (source == null) {
+            throw new IllegalArgumentException("Invalid null source uri.");
+        }
+
+        URL sourceURL = contribution.getArtifact(source).getLocation();
+
+        for (URL artifactURL : getArtifacts(sourceURL, inputStream)) {
+            // FIXME
+            // contribution.addArtifact(artifact)
+            
+            ContentTypeDescriber contentTypeDescriber = new ContentTypeDescriberImpl();
+            String contentType = contentTypeDescriber.getContentType(artifactURL, null);
+            System.out.println("File : " + artifactURL);
+            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);
+            }
+            // process each artifact
+            //this.registry.processContent(contribution, artifactURL, inputStream);
+
+        }
+
+    }
+
+    public void processModel(Contribution contribution, URI source, Object modelObject) throws DeploymentException, IOException {
+        // TODO Auto-generated method stub
+
+    }
+
+}

Added: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/InvalidComponentDefinitionlException.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/InvalidComponentDefinitionlException.java?view=auto&rev=511434
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/InvalidComponentDefinitionlException.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/InvalidComponentDefinitionlException.java Sat Feb 24 19:40:22 2007
@@ -0,0 +1,36 @@
+/*
+ * 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 InvalidComponentDefinitionlException extends DeploymentException {
+
+    protected InvalidComponentDefinitionlException(String componentDefinitionLocatoin) {
+        super(componentDefinitionLocatoin);
+    }
+    
+    protected InvalidComponentDefinitionlException(String message, Throwable cause) {
+        super(message, cause);
+    }
+}

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/JarContributionProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/JarContributionProcessor.java?view=diff&rev=511434&r1=511433&r2=511434
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/JarContributionProcessor.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/JarContributionProcessor.java Sat Feb 24 19:40:22 2007
@@ -23,6 +23,7 @@
 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;
@@ -30,11 +31,13 @@
 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.spi.model.DeployedArtifact;
 
 public class JarContributionProcessor extends ContributionProcessorExtension implements ContributionProcessor {
     public static final String CONTENT_TYPE = "application/x-compressed";
@@ -45,7 +48,7 @@
     }
 
     /**
-     * Get a list of selected resources by the extensions
+     * Get a list of resources inside the jar
      * 
      * @return
      * @throws IOException
@@ -102,20 +105,30 @@
         sourceURL = forceJarURL(sourceURL);
 
         for (URL artifactURL : getArtifacts(sourceURL, inputStream)) {
-            // FIXME
-            // contribution.addArtifact(artifact)
+            URI artifactURI;
             
-            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);
+            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);
+
+ 
 
         }
 

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/ScdlContributionProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/ScdlContributionProcessor.java?view=diff&rev=511434&r1=511433&r2=511434
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/ScdlContributionProcessor.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/main/java/org/apache/tuscany/core/services/deployment/contribution/ScdlContributionProcessor.java Sat Feb 24 19:40:22 2007
@@ -26,7 +26,6 @@
 import javax.xml.stream.XMLInputFactory;
 
 import org.apache.tuscany.core.deployer.RootDeploymentContext;
-import org.apache.tuscany.host.deployment.ContributionProcessorException;
 import org.apache.tuscany.host.deployment.DeploymentException;
 import org.apache.tuscany.spi.annotation.Autowire;
 import org.apache.tuscany.spi.deployer.CompositeClassLoader;
@@ -75,13 +74,14 @@
 
             CompositeComponentType componentType = this.registry.load(null, null, contribution.getArtifact(source).getLocation(), CompositeComponentType.class, deploymentContext);
 
-            //FIXME add this to artifact
             CompositeImplementation implementation = new CompositeImplementation();
+            implementation.setComponentType(componentType);
             ComponentDefinition<CompositeImplementation> componentDefinition = new ComponentDefinition<CompositeImplementation>(implementation);
             
+            contribution.getArtifact(source).addModelObject(null, null, componentDefinition);
+            
         }catch(LoaderException le){
-            le.printStackTrace();
-            throw new ContributionProcessorException("Error processing SCDL", contribution.getArtifact(source).getLocation().toExternalForm(), le);
+            throw new InvalidComponentDefinitionlException(contribution.getArtifact(source).getLocation().toExternalForm(), le);
         }
     }
 

Added: incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessorTestCase.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessorTestCase.java?view=auto&rev=511434
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessorTestCase.java (added)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/core/src/test/java/org/apache/tuscany/core/services/deployment/contribution/FolderContributionProcessorTestCase.java Sat Feb 24 19:40:22 2007
@@ -0,0 +1,56 @@
+/*
+ * 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 java.io.File;
+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 FolderContributionProcessorTestCase extends TestCase {
+    private static final String DIRECTORY_CONTRIBUTION = "//D:/DEV/Projects/Tuscany/source/java-sca-integration/samples/sca/calculator";
+    
+    private File contributionRoot;
+    
+
+    protected void setUp() throws Exception {
+        super.setUp();
+        this.contributionRoot = new File(DIRECTORY_CONTRIBUTION);
+    }
+    
+    public final void testProcessJarArtifacts() throws Exception {
+//        FolderContributionProcessor folderContribution = new FolderContributionProcessor();
+//        ContributionProcessorRegistry mockRegistry = EasyMock.createMock(ContributionProcessorRegistry.class);
+//        mockRegistry.register(FolderContributionProcessor.CONTENT_TYPE, folderContribution);
+//        EasyMock.expectLastCall().anyTimes();
+//        EasyMock.replay(mockRegistry);
+//        folderContribution.setContributionProcessorRegistry(mockRegistry);
+//        folderContribution.start();
+//        EasyMock.verify(mockRegistry);
+//        
+//        Contribution contribution = new Contribution(URI.create("sca://contributions/001"));
+//        contribution.setLocation(this.contributionRoot.toURL());
+//        folderContribution.processContent(contribution, contribution.getUri(), null);
+    }
+}

Modified: incubator/tuscany/branches/sca-java-integration/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/ContributionService.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/ContributionService.java?view=diff&rev=511434&r1=511433&r2=511434
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/ContributionService.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/kernel/host-api/src/main/java/org/apache/tuscany/host/deployment/ContributionService.java Sat Feb 24 19:40:22 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 copyToRepository) 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

Modified: incubator/tuscany/branches/sca-java-integration/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLContributionProcessor.java
URL: http://svn.apache.org/viewvc/incubator/tuscany/branches/sca-java-integration/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLContributionProcessor.java?view=diff&rev=511434&r1=511433&r2=511434
==============================================================================
--- incubator/tuscany/branches/sca-java-integration/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLContributionProcessor.java (original)
+++ incubator/tuscany/branches/sca-java-integration/sca/services/idl/wsdl/src/main/java/org/apache/tuscany/idl/wsdl/WSDLContributionProcessor.java Sat Feb 24 19:40:22 2007
@@ -39,6 +39,7 @@
 import javax.wsdl.xml.WSDLReader;
 import javax.xml.namespace.QName;
 
+import org.apache.tuscany.core.services.deployment.ContributionProcessorException;
 import org.apache.tuscany.host.deployment.DeploymentException;
 import org.apache.tuscany.spi.annotation.Autowire;
 import org.apache.tuscany.spi.deployer.ArtifactResolverRegistry;
@@ -250,8 +251,7 @@
         try {
             loadDefinition(contribution, null, source, inputStream);
         } catch (WSDLException e) {
-            // TODO Auto-generated catch block
-            e.printStackTrace();
+            throw new ContributionProcessorException("Error processing WSDL", contribution.getArtifact(source).getLocation().toExternalForm(), e);
         } 
     }
 



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