Tuscany Hello World Sample - JavaScript

Overview

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

Setup

The jars for a J2SE setup  not requiring web services are required including the sample's own jar helloworldjs-SNAPSHOT.jar.

Running

Using JDK 1.5 java command with the previous jars run the class org.apache.tuscany.samples.helloworldjs.HelloWorldClient

Results

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

Code Overview

The source files are physically organized as shown below:
sca.module
org
+-apache
+-tuscany
+-samples
+-helloworldjs
HelloWorldClient.java
HelloWorldService.java
HelloWorldServiceComponentImpl.js
HelloWorldServiceComponentImpl.componentType


 

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.
HelloWorldServiceComponentImpl.js JavaScript implementation of the SCA component.
HelloWorldServiceComponentImpl.componentType The SCA componentType side file defining the service interface implemented by the JavaScript component.
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.