This web sample demonstrates DAS advanced features in the context of a simple web application using Ajax.
The
application user can navigate the menu to see examples of different DAS
features.
The application uses “dbConfig” utility to create canned
►Adhoc Query (CRUD
operations on COMPANY and DEPARTMENT using adhoc Sql statements)
►DAS Command (CRUD
operations on COMPANY and DEPARTMENT using DAS config commands)
►Advanced Features –
►Optimistic Concurrency
Control (Using
BOOK. NAME)
►Converter (Using
CUSTOMER.LASTNAME)
►Result Set Shape (Using
CUSTOMER table)
In future
more features will get added.
Running
the sample
There are two options for running this sample:
Running from Tomcat configured by
the build
You need to
download the Tuscany RDB DAS source distribution and run maven build to use
this option. When you build using maven from the source root {SRC_ROOT}
directory, the sample war file is created under {SRC_ROOT}/samples/sample-
Deploying the sample-ajax-das WAR into a Tomcat you configured
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 binary distribution or 2) Downloaded the
Tuscany source and run maven build, see the following link to more details
steps on how to build DAS Sample applications http://incubator.apache.org/tuscany/das-java-developer-guide.html
.
Set Up
<!-- Global Datasource for
<Resource name="jdbc/ajaxdastest"
type="javax.sql.DataSource"
auth="Container"
description="
maxActive="100"
maxIdle="30" maxWait="10000"
username=""
password=""
driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
url="jdbc:derby:{absolute
path}Databases/ajaxdastest;create=true"/>
Requirement: You must include
the absolute path to the “Databases” directory in the above url attribute. Fore example:
url="jdbc:derby:c:\apache-tomcat-6.0.13\Databases/ajaxdastest;create=true
"/>
Sample
Architecture
The design
is modular and reusable by other web samples. There are java servlet, other
java classes, jsp, javascript, xml, xsl, css and html files.
Client Side Files
Javascripts
Ajax.js and
dasmenu.js are generic (not DAS specific) and reusable by any web sample.
Set
response handler when request is passed to servlet. Response handler’s job is transform xml response using xsl into
html or plain text based on the example’s requirement.
Used for
menu/submenu rendering, is quite generic and can be used to display any menu.
HTMLs
& jsps (DAS specific files)
DASMenu.html
and DASWebSampleFrame.html are for giving frame and menu to web sample.
DASMenu.html calls required .jsps like indexAdhoc.jsp, indexCommand.jsp, occ.jsp,
converter.jsp. These jsps are all DAS specific. The .jsp file is responsible
for deciding the DAS config file required by current sample and relevant .xsl
file.
Serverside files
CommandServlet.java
and ServiceProcessor.java
Used for
invoking required service and returning results back to ajax.js. These files
are not DAS specific.
DASQueryProcessor.java
Specific to
DAS sample, has logic to invoke required sample example.