Tuscany RDB DAS Service client

Introduction

This stand-alone sample application demonstrate how to consume the DAS Service exposed trough an SCA service.
The application starts with a canned database of Companies and their related Departments.
Through the web page interface, a user can consume the DAS Service to display the list of available companies.
The sample runs on Tomcat 5.5 and employs a Derby database accessed via a DataSource.

Running the sample

There are two options for running this sample:

  1. Run from Tomcat configured by the build
  2. Deploying the DASService.client WAR into a Tomcat you configure yourself

Running from Tomcat configured by the build

This sample application is deployed (along with the canned test database) to an instance of Tomcat as part of our automated sample testing.This means you can run the java/samples/testing/tomcat build (see java/das/samples/testing/tomcat/readme.htm ) and then access the application by pointing your browser to http://localhost:8080/companyweb-service-client/

Deploying the DASService.client WAR into a Tomcat you configure yourself

Alternatively, you can deploy the sample to your own configured Tomcat installation by following the instructions below. These instructions assume that you have either 1) downloaded the Tuscany sample distribution or 2) Downloaded the Tuscany source and run our maven build, see the following link to more details steps on how to build DAS Sample applications http://incubator.apache.org/tuscany/java_das_overview.html.

Set Up:

  1. Download and install the most recent stable version of Tomcat 5.5. You can find it here: http://tomcat.apache.org/download-55.cgi
  2. Download the most recent official release of Derby from here: http://db.apache.org/derby/index.html. The only file you’ll need from this download is derby.jar
  3. Stop Tomcat
  4. Copy derby.jar (from the derby distribution) to {Tomcat_Home}/common/lib:
  5. Add the sample war file to {Tomcat_Home}/webapps
    1. sample-das-service-client-xxx.war (e.g.sample-das-service-client-1.0-incubator-SNAPSHOT.war)
  6. Install the canned Derby database to Tomcat:
    1. First, create a new directory named “Databases” to hold the sample database. Create {Tomcat_Home}/Databases
    2. Copy the dastest folder (and all its contents) from {build directory root OR where samples where unzipped}/java/das/samples/DASService.client to {Tomcat_Home}/Databases.

      NOTE: If you are running this from a sample distribution, the canned database is available in the distribution, inside the databases directory.
  7. Define a DataSource by adding a datasource definition to {Tomcat_Home}/conf/server.xml.
    1. Find the end-of-section marker </GlobalNamingResources> and add the following lines just above it:

               <!-- Global Datasource for Derby dastest database -->
               <Resource name="jdbc/dastest"
                    type="javax.sql.DataSource"  auth="Container"
                    description="Derby database for DAS Company sample"
                    maxActive="100" maxIdle="30" maxWait="10000"
                    username="" password=""
                    driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
                    url="jdbc:derby:{absolute path}Databases/dastest"/>
            

      Requirement:You must include the absolute path to the “Databases” directory in the above url attribute. Fore example:

      	url="jdbc:derby:c:\apache-tomcat-5.5.17\Databases/dastest"

  8. Start tomcat and point your browser to: http://localhost:8080/sample-das-service-client-{version tag}/. Example:

    	http://localhost:8080/sample-das-service-client-1.0-incubator-SNAPSHOT/

Sample Architecture

This is a simple, single-page, web application to consume DAS exposed as an SCA service.

The main components of this application are:

The Company.jsp directly invoke the DAS Service to get a list of companies available and then iterate trough the SDO data graphs and manipulate SDO directly to display data

The canned Derby database comes preloaded with Companies and related Departments. The Derby database instance is a simple file folder.

The SCA DAS Service accepts directives (commands) and reads and writes to the derby database instance appropriately using DAS as the service implementation.

Consuming the DAS service

First, note that the application have dependencies on the DAS Service:

<!-- DAS Service -->
<dependency>
   <groupId>org.apache.tuscany.das.samples</groupId>
   <artifactId>sample-das-service</artifactId>
   <version>${pom.version}</version>
</dependency>


And the SCDL references the service:

<composite xmlns="http://www.osoa.org/xmlns/sca/1.0" name="DASServiceComposite">
  <component name="DASServiceComponent">
     <implementation.composite name="DASServiceComposite" jarLocation="lib/sample-das-service-1.0-incubator-SNAPSHOT.jar"/>
  </component>
</composite>