Tuscany Hello World Multi-Component Sample

Overview

The Tuscany hello world multi-component sample shows using the Tuscany SCA runtime in a J2SE environment  loading a component that implements the classic introductory hello world example. This sample shows the wiring of  multiple components in a single SCA module.

Setup

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

Running

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

Results

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

Code Overview

The source files are physically organized as shown below:
main
+---java
¦ sca.module
¦
+---org
+---apache
+---tuscany
+---samples
+---helloworldmc
GreetingPortionProvider.java
GreetingPortionProviderImpl.java
HelloWorldService.java
HelloWorldServiceComponentImpl.java


 

sca.module Defines the SCA module and  the HelloWorldServiceComponentGreetingPrefixComponent and GreetingSuffixComponent components  Wires the HelloWorldServiceComponent to reference the GreetingPrefixComponent and GreetingSuffixComponent.  Customizes the GreetingPrefixComponent and GreetingSuffixComponent components with the greetings.     
GreetingPortionProvider.java Defines the Java interface implemented by the component. GreetingPrefixComponent and GreetingSuffixComponent
GreetingPortionProviderImpl.java Implements the SCA components GreetingPrefixComponent and GreetingSuffixComponent . Uses the SCA service annotation tag on the class to show what SCA interface is being implemented. Uses the SCA defined Property Java annotation on the greetingPortion Java field to customize the component in the sca.module file.
HelloWorldService.java Defines the Java interface implemented by the component. HelloWorldServiceComponent
HelloWorldServiceComponentImpl.java 
Implements the HelloWorldServiceComponent component. Shows two Java fields being used to reference the and GreetingPrefixComponentGreetingSuffixComponent components.