summaryrefslogtreecommitdiffstats
path: root/java/sca/samples/calculator
diff options
context:
space:
mode:
Diffstat (limited to 'java/sca/samples/calculator')
-rw-r--r--java/sca/samples/calculator/src/main/java/calculator/CalculatorClient.java17
-rw-r--r--java/sca/samples/calculator/src/main/resources/META-INF/sca-contribution.xml23
-rw-r--r--java/sca/samples/calculator/src/test/java/calculator/CalculatorTestCase.java19
3 files changed, 46 insertions, 13 deletions
diff --git a/java/sca/samples/calculator/src/main/java/calculator/CalculatorClient.java b/java/sca/samples/calculator/src/main/java/calculator/CalculatorClient.java
index 3b2966e96d..5496521525 100644
--- a/java/sca/samples/calculator/src/main/java/calculator/CalculatorClient.java
+++ b/java/sca/samples/calculator/src/main/java/calculator/CalculatorClient.java
@@ -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 @@ import org.apache.tuscany.sca.node.SCANodeFactory;
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));
diff --git a/java/sca/samples/calculator/src/main/resources/META-INF/sca-contribution.xml b/java/sca/samples/calculator/src/main/resources/META-INF/sca-contribution.xml
new file mode 100644
index 0000000000..8b60ae590c
--- /dev/null
+++ b/java/sca/samples/calculator/src/main/resources/META-INF/sca-contribution.xml
@@ -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
diff --git a/java/sca/samples/calculator/src/test/java/calculator/CalculatorTestCase.java b/java/sca/samples/calculator/src/test/java/calculator/CalculatorTestCase.java
index 1b7476534a..464950f08c 100644
--- a/java/sca/samples/calculator/src/test/java/calculator/CalculatorTestCase.java
+++ b/java/sca/samples/calculator/src/test/java/calculator/CalculatorTestCase.java
@@ -20,9 +20,11 @@ package calculator;
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 @@ import org.apache.tuscany.sca.node.SCANodeFactory;
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