summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--java/sca/samples/calculator/pom.xml9
-rw-r--r--java/sca/samples/calculator/src/main/java/calculator/CalculatorClient.java15
-rw-r--r--java/sca/samples/calculator/src/test/java/calculator/CalculatorTestCase.java15
3 files changed, 27 insertions, 12 deletions
diff --git a/java/sca/samples/calculator/pom.xml b/java/sca/samples/calculator/pom.xml
index 32015d9250..df2f8d93dd 100644
--- a/java/sca/samples/calculator/pom.xml
+++ b/java/sca/samples/calculator/pom.xml
@@ -38,12 +38,19 @@
<dependencies>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
- <artifactId>tuscany-host-embedded</artifactId>
+ <artifactId>tuscany-node2-api</artifactId>
<version>1.4-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.apache.tuscany.sca</groupId>
+ <artifactId>tuscany-node2-impl</artifactId>
+ <version>1.4-SNAPSHOT</version>
+ <scope>runtime</scope>
+ </dependency>
+
+ <dependency>
+ <groupId>org.apache.tuscany.sca</groupId>
<artifactId>tuscany-implementation-java-runtime</artifactId>
<version>1.4-SNAPSHOT</version>
<scope>runtime</scope>
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 9d180bf52e..6dc2cbbe6f 100644
--- a/java/sca/samples/calculator/src/main/java/calculator/CalculatorClient.java
+++ b/java/sca/samples/calculator/src/main/java/calculator/CalculatorClient.java
@@ -19,7 +19,9 @@
package calculator;
-import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.apache.tuscany.sca.node.SCAClient;
+import org.apache.tuscany.sca.node.SCANode2;
+import org.apache.tuscany.sca.node.SCANode2Factory;
/**
* This client program shows how to create an SCA runtime, start it,
@@ -28,18 +30,19 @@ import org.apache.tuscany.sca.host.embedded.SCADomain;
public class CalculatorClient {
public static void main(String[] args) throws Exception {
- SCADomain scaDomain = SCADomain.newInstance("Calculator.composite");
+ SCANode2Factory factory = SCANode2Factory.newInstance();
+ SCANode2 node = factory.createSCANodeFromClassLoader("Calculator.composite", CalculatorClient.class.getClassLoader());
+ node.start();
+
+ CalculatorService calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent");
- CalculatorService calculatorService =
- scaDomain.getService(CalculatorService.class, "CalculatorServiceComponent");
-
// Calculate
System.out.println("3 + 2=" + calculatorService.add(3, 2));
System.out.println("3 - 2=" + calculatorService.subtract(3, 2));
System.out.println("3 * 2=" + calculatorService.multiply(3, 2));
System.out.println("3 / 2=" + calculatorService.divide(3, 2));
- scaDomain.close();
+ node.stop();
}
}
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 775ad15537..a723af10c6 100644
--- a/java/sca/samples/calculator/src/test/java/calculator/CalculatorTestCase.java
+++ b/java/sca/samples/calculator/src/test/java/calculator/CalculatorTestCase.java
@@ -20,7 +20,9 @@ package calculator;
import junit.framework.TestCase;
-import org.apache.tuscany.sca.host.embedded.SCADomain;
+import org.apache.tuscany.sca.node.SCAClient;
+import org.apache.tuscany.sca.node.SCANode2;
+import org.apache.tuscany.sca.node.SCANode2Factory;
/**
* This shows how to test the Calculator service component.
@@ -28,17 +30,20 @@ import org.apache.tuscany.sca.host.embedded.SCADomain;
public class CalculatorTestCase extends TestCase {
private CalculatorService calculatorService;
- private SCADomain scaDomain;
+ private SCANode2 node;
@Override
protected void setUp() throws Exception {
- scaDomain = SCADomain.newInstance("Calculator.composite");
- calculatorService = scaDomain.getService(CalculatorService.class, "CalculatorServiceComponent");
+ SCANode2Factory factory = SCANode2Factory.newInstance();
+ node = factory.createSCANodeFromClassLoader("Calculator.composite", getClass().getClassLoader());
+ node.start();
+
+ calculatorService = ((SCAClient)node).getService(CalculatorService.class, "CalculatorServiceComponent");
}
@Override
protected void tearDown() throws Exception {
- scaDomain.close();
+ node.stop();
}
public void testCalculator() throws Exception {