tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From antel...@apache.org
Subject svn commit: r719560 - in /tuscany/java/sca/samples/calculator/src: main/java/calculator/CalculatorClient.java main/resources/META-INF/ main/resources/META-INF/sca-contribution.xml test/java/calculator/CalculatorTestCase.java
Date Fri, 21 Nov 2008 11:25:50 GMT
Author: antelder
Date: Fri Nov 21 03:25:50 2008
New Revision: 719560

URL: http://svn.apache.org/viewvc?rev=719560&view=rev
Log:
Get j2se calculator working with current stage 1 modules

Added:
    tuscany/java/sca/samples/calculator/src/main/resources/META-INF/
    tuscany/java/sca/samples/calculator/src/main/resources/META-INF/sca-contribution.xml
Modified:
    tuscany/java/sca/samples/calculator/src/main/java/calculator/CalculatorClient.java
    tuscany/java/sca/samples/calculator/src/test/java/calculator/CalculatorTestCase.java

Modified: tuscany/java/sca/samples/calculator/src/main/java/calculator/CalculatorClient.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/samples/calculator/src/main/java/calculator/CalculatorClient.java?rev=719560&r1=719559&r2=719560&view=diff
==============================================================================
--- tuscany/java/sca/samples/calculator/src/main/java/calculator/CalculatorClient.java (original)
+++ tuscany/java/sca/samples/calculator/src/main/java/calculator/CalculatorClient.java Fri
Nov 21 03:25:50 2008
@@ -19,9 +19,11 @@
 
 package calculator;
 
-import org.apache.tuscany.sca.node.SCAClient;
-import org.apache.tuscany.sca.node.SCANode;
-import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.apache.tuscany.sca.node.Client;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
 
 /**
  * This client program shows how to create an SCA runtime, start it,
@@ -30,11 +32,14 @@
 public class CalculatorClient {
     public static void main(String[] args) throws Exception {
 
-        SCANodeFactory factory = SCANodeFactory.newInstance();
-        SCANode node = factory.createSCANodeFromClassLoader("Calculator.composite", CalculatorClient.class.getClassLoader());
+        NodeFactory factory = NodeFactory.newInstance();
+        String root = ContributionLocationHelper.getContributionLocation("Calculator.composite");
+        Contribution contribution = new Contribution(root, root);
+        Node node = factory.createNode("Calculator.composite", contribution);
+
         node.start();
         
-        CalculatorService calculatorService = ((SCAClient)node).getService(CalculatorService.class,
"CalculatorServiceComponent");
+        CalculatorService calculatorService = ((Client)node).getService(CalculatorService.class,
"CalculatorServiceComponent");
         
         // Calculate
         System.out.println("3 + 2=" + calculatorService.add(3, 2));

Added: tuscany/java/sca/samples/calculator/src/main/resources/META-INF/sca-contribution.xml
URL: http://svn.apache.org/viewvc/tuscany/java/sca/samples/calculator/src/main/resources/META-INF/sca-contribution.xml?rev=719560&view=auto
==============================================================================
--- tuscany/java/sca/samples/calculator/src/main/resources/META-INF/sca-contribution.xml (added)
+++ tuscany/java/sca/samples/calculator/src/main/resources/META-INF/sca-contribution.xml Fri
Nov 21 03:25:50 2008
@@ -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://www.osoa.org/xmlns/sca/1.0"
+              xmlns:sample="http://sample">
+   <deployable composite="sample:Calculator"/>
+</contribution>
\ No newline at end of file

Modified: tuscany/java/sca/samples/calculator/src/test/java/calculator/CalculatorTestCase.java
URL: http://svn.apache.org/viewvc/tuscany/java/sca/samples/calculator/src/test/java/calculator/CalculatorTestCase.java?rev=719560&r1=719559&r2=719560&view=diff
==============================================================================
--- tuscany/java/sca/samples/calculator/src/test/java/calculator/CalculatorTestCase.java (original)
+++ tuscany/java/sca/samples/calculator/src/test/java/calculator/CalculatorTestCase.java Fri
Nov 21 03:25:50 2008
@@ -20,9 +20,11 @@
 
 import junit.framework.TestCase;
 
-import org.apache.tuscany.sca.node.SCAClient;
-import org.apache.tuscany.sca.node.SCANode;
-import org.apache.tuscany.sca.node.SCANodeFactory;
+import org.apache.tuscany.sca.node.Client;
+import org.apache.tuscany.sca.node.Contribution;
+import org.apache.tuscany.sca.node.ContributionLocationHelper;
+import org.apache.tuscany.sca.node.Node;
+import org.apache.tuscany.sca.node.NodeFactory;
 
 /**
  * This shows how to test the Calculator service component.
@@ -30,15 +32,18 @@
 public class CalculatorTestCase extends TestCase {
 
     private CalculatorService calculatorService;
-    private SCANode node;
+    private Node node;
 
     @Override
     protected void setUp() throws Exception {
-        SCANodeFactory factory = SCANodeFactory.newInstance();
-        node = factory.createSCANodeFromClassLoader("Calculator.composite", getClass().getClassLoader());
+        NodeFactory factory = NodeFactory.newInstance();
+        String root = ContributionLocationHelper.getContributionLocation("Calculator.composite");
+        Contribution contribution = new Contribution(root, root);
+        node = factory.createNode("Calculator.composite", contribution);
+
         node.start();
         
-        calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent");
+        calculatorService = ((Client)node).getService(CalculatorService.class, "CalculatorServiceComponent");
     }
 
     @Override



Mime
View raw message