Tuscany Customer Sample

Overview

This sample employs the Tuscany runtime in collaboration with the RDB DAS to demonstrate a simple read of a customer record from a relational database in the context of a web application. The user provides a customer ID and the application responds with the corresponding customer record

Setup

Run the Maven 'acceptance' task as described in the Tomcat Setup.  Running this task will configure and start a Tomcat server and deploy the sample application along with a canned Derby database for use by the example. Instructions will be posted soon for manually deploying the sample to an existing Tomcat install.

Running

As mentioned above, running the Maven acceptance task deploys and runs the sample as part of the Tuscany acceptance testing. After the task has completed you can manually run the sample by pointing a browser to: http://localhost:8080/tuscany-samples-customerWEB/. A page is displayed that prompts the user for a customer id. Submit an integer from 1 to 3.

Results

Submitting an integer from 1 to 3 will result in the display of the corresponding employee record

Code Overview

The following illustrates the structure of the sample application components:
main
+---java
¦   ¦   sca.module
¦   ¦
¦   +---org
¦       +---apache
¦           +---tuscany
¦              +---samples
¦                   +---customers
¦                           CustomerClient.java
¦                           CustomerServiceComponent.java
¦                           CustomerServiceComponentImpl.java
¦
+---webapp
    ¦   Customer.jsp
    ¦
    +---customerdb
    ¦         ¦   
    ¦
    +---WEB-INF
             web.xml



sca.module Defines the SCA module and component. Defines for the CustomerServiceComponent.
CustomerClient.java Wraps the get customer service to provide a clean "getCustomer()" API.
CustomerServiceComponent.java Defines the interface of the service.
Customer.jsp Handles Web form input. Instantiates a CustomerClient instance and calls getCustomer()
customerdb The canned Derby database with Customer records
web.xml Standard J2EE web application web.xml