From cbd96cbf252e7e6989aba9a46a556573aa533606 Mon Sep 17 00:00:00 2001 From: slaws Date: Sun, 12 Oct 2008 12:25:49 +0000 Subject: Branch for 1.3.3 git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@703809 13f79535-47bb-0310-9956-ffa450edef68 --- .../samples/calculator-distributed/README | 438 +++++++++++++++++++++ .../samples/calculator-distributed/build.xml | 114 ++++++ .../calculator-distributed.png | Bin 0 -> 76839 bytes .../calculator-distributed.svg | 383 ++++++++++++++++++ .../samples/calculator-distributed/cloud.composite | 26 ++ .../calculator-distributed/domain.composite | 26 ++ .../samples/calculator-distributed/pom.xml | 119 ++++++ .../src/main/java/calculator/AddService.java | 31 ++ .../src/main/java/calculator/AddServiceImpl.java | 31 ++ .../main/java/calculator/CalculatorService.java | 35 ++ .../java/calculator/CalculatorServiceImpl.java | 74 ++++ .../src/main/java/calculator/DivideService.java | 28 ++ .../main/java/calculator/DivideServiceImpl.java | 30 ++ .../src/main/java/calculator/MultiplyService.java | 28 ++ .../main/java/calculator/MultiplyServiceImpl.java | 30 ++ .../src/main/java/calculator/SubtractService.java | 31 ++ .../main/java/calculator/SubtractServiceImpl.java | 31 ++ .../src/main/java/node/LaunchCalculatorNodeA.java | 67 ++++ .../src/main/java/node/LaunchCalculatorNodeB.java | 28 ++ .../src/main/java/node/LaunchCalculatorNodeC.java | 28 ++ .../src/main/java/node/LaunchDomain.java | 33 ++ .../src/main/resources/cloud/NodeA.composite | 33 ++ .../src/main/resources/cloud/NodeB.composite | 33 ++ .../src/main/resources/cloud/NodeC.composite | 33 ++ .../src/main/resources/nodeA/Calculator.composite | 41 ++ .../resources/nodeA/META-INF/sca-contribution.xml | 24 ++ .../src/main/resources/nodeB/Calculator.composite | 29 ++ .../resources/nodeB/META-INF/sca-contribution.xml | 24 ++ .../src/main/resources/nodeC/Calculator.composite | 29 ++ .../resources/nodeC/META-INF/sca-contribution.xml | 24 ++ .../calculator/CalculatorDistributedTestCase.java | 92 +++++ .../samples/calculator-distributed/workspace.xml | 25 ++ 32 files changed, 1998 insertions(+) create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/README create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/build.xml create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/calculator-distributed.png create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/calculator-distributed.svg create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/cloud.composite create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/domain.composite create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/pom.xml create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/AddService.java create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/AddServiceImpl.java create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/CalculatorService.java create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/CalculatorServiceImpl.java create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/DivideService.java create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/DivideServiceImpl.java create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/MultiplyService.java create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/MultiplyServiceImpl.java create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/SubtractService.java create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/SubtractServiceImpl.java create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeA.java create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeB.java create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeC.java create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/node/LaunchDomain.java create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/cloud/NodeA.composite create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/cloud/NodeB.composite create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/cloud/NodeC.composite create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeA/Calculator.composite create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeA/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeB/Calculator.composite create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeB/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeC/Calculator.composite create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeC/META-INF/sca-contribution.xml create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/src/test/java/calculator/CalculatorDistributedTestCase.java create mode 100644 branches/sca-java-1.3.3/samples/calculator-distributed/workspace.xml (limited to 'branches/sca-java-1.3.3/samples/calculator-distributed') diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/README b/branches/sca-java-1.3.3/samples/calculator-distributed/README new file mode 100644 index 0000000000..51f4b07e81 --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/README @@ -0,0 +1,438 @@ +Calculator Distributed Sample +============================= +This sample implements a simple calculator using SCA components. It uses +exactly the same calculator application classes as the calculator sample but +runs the application distributed across three nodes. + +A node in this sample means an instance of the Tuscany SCA java runtime running +in a Java virtual machine. + +The README in the samples directory (the directory above this) provides +general instructions about building and running samples. Take a look there +first. + +If you just want to run it to see what happens open four command prompts and +navigate to this sample directory in each one. There is one command to be run +in each command prompt: + +ant runDomain +ant runNodeB +ant runNodeC +ant runNodeA + +Please run the commands in this order. + +OR if you don't have ant, on Windows use + +java -cp src\main\resources;..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator-distributed.jar node.LaunchDomain +java -cp src\main\resources;..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator-distributed.jar node.LaunchCalculatorNodeB +java -cp src\main\resources;..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator-distributed.jar node.LaunchCalculatorNodeC +java -cp src\main\resources;..\..\lib\tuscany-sca-manifest.jar;target\sample-calculator-distributed.jar node.LaunchCalculatorNodeA + +and on *nix do + +java -cp src/main/resources:../../lib/tuscany-sca-manifest.jar:target/sample-calculator-distributed.jar node.LaunchDomain +java -cp src/main/resources:../../lib/tuscany-sca-manifest.jar:target/sample-calculator-distributed.jar node.LaunchCalculatorNodeB +java -cp src/main/resources:../../lib/tuscany-sca-manifest.jar:target/sample-calculator-distributed.jar node.LaunchCalculatorNodeC +java -cp src/main/resources:../../lib/tuscany-sca-manifest.jar:target/sample-calculator-distributed.jar node.LaunchCalculatorNodeA + + +The processes started on each of these command prompts can be ended by pressing +the key. + + +Sample Overview +--------------- +The sample provides a single calculator service with a default SCA (java) +binding. NodeA exercises this interface by calling add, subtract, multiply and +divide operations. + +In the case of add and subtract the runtime recognises that +it can't find these services locally and, using the remote (web services) +version of the default SCA binding, contacts the add service running in NodeB +and the subtract service running in NodeC. + +On the command prompt where you started NodeA, you see the output of invoking the +calculator functions distributed over NodeB and and NodeC. On the command prompts +where you have started NodeB and NodeC, you see log messages that indicate that +the add and subtract services where called on these nodes respectively. + +The sample demonstrates that the calculator application can be distributed +across multiple nodes with no change to the application or to the SCA description +files. + +The domain node makes available a web application through which the contributions and +composites used in this sample can be navigated. One you have run "ant runDomain" you can +point you browser at: + +http://localhost:9990/ui/workspace/ + +The contents of the sample are as follows: + +calculator/ + src/ + main/ + java/ + calculator/ + CalculatorService.java - the first component, calls +-/* as + appropriate + AddService.java - adds two numbers + AddServiceImpl.java + SubtractService.java - subtracts one number from another + SubtractServiceImpl.java + MultiplyService.java - multiplies two numbers + MultiplyServiceImpl.java + DivideService.java - divides one number by another + DivideServiceImpl.java + node/ + LaunchCalculatorNodeA.java - runs an sca node configured with the + composite describing the main calculator + application. If you look inside this class + you will see that the node is configured + using a URL of the form: + + http://localhost:9990/node-config/NodeA + + This retrieves the information required + to configure NodeA from the domain. + + Once the node has been started this launcher + then finds the calculator service and + calls the various methods. + + LaunchCalculatorNodeB&C.java - These launchers start nodes B and C + which runs the add and subtract services. + + Unlike NodeA though these launchers just + wait once the node has been started. They + will service incomming web service requests + as they arrive. + + LaunchDomain.java - the node that provides the domain + configuration to the distributed + nodes + resources/ + cloud - The SCA composite files that describe + the configuration of each node + nodeA - the SCA assembly for nodeA's part of the + calculator application + nodeB - the SCA assembly for nodeB's part of the + calculator application + nodeC - the SCA assembly for nodeC's part of the + calculator application + test/ + java/ + calculator/ + CalculatorDistributedTestCase.java - JUnit test case which runs all + of the separate nodes along with the domain + in a single VM for test purposes + calculator-distributed.png - a pictorial representation of the sample + .composite files + build.xml - the Ant build file + pom.xml - the Maven build file + + +Building And Running The Sample Using Ant +----------------------------------------- +With the binary distribution the sample can be built and run using Ant as +follows + +cd calculator-distributed +ant compile +ant runDomain +ant runNodeB +ant runNodeC +ant runNodeA + +You should see the following output from the four separate command prompt: + +runDomain: +ted>ant runDomain +Buildfile: build.xml + +runDomain: + [java] 26-Mar-2008 12:55:12 org.apache.tuscany.sca.node.launcher.DomainMana +gerLauncher main + [java] INFO: Apache Tuscany SCA Domain Manager starting... + [java] 26-Mar-2008 12:55:13 org.apache.tuscany.sca.node.launcher.NodeLaunch +erUtil collectJARFiles + [java] INFO: Runtime classpath: 147 JARs from C:\simon\tuscany\sca-java-1.2 +\distribution\target\apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir\tuscany-sca- +1.2-incubating-SNAPSHOT\lib + [java] 26-Mar-2008 12:55:13 org.apache.tuscany.sca.node.launcher.NodeLaunch +erUtil collectJARFiles + [java] INFO: Runtime classpath: 89 JARs from C:\simon\tuscany\sca-java-1.2\ +distribution\target\apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir\tuscany-sca-1 +.2-incubating-SNAPSHOT\modules + [java] 26-Mar-2008 12:55:19 org.apache.catalina.core.StandardEngine start + [java] INFO: Starting Servlet Engine: Apache Tomcat/6.0.14 + [java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.ContextConfig defau +ltWebConfig + [java] INFO: No default web.xml + [java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.DigesterFactory reg +ister + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_0. +xsd + [java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.DigesterFactory reg +ister + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/jsp_2_1. +xsd + [java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.DigesterFactory reg +ister + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt +aglibrary_1_1.dtd + [java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.DigesterFactory reg +ister + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt +aglibrary_1_2.dtd + [java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.DigesterFactory reg +ister + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt +aglibrary_2_0.xsd + [java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.DigesterFactory reg +ister + [java] WARNING: Could not get url for /javax/servlet/jsp/resources/web-jspt +aglibrary_2_1.xsd + [java] 26-Mar-2008 12:55:20 org.apache.catalina.startup.DigesterFactory reg +ister + [java] WARNING: Could not get url for /javax/servlet/resources/j2ee_web_ser +vices_1_1.xsd + [java] 26-Mar-2008 12:55:20 org.apache.coyote.http11.Http11Protocol init + [java] INFO: Initializing Coyote HTTP/1.1 on http-9990 + [java] 26-Mar-2008 12:55:20 org.apache.coyote.http11.Http11Protocol start + [java] INFO: Starting Coyote HTTP/1.1 on http-9990 + [java] 26-Mar-2008 12:55:20 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/ui/home/* + [java] 26-Mar-2008 12:55:20 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/ui/workspace/* + [java] 26-Mar-2008 12:55:20 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/ui/files/* + [java] 26-Mar-2008 12:55:20 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/ui/composite/* + [java] 26-Mar-2008 12:55:20 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/ui/cloud/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/workspace/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/contribution/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/feed/files/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/files/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/composite/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/composite-source/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/deployable/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/composite-resolved/ +* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/cloud/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/cloud-source/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/composite-config/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/node-config/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/quickstart/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/processes/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/node/processes/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.http.tomcat.TomcatServer + addServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:9990/ping/* + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.node.launcher.DomainMana +gerLauncher main + [java] INFO: SCA Domain Manager started. + [java] 26-Mar-2008 12:55:21 org.apache.tuscany.sca.node.launcher.DomainMana +gerLauncher main + [java] INFO: Press enter to shutdown. + + +runNodeB: + [java] 26-Mar-2008 12:55:42 org.apache.tuscany.sca.node.launcher.NodeLaunch +er main + [java] INFO: Apache Tuscany SCA Node starting... + [java] 26-Mar-2008 12:55:42 org.apache.tuscany.sca.node.launcher.NodeLaunch +er main + [java] INFO: SCA Node configuration: http://localhost:9990/node-config/NodeB + + [java] 26-Mar-2008 12:55:42 org.apache.tuscany.sca.node.launcher.NodeLaunch +erUtil collectJARFiles + [java] INFO: Runtime classpath: 147 JARs from C:\simon\tuscany\sca-java-1.2 +\distribution\target\apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir\tuscany-sca- +1.2-incubating-SNAPSHOT\lib + [java] 26-Mar-2008 12:55:42 org.apache.tuscany.sca.node.launcher.NodeLaunch +erUtil collectJARFiles + [java] INFO: Runtime classpath: 89 JARs from C:\simon\tuscany\sca-java-1.2\ +distribution\target\apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir\tuscany-sca-1 +.2-incubating-SNAPSHOT\modules + [java] 26-Mar-2008 12:55:42 org.apache.tuscany.sca.node.impl.NodeImpl + [java] INFO: Creating node: http://localhost:9990/node-config/NodeB + [java] 26-Mar-2008 12:55:45 org.apache.tuscany.sca.node.impl.NodeImpl confi +gureNode + [java] INFO: Loading contribution: file:/C:/simon/tuscany/sca-java-1.2/dist +ribution/target/apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir/tuscany-sca-1.2-i +ncubating-SNAPSHOT/samples/calculator-distributed/./src/main/resources/nodeB/ + [java] 26-Mar-2008 12:55:46 org.apache.tuscany.sca.node.impl.NodeImpl confi +gureNode + [java] INFO: Loading composite: http://localhost:9990/composite-resolved/co +mposite:nodeB;http://sample;CalculatorB + [java] 26-Mar-2008 12:55:47 org.apache.tuscany.sca.node.impl.NodeImpl start + + [java] INFO: Starting node: http://localhost:9990/node-config/NodeB + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] 26-Mar-2008 12:55:53 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:8200/AddServiceComponent +B + [java] 26-Mar-2008 12:55:53 org.apache.tuscany.sca.node.launcher.NodeLaunch +er main + [java] INFO: SCA Node started. + [java] 26-Mar-2008 12:55:53 org.apache.tuscany.sca.node.launcher.NodeLaunch +er main + [java] INFO: Press enter to shutdown. + [java] AddService - add 3.0 and 2.0 + +runNodeC: + [java] 26-Mar-2008 12:56:01 org.apache.tuscany.sca.node.launcher.NodeLaunch +er main + [java] INFO: Apache Tuscany SCA Node starting... + [java] 26-Mar-2008 12:56:01 org.apache.tuscany.sca.node.launcher.NodeLaunch +er main + [java] INFO: SCA Node configuration: http://localhost:9990/node-config/NodeC + + [java] 26-Mar-2008 12:56:01 org.apache.tuscany.sca.node.launcher.NodeLaunch +erUtil collectJARFiles + [java] INFO: Runtime classpath: 147 JARs from C:\simon\tuscany\sca-java-1.2 +\distribution\target\apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir\tuscany-sca- +1.2-incubating-SNAPSHOT\lib + [java] 26-Mar-2008 12:56:01 org.apache.tuscany.sca.node.launcher.NodeLaunch +erUtil collectJARFiles + [java] INFO: Runtime classpath: 89 JARs from C:\simon\tuscany\sca-java-1.2\ +distribution\target\apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir\tuscany-sca-1 +.2-incubating-SNAPSHOT\modules + [java] 26-Mar-2008 12:56:01 org.apache.tuscany.sca.node.impl.NodeImpl + [java] INFO: Creating node: http://localhost:9990/node-config/NodeC + [java] 26-Mar-2008 12:56:03 org.apache.tuscany.sca.node.impl.NodeImpl confi +gureNode + [java] INFO: Loading contribution: file:/C:/simon/tuscany/sca-java-1.2/dist +ribution/target/apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir/tuscany-sca-1.2-i +ncubating-SNAPSHOT/samples/calculator-distributed/./src/main/resources/nodeC/ + [java] 26-Mar-2008 12:56:04 org.apache.tuscany.sca.node.impl.NodeImpl confi +gureNode + [java] INFO: Loading composite: http://localhost:9990/composite-resolved/co +mposite:nodeC;http://sample;CalculatorC + [java] 26-Mar-2008 12:56:04 org.apache.tuscany.sca.node.impl.NodeImpl start + + [java] INFO: Starting node: http://localhost:9990/node-config/NodeC + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] 26-Mar-2008 12:56:10 org.apache.tuscany.sca.http.jetty.JettyServer a +ddServletMapping + [java] INFO: Added Servlet mapping: http://L3AW203:8300/SubtractServiceComp +onentC + [java] 26-Mar-2008 12:56:10 org.apache.tuscany.sca.node.launcher.NodeLaunch +er main + [java] INFO: SCA Node started. + [java] 26-Mar-2008 12:56:10 org.apache.tuscany.sca.node.launcher.NodeLaunch +er main + [java] INFO: Press enter to shutdown. + [java] SubtractService - subtract 3.0 and 2.0 + +runNodeA: + [java] 26-Mar-2008 12:56:10 org.apache.tuscany.sca.node.impl.NodeImpl + [java] INFO: Creating node: http://localhost:9990/node-config/NodeA + [java] 26-Mar-2008 12:56:12 org.apache.tuscany.sca.node.impl.NodeImpl confi +gureNode + [java] INFO: Loading contribution: file:/C:/simon/tuscany/sca-java-1.2/dist +ribution/target/apache-tuscany-sca-1.2-incubating-SNAPSHOT.dir/tuscany-sca-1.2-i +ncubating-SNAPSHOT/samples/calculator-distributed/./src/main/resources/nodeA/ + [java] 26-Mar-2008 12:56:13 org.apache.tuscany.sca.node.impl.NodeImpl confi +gureNode + [java] INFO: Loading composite: http://localhost:9990/composite-resolved/co +mposite:nodeA;http://sample;CalculatorA + [java] 26-Mar-2008 12:56:14 org.apache.tuscany.sca.assembly.builder.impl.Co +mpositeBuilderImpl$1 problem + [java] WARNING: Component reference target not found, it might be a remote +service: SubtractServiceComponentC + [java] 26-Mar-2008 12:56:14 org.apache.tuscany.sca.assembly.builder.impl.Co +mpositeBuilderImpl$1 problem + [java] WARNING: Component reference target not found, it might be a remote +service: AddServiceComponentB + [java] 26-Mar-2008 12:56:14 org.apache.tuscany.sca.node.impl.NodeImpl start + + [java] INFO: Starting node: http://localhost:9990/node-config/NodeA + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] Warning: Running an XSLT 1.0 stylesheet with an XSLT 2.0 processor + [java] CalculatorService - add 3.0 and 2.0 + [java] 3 + 2=5.0 + [java] CalculatorService - subtract 3.0 and 2.0 + [java] 3 - 2=1.0 + [java] CalculatorService - multiply 3.0 and 2.0 + [java] 3 * 2=6.0 + [java] CalculatorService - divide 3.0 and 2.0 + [java] 3 / 2=1.5 + [java] 26-Mar-2008 12:56:20 org.apache.tuscany.sca.node.impl.NodeImpl stop + [java] INFO: Stopping node: http://localhost:9990/node-config/NodeA + +Building And Running The Sample Using Maven +------------------------------------------- +With either the binary or source distributions the sample can be built and run +using Maven as follows. When running from Maven the four nodes all run within +Java virtual machine. + +cd calculator-distributed +mvn + +You should see the following output at the end of the test phase. + +INFO: Starting node: http://localhost:9990/node-config/NodeA +CalculatorService - add 3.0 and 2.0 +AddService - add 3.0 and 2.0 +CalculatorService - subtract 3.0 and 2.0 +SubtractService - subtract 3.0 and 2.0 +CalculatorService - multiply 3.0 and 2.0 +CalculatorService - divide 3.0 and 2.0 +26-Mar-2008 13:00:52 org.apache.tuscany.sca.node.impl.NodeImpl stop +INFO: Stopping node: http://localhost:9990/node-config/NodeC +26-Mar-2008 13:00:52 org.apache.tuscany.sca.node.impl.NodeImpl stop +INFO: Stopping node: http://localhost:9990/node-config/NodeB +26-Mar-2008 13:00:52 org.apache.tuscany.sca.node.impl.NodeImpl stop +INFO: Stopping node: http://localhost:9990/node-config/NodeA +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0, Time elapsed: 13.328 sec + +Results : + +Tests run: 1, Failures: 0, Errors: 0, Skipped: 0 + +This shows that the Junit test cases have run successfully. + + + diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/build.xml b/branches/sca-java-1.3.3/samples/calculator-distributed/build.xml new file mode 100644 index 0000000000..f7a23e4b81 --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/build.xml @@ -0,0 +1,114 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/calculator-distributed.png b/branches/sca-java-1.3.3/samples/calculator-distributed/calculator-distributed.png new file mode 100644 index 0000000000..7c0e175664 Binary files /dev/null and b/branches/sca-java-1.3.3/samples/calculator-distributed/calculator-distributed.png differ diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/calculator-distributed.svg b/branches/sca-java-1.3.3/samples/calculator-distributed/calculator-distributed.svg new file mode 100644 index 0000000000..be5a4b8185 --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/calculator-distributed.svg @@ -0,0 +1,383 @@ + + + + + + + + + + image/svg+xml + + + + + + + + Calculator + + CalculatorServiceComponent + + + CalculatorService + AddServiceComponent + + SubtractServiceComponent + + MultiplyServiceComponent + + DivideServiceComponent + addService + subtractService + multiplyService + divideService + + + + + + + nodeB nodeC + nodeA + diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/cloud.composite b/branches/sca-java-1.3.3/samples/calculator-distributed/cloud.composite new file mode 100644 index 0000000000..85e2f9c7f3 --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/cloud.composite @@ -0,0 +1,26 @@ + + + + + + + diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/domain.composite b/branches/sca-java-1.3.3/samples/calculator-distributed/domain.composite new file mode 100644 index 0000000000..643e22d0cf --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/domain.composite @@ -0,0 +1,26 @@ + + + + + + + diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/pom.xml b/branches/sca-java-1.3.3/samples/calculator-distributed/pom.xml new file mode 100644 index 0000000000..de13d23e24 --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/pom.xml @@ -0,0 +1,119 @@ + + + + 4.0.0 + + org.apache.tuscany.sca + tuscany-sca + 1.3.2-SNAPSHOT + ../../pom.xml + + sample-calculator-distributed + Apache Tuscany SCA Distributed Calculator Sample + + + + apache.incubator + http://people.apache.org/repo/m2-incubating-repository + + + + + + + org.apache.tuscany.sca + tuscany-node2-api + 1.3.2-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-node2-launcher + 1.3.2-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-domain-manager + 1.3.2-SNAPSHOT + + + + org.apache.tuscany.sca + tuscany-implementation-node-runtime + 1.3.2-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-sca + 1.3.2-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-sca-axis2 + 1.3.2-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-binding-http-runtime + 1.3.2-SNAPSHOT + runtime + + + + org.apache.tuscany.sca + tuscany-implementation-resource-runtime + 1.3.2-SNAPSHOT + runtime + + + + org.codehaus.woodstox + wstx-asl + 3.2.1 + runtime + + + + org.apache.tuscany.sca + tuscany-host-tomcat + 1.3.2-SNAPSHOT + test + + + + junit + junit + 4.2 + test + + + + + + ${artifactId} + + diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/AddService.java b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/AddService.java new file mode 100644 index 0000000000..d7dc4473ad --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/AddService.java @@ -0,0 +1,31 @@ +/* + * 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 calculator; + +import org.osoa.sca.annotations.Remotable; + +/** + * The Add service interface + */ +@Remotable +public interface AddService { + + double add(double n1, double n2); + +} diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/AddServiceImpl.java b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/AddServiceImpl.java new file mode 100644 index 0000000000..e9b7e254e5 --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/AddServiceImpl.java @@ -0,0 +1,31 @@ +/* + * 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 calculator; + +/** + * An implementation of the Add service + */ +public class AddServiceImpl implements AddService { + + public double add(double n1, double n2) { + System.out.println("AddService - add " + n1 + " and " + n2); + return n1 + n2; + } + +} diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/CalculatorService.java b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/CalculatorService.java new file mode 100644 index 0000000000..031fa8b912 --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/CalculatorService.java @@ -0,0 +1,35 @@ +/* + * 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 calculator; + + +/** + * The Calculator service interface. + */ +public interface CalculatorService { + + double add(double n1, double n2); + + double subtract(double n1, double n2); + + double multiply(double n1, double n2); + + double divide(double n1, double n2); + +} diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/CalculatorServiceImpl.java b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/CalculatorServiceImpl.java new file mode 100644 index 0000000000..da869e00fd --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/CalculatorServiceImpl.java @@ -0,0 +1,74 @@ +/* + * 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 calculator; + +import org.osoa.sca.annotations.Reference; + + +/** + * An implementation of the Calculator service. + */ +public class CalculatorServiceImpl implements CalculatorService { + + private AddService addService; + private SubtractService subtractService; + private MultiplyService multiplyService; + private DivideService divideService; + + @Reference + public void setAddService(AddService addService) { + this.addService = addService; + } + + @Reference + public void setSubtractService(SubtractService subtractService) { + this.subtractService = subtractService; + } + + @Reference + public void setMultiplyService(MultiplyService multiplyService) { + this.multiplyService = multiplyService; + } + + @Reference + public void setDivideService(DivideService divideService) { + this.divideService = divideService; + } + + public double add(double n1, double n2) { + System.out.println("CalculatorService - add " + n1 + " and " + n2); + return addService.add(n1, n2); + } + + public double subtract(double n1, double n2) { + System.out.println("CalculatorService - subtract " + n1 + " and " + n2); + return subtractService.subtract(n1, n2); + } + + public double multiply(double n1, double n2) { + System.out.println("CalculatorService - multiply " + n1 + " and " + n2); + return multiplyService.multiply(n1, n2); + } + + public double divide(double n1, double n2) { + System.out.println("CalculatorService - divide " + n1 + " and " + n2); + return divideService.divide(n1, n2); + } + +} diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/DivideService.java b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/DivideService.java new file mode 100644 index 0000000000..30d248208b --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/DivideService.java @@ -0,0 +1,28 @@ +/* + * 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 calculator; + +/** + * The divide service interface + */ +public interface DivideService { + + double divide(double n1, double n2); + +} diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/DivideServiceImpl.java b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/DivideServiceImpl.java new file mode 100644 index 0000000000..f7ac0b7287 --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/DivideServiceImpl.java @@ -0,0 +1,30 @@ +/* + * 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 calculator; + +/** + * An implementation of the Divide service. + */ +public class DivideServiceImpl implements DivideService { + + public double divide(double n1, double n2) { + return n1 / n2; + } + +} diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/MultiplyService.java b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/MultiplyService.java new file mode 100644 index 0000000000..5290605938 --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/MultiplyService.java @@ -0,0 +1,28 @@ +/* + * 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 calculator; + +/** + * The interface for the multiply service + */ +public interface MultiplyService { + + double multiply(double n1, double n2); + +} diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/MultiplyServiceImpl.java b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/MultiplyServiceImpl.java new file mode 100644 index 0000000000..b7dca792b2 --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/MultiplyServiceImpl.java @@ -0,0 +1,30 @@ +/* + * 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 calculator; + +/** + * An implementation of the Multiply service. + */ +public class MultiplyServiceImpl implements MultiplyService { + + public double multiply(double n1, double n2) { + return n1 * n2; + } + +} diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/SubtractService.java b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/SubtractService.java new file mode 100644 index 0000000000..78ab9c6ee0 --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/SubtractService.java @@ -0,0 +1,31 @@ +/* + * 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 calculator; + +import org.osoa.sca.annotations.Remotable; + +/** + * The interface for the multiply service + */ +@Remotable +public interface SubtractService { + + double subtract(double n1, double n2); + +} diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/SubtractServiceImpl.java b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/SubtractServiceImpl.java new file mode 100644 index 0000000000..1010207154 --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/calculator/SubtractServiceImpl.java @@ -0,0 +1,31 @@ +/* + * 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 calculator; + +/** + * An implementation of the subtract service. + */ +public class SubtractServiceImpl implements SubtractService { + + public double subtract(double n1, double n2) { + System.out.println("SubtractService - subtract " + n1 + " and " + n2); + return n1 - n2; + } + +} diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeA.java b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeA.java new file mode 100644 index 0000000000..b61d1da85d --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeA.java @@ -0,0 +1,67 @@ +/* + * 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 node; + +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCANode2; +import org.apache.tuscany.sca.node.launcher.NodeLauncher; +import org.osoa.sca.ServiceRuntimeException; + +import calculator.CalculatorService; + +public class LaunchCalculatorNodeA { + public static void main(String[] args) throws Exception { + + SCANode2 node = null; + try { + + NodeLauncher nodeLauncher = NodeLauncher.newInstance(); + node = nodeLauncher.createNode("http://localhost:9990/node-config/NodeA"); + + node.start(); + + // get a reference to the calculator component + SCAClient client = (SCAClient)node; + CalculatorService calculatorService = + client.getService(CalculatorService.class, "CalculatorServiceComponentA"); + + // 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)); + + if (args.length > 1){ + for (int i=0; i < 1000; i++){ + // 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)); + } + } + + node.stop(); + + } catch (Exception e) { + throw new ServiceRuntimeException(e); + } + } +} diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeB.java b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeB.java new file mode 100644 index 0000000000..50600eaedc --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeB.java @@ -0,0 +1,28 @@ +/* + * 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 node; + +import org.apache.tuscany.sca.node.launcher.NodeLauncher; + +public class LaunchCalculatorNodeB { + public static void main(String[] args) throws Exception { + NodeLauncher.main(new String[] {"http://localhost:9990/node-config/NodeB"}); + } +} diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeC.java b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeC.java new file mode 100644 index 0000000000..95d8934665 --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/node/LaunchCalculatorNodeC.java @@ -0,0 +1,28 @@ +/* + * 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 node; + +import org.apache.tuscany.sca.node.launcher.NodeLauncher; + +public class LaunchCalculatorNodeC { + public static void main(String[] args) throws Exception { + NodeLauncher.main(new String[] {"http://localhost:9990/node-config/NodeC"}); + } +} diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/node/LaunchDomain.java b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/node/LaunchDomain.java new file mode 100644 index 0000000000..8b4fe566a1 --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/java/node/LaunchDomain.java @@ -0,0 +1,33 @@ +/* + * 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 node; + +import org.apache.tuscany.sca.node.launcher.DomainManagerLauncher; + +/** + * This server program that loads a composite to provide simple registry function. + * This server can be replaced with any registry that is appropriate but the components + * in each node that talk to the registry should be replaced also. + */ +public class LaunchDomain { + public static void main(String[] args) throws Exception { + DomainManagerLauncher.main(args); + } + +} diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/cloud/NodeA.composite b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/cloud/NodeA.composite new file mode 100644 index 0000000000..ed7fe55abc --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/cloud/NodeA.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/cloud/NodeB.composite b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/cloud/NodeB.composite new file mode 100644 index 0000000000..8f29cc17aa --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/cloud/NodeB.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/cloud/NodeC.composite b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/cloud/NodeC.composite new file mode 100644 index 0000000000..9ad132b0d4 --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/cloud/NodeC.composite @@ -0,0 +1,33 @@ + + + + + + + + + + + + diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeA/Calculator.composite b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeA/Calculator.composite new file mode 100644 index 0000000000..172676a3c7 --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeA/Calculator.composite @@ -0,0 +1,41 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeA/META-INF/sca-contribution.xml b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeA/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..1b1c0291e2 --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeA/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeB/Calculator.composite b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeB/Calculator.composite new file mode 100644 index 0000000000..b770dbe8d4 --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeB/Calculator.composite @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeB/META-INF/sca-contribution.xml b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeB/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..6c0ffe4ac0 --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeB/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeC/Calculator.composite b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeC/Calculator.composite new file mode 100644 index 0000000000..66caf0d17b --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeC/Calculator.composite @@ -0,0 +1,29 @@ + + + + + + + + + diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeC/META-INF/sca-contribution.xml b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeC/META-INF/sca-contribution.xml new file mode 100644 index 0000000000..8c311553c3 --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/main/resources/nodeC/META-INF/sca-contribution.xml @@ -0,0 +1,24 @@ + + + + + \ No newline at end of file diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/src/test/java/calculator/CalculatorDistributedTestCase.java b/branches/sca-java-1.3.3/samples/calculator-distributed/src/test/java/calculator/CalculatorDistributedTestCase.java new file mode 100644 index 0000000000..9c3f06ee53 --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/src/test/java/calculator/CalculatorDistributedTestCase.java @@ -0,0 +1,92 @@ +/* + * 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 calculator; + + +import junit.framework.Assert; + +import org.apache.tuscany.sca.node.SCAClient; +import org.apache.tuscany.sca.node.SCANode2; +import org.apache.tuscany.sca.node.SCANode2Factory; +import org.apache.tuscany.sca.node.launcher.DomainManagerLauncher; +import org.junit.AfterClass; +import org.junit.BeforeClass; +import org.junit.Test; + +/** + * Runs a distributed domain in a single VM by using and in memory + * implementation of the distributed domain + */ +public class CalculatorDistributedTestCase { + + private static SCANode2 manager; + private static SCANode2 nodeA; + private static SCANode2 nodeB; + private static SCANode2 nodeC; + + private static CalculatorService calculatorService; + + + @BeforeClass + public static void init() throws Exception { + + try { + System.out.println("Setting up domain"); + + DomainManagerLauncher managerLauncher = DomainManagerLauncher.newInstance(); + manager = managerLauncher.createDomainManager(); + manager.start(); + + SCANode2Factory nodeFactory = SCANode2Factory.newInstance(); + nodeC = nodeFactory.createSCANodeFromURL("http://localhost:9990/node-config/NodeC"); + nodeB = nodeFactory.createSCANodeFromURL("http://localhost:9990/node-config/NodeB"); + nodeA = nodeFactory.createSCANodeFromURL("http://localhost:9990/node-config/NodeA"); + + nodeC.start(); + nodeB.start(); + nodeA.start(); + + SCAClient client = (SCAClient)nodeA; + calculatorService = + client.getService(CalculatorService.class, "CalculatorServiceComponentA"); + + } catch(Exception ex){ + System.err.println(ex.toString()); + } + + } + + @AfterClass + public static void destroy() throws Exception { + nodeC.stop(); + nodeB.stop(); + nodeA.stop(); + manager.stop(); + } + + @Test + public void testCalculator() throws Exception { + + // Calculate + Assert.assertEquals(calculatorService.add(3, 2), 5.0); + Assert.assertEquals(calculatorService.subtract(3, 2), 1.0); + Assert.assertEquals(calculatorService.multiply(3, 2), 6.0); + Assert.assertEquals(calculatorService.divide(3, 2), 1.5); + } +} diff --git a/branches/sca-java-1.3.3/samples/calculator-distributed/workspace.xml b/branches/sca-java-1.3.3/samples/calculator-distributed/workspace.xml new file mode 100644 index 0000000000..7d6d3dbdbd --- /dev/null +++ b/branches/sca-java-1.3.3/samples/calculator-distributed/workspace.xml @@ -0,0 +1,25 @@ + + + + + + + + -- cgit v1.2.3