The Tuscany calculator sample shows using the Tuscany SCA
runtime in a J2SE environment loading several components.
Each component provides a basic operation (add, subtract, etc).
The
main component uses each of these to perrform a simple calculation.
Linux: java -cp ../../../lib/tuscany-runtime-incubating-M1.jar:target/sample-calculator-incubating-M1.jar calculator.CalculatorClient
Windows: java -cp ../../../lib/tuscany-runtime-incubating-M1.jar;target/sample-calculator-incubating-M1.jar calculator.CalculatorClient
The sample when run should simply display to the standard
output:
Hello World
src +---main +---java ¦ +---calculator ¦ AddService.java ¦ AddServiceImpl.java ¦ CalculatorClient.java ¦ CalculatorService.java ¦ CalculatorServiceImpl.java ¦ DivideService.java ¦ DivideServiceImpl.java ¦ MultiplyService.java ¦ MultiplyServiceImpl.java ¦ SubtractService.java ¦ SubtractServiceImpl.java ¦ +---resources logging.properties sca.module |
sca.module | Defines the SCA module and component. Defines for the CalculatorServiceComponent component the Java class that implements that component. Wires each of the operation components to the CalculatorServiceComponent |
CalculatorService.java | Defines the Java interface implemented by the cacomponent. |
CalculatorServiceImpl.java | Implements the SCA component. Uses the SCA service annotation tag on the class to show what SCA interface is being implemented. |
CalculatorClient.java | Creates a Tuscany runtime and starts it. Obtains the module context which was defined by the sca.module file. From the module context locates the CalculatorServiceComponent and then calls operations on that component to demonstrating it using the multiple components implementing the operations.. |