tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r946913 - in /tuscany/sca-java-2.x/contrib/modules/section10: ./ src/main/java/org/apache/tuscany/sca/something/ src/main/java/org/apache/tuscany/sca/something/impl/ src/test/ src/test/java/ src/test/java/org/ src/test/java/org/apache/ src/...
Date Fri, 21 May 2010 07:11:36 GMT
Author: antelder
Date: Fri May 21 07:11:35 2010
New Revision: 946913

URL: http://svn.apache.org/viewvc?rev=946913&view=rev
Log:
Add start of a basic impl using Node to install contributions. Not much works yet but the
helloworld type testcase does run

Added:
    tuscany/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/Section10Factory.java
    tuscany/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/
    tuscany/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java
    tuscany/sca-java-2.x/contrib/modules/section10/src/test/
    tuscany/sca-java-2.x/contrib/modules/section10/src/test/java/
    tuscany/sca-java-2.x/contrib/modules/section10/src/test/java/org/
    tuscany/sca-java-2.x/contrib/modules/section10/src/test/java/org/apache/
    tuscany/sca-java-2.x/contrib/modules/section10/src/test/java/org/apache/tuscany/
    tuscany/sca-java-2.x/contrib/modules/section10/src/test/java/org/apache/tuscany/sca/
    tuscany/sca-java-2.x/contrib/modules/section10/src/test/java/org/apache/tuscany/sca/something/
    tuscany/sca-java-2.x/contrib/modules/section10/src/test/java/org/apache/tuscany/sca/something/Section10TestCase.java
    tuscany/sca-java-2.x/contrib/modules/section10/src/test/java/sample/
    tuscany/sca-java-2.x/contrib/modules/section10/src/test/java/sample/Helloworld.java
    tuscany/sca-java-2.x/contrib/modules/section10/src/test/resources/
    tuscany/sca-java-2.x/contrib/modules/section10/src/test/resources/sample-helloworld-nodeployable.jar
  (with props)
    tuscany/sca-java-2.x/contrib/modules/section10/src/test/resources/sample-helloworld.jar
  (with props)
Modified:
    tuscany/sca-java-2.x/contrib/modules/section10/pom.xml
    tuscany/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/Section10.java

Modified: tuscany/sca-java-2.x/contrib/modules/section10/pom.xml
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/modules/section10/pom.xml?rev=946913&r1=946912&r2=946913&view=diff
==============================================================================
--- tuscany/sca-java-2.x/contrib/modules/section10/pom.xml (original)
+++ tuscany/sca-java-2.x/contrib/modules/section10/pom.xml Fri May 21 07:11:35 2010
@@ -30,10 +30,16 @@
 
     <dependencies>
         <dependency>
-            <groupId>org.apache.tuscany.sca</groupId>
-            <artifactId>tuscany-sca-api</artifactId>
+            <groupId>org.apache.tuscany.sca.shades</groupId>
+            <artifactId>tuscany-base</artifactId>
             <version>2.0-SNAPSHOT</version>
         </dependency>
+        <dependency>
+            <groupId>junit</groupId>
+            <artifactId>junit</artifactId>
+            <version>4.8.1</version>
+            <scope>test</scope>
+        </dependency>
     </dependencies>
 
 </project>

Modified: tuscany/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/Section10.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/Section10.java?rev=946913&r1=946912&r2=946913&view=diff
==============================================================================
--- tuscany/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/Section10.java
(original)
+++ tuscany/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/Section10.java
Fri May 21 07:11:35 2010
@@ -83,7 +83,8 @@ public interface Section10 {
      * 4595 [ASM12009]
      * 4596 Note that in many cases, the dependent contribution list can be generated. In
particular, if the creator of
      * 4597 a Domain is careful to avoid creating duplicate definitions for the same qualified
name, then it is easy for
-     * 4598 this list to be generated by tooling.     * 
+     * 4598 this list to be generated by tooling.
+     *  
      * @param uri
      * @param contributionURL
      */

Added: tuscany/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/Section10Factory.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/Section10Factory.java?rev=946913&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/Section10Factory.java
(added)
+++ tuscany/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/Section10Factory.java
Fri May 21 07:11:35 2010
@@ -0,0 +1,38 @@
+/*
+ * 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.sca.something;
+
+import java.util.Properties;
+
+import org.apache.tuscany.sca.something.impl.Section10Impl;
+
+public class Section10Factory {
+
+    public static Section10 createSection10() {
+        Properties defaultConfig = new Properties();
+        defaultConfig.setProperty("defaultScheme", "vm");
+        defaultConfig.setProperty("defaultDomainName", "default");
+        return new Section10Impl(defaultConfig);
+    }
+
+    public static Section10 createSection10(Properties config) {
+        return new Section10Impl(config);
+    }
+}

Added: tuscany/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java?rev=946913&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java
(added)
+++ tuscany/sca-java-2.x/contrib/modules/section10/src/main/java/org/apache/tuscany/sca/something/impl/Section10Impl.java
Fri May 21 07:11:35 2010
@@ -0,0 +1,191 @@
+/*
+ * 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.sca.something.impl;
+
+import java.io.Reader;
+import java.net.URI;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+
+import javax.xml.namespace.QName;
+
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
+import org.apache.tuscany.sca.node.configuration.NodeConfiguration;
+import org.apache.tuscany.sca.node.impl.NodeFactoryImpl;
+import org.apache.tuscany.sca.node.impl.NodeImpl;
+import org.apache.tuscany.sca.something.Section10;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.client.SCAClientFactory;
+import org.w3c.dom.Document;
+
+public class Section10Impl implements Section10 {
+
+    private NodeFactory nodeFactory;
+    private Map<String, Node> installedContributions = new HashMap<String, Node>();
+    
+    public Section10Impl(Properties config) {
+        this.nodeFactory = NodeFactory.newInstance(config);
+        ((NodeFactoryImpl)nodeFactory).start();
+    }
+
+    public String addDeploymentComposite(String contriubutionURI, String compositeXML) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String addDeploymentComposite(String contriubutionURI, Reader compositeXML) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public void addToDomainLevelComposite(String compositeURI) {
+        String contributionURI = getContributionUriFromArtifactUri(compositeURI);
+        String artifactURI = compositeURI.substring(contributionURI.length()+1);
+        // TODO: now what? there doesn't appear to be any way yet to do this with the exsiting
Node API
+    }
+
+    protected String getContributionUriFromArtifactUri(String artifactURI) {
+        String contributionURI = null;
+        for (String uri : installedContributions.keySet()) {
+            if (artifactURI.startsWith(uri)) {
+                contributionURI = uri;
+                break;
+            }
+        }
+        if (contributionURI == null) {
+            throw new IllegalArgumentException("no contribution found for: " + artifactURI);
+        }
+        return contributionURI;
+    }
+
+    public void deployContribution(String contributionURI) {
+        // TODO Auto-generated method stub
+    }
+
+    public Document getDomainLevelComposite() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String getDomainLevelCompositeAsString() {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public Object getQNameDefinition(String contributionURI, QName definition, QName symbolSpace)
{
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public SCAClientFactory getSCAClientFactory() {
+        try {
+            return SCAClientFactory.newInstance(URI.create(getDomainName()));
+        } catch (NoSuchDomainException e) {
+            throw new IllegalStateException(e);
+        }
+    }
+
+    private String getDomainName() {
+        // TODO Auto-generated method stub
+        return "default";
+    }
+
+    public void installContribution(String uri, String contributionURL, List<String>
dependentContributionURIs) {
+        if (dependentContributionURIs == null) {
+            dependentContributionURIs = Collections.emptyList();
+        }
+        String[] cs = new String[dependentContributionURIs.size()+1];
+        cs[0] = contributionURL;
+        for (int i=1; i<dependentContributionURIs.size(); i++) {
+            cs[i] = getContributionURL(dependentContributionURIs.get(i));
+        }
+        Node node = nodeFactory.createNode((String)null, cs);
+        node.start();
+        installedContributions.put(uri, node);
+    }
+    
+    protected String getContributionURL(String contributionURI) {
+        Node n = installedContributions.get(contributionURI);
+        if (n == null) {
+            throw new IllegalStateException("not installed: " + contributionURI);
+        }
+        NodeConfiguration c = ((NodeImpl)n).getConfiguration();
+        return c.getContributions().get(0).getLocation();
+    }
+
+    public String installContribution(String contributionURL) {
+        installContribution(contributionURL, contributionURL, null);
+        return contributionURL;
+    }
+
+    public void installContribution(String uri, String contributionURL) {
+        installContribution(uri, contributionURL, null);
+    }
+
+    public void removeContribution(String contributionURI) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void removeFromDomainLevelComposite(String compositeURI) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void shutdown() {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void startComponent(String componentURI) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void stopComponent(String componentURI) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void undeployContribution(String contributionURI) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public void updateContribution(String uri, String contributionURL) {
+        // TODO Auto-generated method stub
+        
+    }
+
+    public String updateDeploymentComposite(String uri, String compositeXML) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+    public String updateDeploymentComposite(String uri, Reader compositeXML) {
+        // TODO Auto-generated method stub
+        return null;
+    }
+
+}

Added: tuscany/sca-java-2.x/contrib/modules/section10/src/test/java/org/apache/tuscany/sca/something/Section10TestCase.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/modules/section10/src/test/java/org/apache/tuscany/sca/something/Section10TestCase.java?rev=946913&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/modules/section10/src/test/java/org/apache/tuscany/sca/something/Section10TestCase.java
(added)
+++ tuscany/sca-java-2.x/contrib/modules/section10/src/test/java/org/apache/tuscany/sca/something/Section10TestCase.java
Fri May 21 07:11:35 2010
@@ -0,0 +1,72 @@
+/*
+ * 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.sca.something;
+
+import junit.framework.Assert;
+
+import org.junit.Test;
+import org.oasisopen.sca.NoSuchDomainException;
+import org.oasisopen.sca.NoSuchServiceException;
+import org.oasisopen.sca.client.SCAClientFactory;
+
+import sample.Helloworld;
+
+public class Section10TestCase {
+
+    @Test
+    public void testInstallDeployable() throws NoSuchServiceException, NoSuchDomainException
{
+        Section10 section10 = Section10Factory.createSection10();
+        section10.installContribution("src/test/resources/sample-helloworld.jar");
+
+        SCAClientFactory scaClientFactory = section10.getSCAClientFactory();
+        Helloworld helloworldService = scaClientFactory.getService(Helloworld.class, "HelloworldComponent");
+        Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
+    }
+
+    @Test
+    public void testInstallWithDependent() throws NoSuchServiceException, NoSuchDomainException
{
+        Section10 section10 = Section10Factory.createSection10();
+        section10.installContribution("/Tuscany/svn/2.x-trunk/itest/T3558/src/test/resources/sample-store.jar");
+        section10.installContribution("/Tuscany/svn/2.x-trunk/itest/T3558/src/test/resources/sample-store-client.jar");
+
+        SCAClientFactory scaClientFactory = section10.getSCAClientFactory();
+        Helloworld helloworldService = scaClientFactory.getService(Helloworld.class, "HelloworldComponent");
+        Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
+    }
+
+// Doesnt work yet as addToDomainLevelComposite doesn't work 
+//    @Test
+//    public void testInstallNoDeployable() throws NoSuchServiceException, NoSuchDomainException
{
+//        Section10 section10 = Section10Factory.createSection10();
+//        String contributionURI = section10.installContribution("src/test/resources/sample-helloworld-nodeployable.jar");
+//
+//        SCAClientFactory scaClientFactory = section10.getSCAClientFactory();
+//        try {
+//            scaClientFactory.getService(Helloworld.class, "HelloworldComponent");
+//            Assert.fail();
+//        } catch (NoSuchServiceException e) {
+//            // expected as there is no deployables
+//        }
+//
+//        section10.addToDomainLevelComposite(contributionURI + "/helloworld.composite");
+//        Helloworld helloworldService = scaClientFactory.getService(Helloworld.class, "HelloworldComponent");
+//        Assert.assertEquals("Hello petra", helloworldService.sayHello("petra"));
+//    }
+
+}

Added: tuscany/sca-java-2.x/contrib/modules/section10/src/test/java/sample/Helloworld.java
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/modules/section10/src/test/java/sample/Helloworld.java?rev=946913&view=auto
==============================================================================
--- tuscany/sca-java-2.x/contrib/modules/section10/src/test/java/sample/Helloworld.java (added)
+++ tuscany/sca-java-2.x/contrib/modules/section10/src/test/java/sample/Helloworld.java Fri
May 21 07:11:35 2010
@@ -0,0 +1,24 @@
+/*
+ * 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 sample;
+
+public interface Helloworld {
+    String sayHello(String name);
+}

Added: tuscany/sca-java-2.x/contrib/modules/section10/src/test/resources/sample-helloworld-nodeployable.jar
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/modules/section10/src/test/resources/sample-helloworld-nodeployable.jar?rev=946913&view=auto
==============================================================================
Binary file - no diff available.

Propchange: tuscany/sca-java-2.x/contrib/modules/section10/src/test/resources/sample-helloworld-nodeployable.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream

Added: tuscany/sca-java-2.x/contrib/modules/section10/src/test/resources/sample-helloworld.jar
URL: http://svn.apache.org/viewvc/tuscany/sca-java-2.x/contrib/modules/section10/src/test/resources/sample-helloworld.jar?rev=946913&view=auto
==============================================================================
Binary file - no diff available.

Propchange: tuscany/sca-java-2.x/contrib/modules/section10/src/test/resources/sample-helloworld.jar
------------------------------------------------------------------------------
    svn:mime-type = application/octet-stream



Mime
View raw message