Tuscany Hello World Sample

Overview

The Tuscany helloworld sample shows using the Tuscany SCA runtime in a J2SE environment  loading a component that implements the classic introductory hello world example.

Location

This sample is located  in the samples\sca\helloworld directory.

Setup

This sample depends on the Tuscany runtime and the sample jar, sample-helloworld-incubating-M1.jar , both of these must be available on the classpath to run the sample.

Running

In the directory samples/sca/helloworld use the JDK 1.5 java command to run the class helloworld.HelloWorldClient
Linux: java -cp ../../../lib/tuscany-runtime-incubating-M1.jar:target/sample-helloworld-incubating-M1.jar helloworld.HelloWorldClient
Windows: java -cp ../../../lib/tuscany-runtime-incubating-M1.jar;target/sample-helloworld-incubating-M1.jar helloworld.HelloWorldClient

Results

The sample when run should simply display to the standard output:
Hello World

Code Overview

The source files are physically organized as shown below:
src
+---main
    +---java
    ¦   +---helloworld
    ¦           HelloWorldClient.java
    ¦           HelloWorldImpl.java
    ¦           HelloWorldService.java
    ¦
    +---resources
            sca.module

sca.module Defines the SCA module and component. Defines for the HelloWorldServiceComponent component  the Java class that implements that component
HelloWorldService.java Defines the Java interface implemented by the component.
HelloWorldImpl.java Implements the SCA component. Uses the SCA service annotation tag on the class to show what SCA interface is being implemented.
HelloWorldClient.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 HelloWorldServiceComponent and then calls  the getGreetings method to invoke the component.