Tuscany CustomerInfo Sample

Overview

The CustomerInfo sample shows a component exposing a WSDL portType interface and a J2SE client using the dynamic SDO API to use the component.

Location

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

Setup

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

Running

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

Results

The sample when run should simply display to the standard output:
customerID = 12345
firstName = Jane
lastName = Doe

Code Overview

The source files are physically organized as shown below:
src
+---main
    +---java
    ¦   +---customerinfo
    ¦           CustomerInfoClient.java
    ¦           CustomerInfoServiceImpl.java
    ¦
    +---resources
            sca.module
    +---wsdl
            customer.xsd
            customerinfo.wsdl

sca.module Defines the SCA module and component. Defines for the CustomerInfoServiceComponent component with the Java class that implements that component
CustomerInfoServiceImpl.java Implements the SCA component. Uses an @SDOHelper anotation to have the SDO DataFactory automatically injected into the dataFacory field, and uses the DataFactory to create a cutomer DataObject which it initialises and returns to the caller.
CustomerInfoClient .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 CustomerInfoServiceComponent, and then calls  the getCustomerInfo method to invoke the component. It uses the SDO dynamic APIs to extract the information from the returned DataObject.