tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r951457 - in /tuscany/sca-java-2.x/trunk/modules/domain/src: main/java/org/apache/tuscany/sca/something/ main/java/org/apache/tuscany/sca/something/impl/ test/java/org/apache/tuscany/sca/something/ test/resources/
Date Fri, 04 Jun 2010 15:48:26 GMT
Author: antelder
Date: Fri Jun  4 15:48:25 2010
New Revision: 951457

URL: http://svn.apache.org/viewvc?rev=951457&view=rev
Log:
Add support for generated sca-contribution.xml metadata

Added:
    tuscany/sca-java-2.x/trunk/modules/domain/src/test/resources/sca-contribution-generated.xml
Modified:
    tuscany/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/Section10.java
    tuscany/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java
    tuscany/sca-java-2.x/trunk/modules/domain/src/test/java/org/apache/tuscany/sca/something/DeployerTestCase.java
    tuscany/sca-java-2.x/trunk/modules/domain/src/test/java/org/apache/tuscany/sca/something/Section10TestCase.java

Modified: tuscany/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/Section10.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/Section10.java?rev=951457&r1=951456&r2=951457&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/Section10.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/Section10.java
Fri Jun  4 15:48:25 2010
@@ -64,9 +64,8 @@ public interface Section10 {
      * @throws ActivationException 
      * @throws ValidationException 
      */
-    void installContribution(String uri, String contributionURL, List<String> dependentContributionURIs,
boolean deployDeployables) throws ContributionReadException, ActivationException, ValidationException;
+    void installContribution(String uri, String contributionURL, String metaDataURL, List<String>
dependentContributionURIs, boolean deployDeployables) throws ContributionReadException, ActivationException,
ValidationException;
     void installContribution(Contribution contribution, List<String> dependentContributionURIs,
boolean deployDeployables) throws ContributionReadException, ActivationException, ValidationException;
-    /* TODO: also needs a parameter to add a generated sca-contribution document */
     
     /* Useful short forms of that for when you don't care or have the others (but leave out
for now to keep as simple as possible):
     String installContribution(String contributionURL) throws ContributionReadException,
ActivationException, ValidationException;

Modified: tuscany/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java?rev=951457&r1=951456&r2=951457&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/domain/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java
Fri Jun  4 15:48:25 2010
@@ -21,7 +21,6 @@ package org.apache.tuscany.sca.something
 
 import java.io.Reader;
 import java.net.URI;
-import java.net.URL;
 import java.util.ArrayList;
 import java.util.HashMap;
 import java.util.HashSet;
@@ -36,6 +35,7 @@ import org.apache.tuscany.sca.assembly.C
 import org.apache.tuscany.sca.common.java.io.IOHelper;
 import org.apache.tuscany.sca.contribution.Artifact;
 import org.apache.tuscany.sca.contribution.Contribution;
+import org.apache.tuscany.sca.contribution.ContributionMetadata;
 import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
 import org.apache.tuscany.sca.core.ExtensionPointRegistry;
 import org.apache.tuscany.sca.deployment.Deployer;
@@ -66,14 +66,30 @@ public class Section10Impl implements Se
         this.extensionPointRegistry = extensionPointRegistry;
     }
 
-    public void installContribution(String uri, String contributionURL, List<String>
dependentContributionURIs, boolean deployDeployables) throws ContributionReadException, ActivationException,
ValidationException {
-        URL url = IOHelper.getLocationAsURL(contributionURL);
+    public void installContribution(String uri, String contributionURL, String metaDataURL,
List<String> dependentContributionURIs, boolean deployDeployables) throws ContributionReadException,
ActivationException, ValidationException {
         Monitor monitor = deployer.createMonitor();
-        Contribution contribution = deployer.loadContribution(URI.create(uri), url, monitor);
+        Contribution contribution = deployer.loadContribution(URI.create(uri), IOHelper.getLocationAsURL(contributionURL),
monitor);
         monitor.analyzeProblems();
+        if (metaDataURL != null) {
+            mergeContributionMetaData(metaDataURL, contribution);
+        }
         installContribution(contribution, dependentContributionURIs, deployDeployables);
     }
 
+    private void mergeContributionMetaData(String metaDataURL, Contribution contribution)
throws ValidationException {
+        ContributionMetadata metaData;
+        Monitor monitor = deployer.createMonitor();
+        try {
+            metaData = deployer.loadXMLDocument(IOHelper.getLocationAsURL(metaDataURL), monitor);
+        } catch (Exception e) {
+            throw new ValidationException(e);
+        }
+        monitor.analyzeProblems();
+        contribution.getDeployables().addAll(metaData.getDeployables());
+        contribution.getImports().addAll(metaData.getImports());
+        contribution.getExports().addAll(metaData.getExports());
+    }
+    
     public void installContribution(Contribution contribution, List<String> dependentContributionURIs,
boolean deployDeployables) throws ContributionReadException, ActivationException, ValidationException
{
         // TODO: dependentContributionURIs
         InstalledContribution ic = new InstalledContribution(contribution.getURI(), contribution.getLocation(),
contribution);

Modified: tuscany/sca-java-2.x/trunk/modules/domain/src/test/java/org/apache/tuscany/sca/something/DeployerTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain/src/test/java/org/apache/tuscany/sca/something/DeployerTestCase.java?rev=951457&r1=951456&r2=951457&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain/src/test/java/org/apache/tuscany/sca/something/DeployerTestCase.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/domain/src/test/java/org/apache/tuscany/sca/something/DeployerTestCase.java
Fri Jun  4 15:48:25 2010
@@ -28,7 +28,6 @@ import javax.xml.stream.XMLStreamExcepti
 import junit.framework.Assert;
 
 import org.apache.tuscany.sca.assembly.Composite;
-import org.apache.tuscany.sca.contribution.Artifact;
 import org.apache.tuscany.sca.contribution.Contribution;
 import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
 import org.apache.tuscany.sca.deployment.Deployer;
@@ -60,7 +59,7 @@ public class DeployerTestCase {
     public void testAddDeploymentComposite() throws NoSuchServiceException, NoSuchDomainException,
ContributionReadException, ActivationException, ValidationException, MalformedURLException,
XMLStreamException {
         Section10 section10 = Section10Factory.createSection10();
         
-        section10.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar",
null, true);
+        section10.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar",
null, null, true);
 
         Deployer deployer = section10.getDeployer();
         Monitor monitor = deployer.createMonitor();

Modified: tuscany/sca-java-2.x/trunk/modules/domain/src/test/java/org/apache/tuscany/sca/something/Section10TestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain/src/test/java/org/apache/tuscany/sca/something/Section10TestCase.java?rev=951457&r1=951456&r2=951457&view=diff
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain/src/test/java/org/apache/tuscany/sca/something/Section10TestCase.java
(original)
+++ tuscany/sca-java-2.x/trunk/modules/domain/src/test/java/org/apache/tuscany/sca/something/Section10TestCase.java
Fri Jun  4 15:48:25 2010
@@ -26,6 +26,7 @@ import junit.framework.Assert;
 import org.apache.tuscany.sca.contribution.processor.ContributionReadException;
 import org.apache.tuscany.sca.monitor.ValidationException;
 import org.apache.tuscany.sca.runtime.ActivationException;
+import org.apache.tuscany.sca.something.impl.Section10Impl;
 import org.junit.Ignore;
 import org.junit.Test;
 import org.oasisopen.sca.NoSuchDomainException;
@@ -36,7 +37,7 @@ public class Section10TestCase {
     @Test
     public void testInstallDeployable() throws NoSuchServiceException, NoSuchDomainException,
ContributionReadException, ActivationException, ValidationException {
         Section10 section10 = Section10Factory.createSection10();
-        section10.installContribution("helloworld", "src/test/resources/sample-helloworld.jar",
null, true);
+        section10.installContribution("helloworld", "src/test/resources/sample-helloworld.jar",
null, null, true);
 
 //        Helloworld helloworldService = section10.getService(Helloworld.class, "HelloworldComponent");
 //        Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
@@ -46,8 +47,8 @@ public class Section10TestCase {
     @Test
     public void testInstallWithDependent() throws NoSuchServiceException, ContributionReadException,
ActivationException, ValidationException {
         Section10 section10 = Section10Factory.createSection10();
-        section10.installContribution("store", "/Tuscany/svn/2.x-trunk/itest/T3558/src/test/resources/sample-store.jar",
null, true);
-        section10.installContribution("store-client", "/Tuscany/svn/2.x-trunk/itest/T3558/src/test/resources/sample-store-client.jar",
null, true);
+        section10.installContribution("store", "/Tuscany/svn/2.x-trunk/itest/T3558/src/test/resources/sample-store.jar",
null, null, true);
+        section10.installContribution("store-client", "/Tuscany/svn/2.x-trunk/itest/T3558/src/test/resources/sample-store-client.jar",
null, null, true);
 
 //        Helloworld helloworldService = section10.getService(Helloworld.class, "HelloworldComponent");
 //        Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
@@ -56,7 +57,7 @@ public class Section10TestCase {
     @Test
     public void testInstallNoDeployable() throws NoSuchServiceException, NoSuchDomainException,
ContributionReadException, ActivationException, ValidationException {
         Section10 section10 = Section10Factory.createSection10();
-        section10.installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar",
null, true);
+        section10.installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar",
null, null, true);
 
 //        SCAClientFactory scaClientFactory = section10.getSCAClientFactory();
 //        try {
@@ -74,7 +75,7 @@ public class Section10TestCase {
     @Test
     public void testGetInstalledContributions() throws NoSuchServiceException, NoSuchDomainException,
ContributionReadException, ActivationException, ValidationException {
         Section10 section10 = Section10Factory.createSection10();
-        section10.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar",
null, true);
+        section10.installContribution("foo", "src/test/resources/sample-helloworld-nodeployable.jar",
null, null, true);
         List<String> ics = section10.getInstalledContributions();
         Assert.assertEquals(1, ics.size());
         Assert.assertEquals("foo", ics.get(0));
@@ -83,7 +84,7 @@ public class Section10TestCase {
     @Test
     public void testGetDeployedCompostes() throws NoSuchServiceException, NoSuchDomainException,
ContributionReadException, MalformedURLException, ActivationException, ValidationException
{
         Section10 section10 = Section10Factory.createSection10();
-        section10.installContribution("foo", "src/test/resources/sample-helloworld.jar",
null, true);
+        section10.installContribution("foo", "src/test/resources/sample-helloworld.jar",
null, null, true);
         List<String> dcs = section10.getDeployedCompostes("foo");
         Assert.assertEquals(1, dcs.size());
         Assert.assertEquals("foo/helloworld.composite", dcs.get(0));
@@ -92,10 +93,22 @@ public class Section10TestCase {
     @Test
     public void testRemoveComposte() throws NoSuchServiceException, NoSuchDomainException,
ContributionReadException, MalformedURLException, ActivationException, ValidationException
{
         Section10 section10 = Section10Factory.createSection10();
-        section10.installContribution("foo", "src/test/resources/sample-helloworld.jar",
null, true);
+        section10.installContribution("foo", "src/test/resources/sample-helloworld.jar",
null, null, true);
         section10.removeFromDomainLevelComposite("foo/helloworld.composite");
         List<String> dcs = section10.getDeployedCompostes("foo");
         Assert.assertEquals(0, dcs.size());
     }
 
+    @Test
+    public void testInstallWithMetaData() throws ContributionReadException, ActivationException,
ValidationException {
+        Section10 section10 = Section10Factory.createSection10();
+        ((Section10Impl)section10).installContribution("helloworld", "src/test/resources/sample-helloworld-nodeployable.jar",
"src/test/resources/sca-contribution-generated.xml", null, true);
+
+        List<String> dcs = section10.getDeployedCompostes("helloworld");
+        Assert.assertEquals(1, dcs.size());
+        Assert.assertEquals("helloworld/helloworld.composite", dcs.get(0));
+
+//        Helloworld helloworldService = scaClientFactory.getService(Helloworld.class, "HelloworldComponent");
+//        Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
+    }
 }

Added: tuscany/sca-java-2.x/trunk/modules/domain/src/test/resources/sca-contribution-generated.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/trunk/modules/domain/src/test/resources/sca-contribution-generated.xml?rev=951457&view=auto
==============================================================================
--- tuscany/sca-java-2.x/trunk/modules/domain/src/test/resources/sca-contribution-generated.xml
(added)
+++ tuscany/sca-java-2.x/trunk/modules/domain/src/test/resources/sca-contribution-generated.xml
Fri Jun  4 15:48:25 2010
@@ -0,0 +1,23 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.    
+-->
+<contribution xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912"
+              xmlns:sample="http://sample">
+   <deployable composite="sample:helloworld"/>
+</contribution>



Mime
View raw message