1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
|
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<!--
Licensed to the Apache Software Foundation (ASF) under one
or more contributor license agreements. See the NOTICE file
distributed with this work for additional information
regarding copyright ownership. The ASF licenses this file
to you under the Apache License, Version 2.0 (the
"License"); you may not use this file except in compliance
with the License. You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing,
software distributed under the License is distributed on an
"AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
KIND, either express or implied. See the License for the
specific language governing permissions and limitations
under the License.
-->
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Tuscany DAS Sample - Advanced webapp</title>
<style>
.code {font-size: 11px; color: #006699}
.codebox {border: 1px solid #6699CC; background-color: #F1F7FA;padding:15px}
.codebox2 {border: 1px solid #6699CC; background-color: #F1F7FA;padding:15px; width:85%}
.codeboxW {border: 1px solid #6699CC; background-color: #FFFFFF;padding:15px}
.codeboxB {background-color: #C9DBED;padding:1px 10px 10px 10px}
</style>
</head>
<body>
<h1><center>Advanced DAS web application Sample</center></h1>
<br>
<p>
This web sample demonstrates DAS advanced features in the context of a simple web application using Ajax.<br>
The application user can navigate the menu to see examples of different DAS features.<br>
The application uses "dbConfig" utility to create canned Derby database with required tables and populate initial data in them. For refreshing database data to initial state, user can click on Refresh Button.<br>
</p>
<ul>
<li><b>Adhoc Query</b> (CRUD operations on COMPANY and DEPARTMENT using adhoc Sql statements)</li>
<li><b>DAS Command</b> (CRUD operations on COMPANY and DEPARTMENT using DAS config commands)</li>
<li><b>Advanced features:</b>
<ul>
<li><b>Optimistic Concurrency Control</b> (Using BOOK. NAME)</li>
<li><b>Converter</b>(Using CUSTOMER.LASTNAME)</li>
<li><b>Result Set Shape</b>(Using CUSTOMER table)</li>
</ul>
</li>
</ul>
<p>
In future more features will get added.
</p>
<h2>Running the sample</h2>
<p>
There are two options for running this sample:
<ul>
<li>Run from Tomcat configured by the build</li>
<li>Deploying the sample-advanced-webapp WAR into a Tomcat you configure yourself</li>
</ul>
<h2>Running from Tomcat configured by the build</h2>
<p>
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-ajax-das/target. This sample application is deployed to an instance of Tomcat as part of our automated sample testing. For this, follow instructions from reademe.htm from {SRC_ROOT}/samples/testing/tomcat. This will in-effect run the htmlunit tests on the sample. The sample deployed on Tomcat instance will be ready this way and you can just point your browser to <a href="http://localhost:8080/sample-advanced-webapp/">http://localhost:8080/sample-advanced-webapp/</a> to test further.
</p>
<h2>Deploying the sample-ajax-das WAR into a Tomcat you configure yourself</h2>
<p>
Alternatively, you can deploy the sample to your own configured Tomcat installation by following the instructions below. <br>
These instructions assume that you have either :
<ul>
<li>1) Downloaded the Tuscany binary distribution or </li>
<li>2) Downloaded the Tuscany source and run maven build </li>
</ul>
see the following link to more details steps on how to build DAS Sample applications <a href="http://incubator.apache.org/tuscany/das-java-developer-guide.html">http://incubator.apache.org/tuscany/das-java-developer-guide.html</a> .
</p>
<h3>Set Up - Derby</h3>
<ul>
<li>Download and install the most recent stable version of Tomcat 5.5 or Tomcat 6. You can find it here: http://tomcat.apache.org/download-60.cgi</li>
<li>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(version).jar</li>
<li>Stop Tomcat</li>
<li>Copy derby(version).jar (from the derby distribution) to {Tomcat_Home}/common/lib (for Tomcat 5.5) or to {Tomcat_Home}/lib (for Tomcat 6) - e.g. derby-10.2.2.0.jar.</li>
<li>Add the sample war file to {Tomcat_Home}/webapps
<ul>
<li>sample-advanced-webapp.war</li>
</ul>
</li>
<li>Define a DataSource by adding a datasource definition to {Tomcat_Home}/conf/server.xml.
<ul>
<li>Find the end-of-section marker </GlobalNamingResources> and add the following lines just above it:</li>
</ul>
<pre STYLE="{font-style:italic}">
<!-- Global Datasource for Derby ajaxdastest database -->
<Resource name="jdbc/ajaxdastest"
type="javax.sql.DataSource" auth="Container"
description="Derby database for DAS Advanced sample"
maxActive="100" maxIdle="30" maxWait="10000"
username="" password=""
driverClassName="org.apache.derby.jdbc.EmbeddedDriver"
url="jdbc:derby:{absolute path}Databases/ajaxdastest;create=true"/>
</pre>
<b>Requirement:</b> You must include the absolute path to the <i>Databases</i> directory in the above url attribute. <br/>
Fore example: url="jdbc:derby:c:\apache-tomcat-6.0.13\Databases/ajaxdastest;create=true "
<p/>
</li>
<li>Start tomcat and point your browser to: <a href="http://localhost:8080/sample-advanced-webapp/">http://localhost:8080/sample-advanced-webapp/</a></li>
</ul>
<h3>Set Up - MySQL</h3>
<ul>
<li>Download and install the most recent stable version of Tomcat 5.5 or Tomcat 6. You can find it here: http://tomcat.apache.org/download-60.cgi</li>
<li>Download the most recent official release of MySQL. The only file you'll need from this download is mysql(version).jar (e.g. mysql-connector-java-5.0.4.jar) </li>
<li>Stop Tomcat</li>
<li>Copy mysql(version).jar (from the MySQL distribution) to {Tomcat_Home}/common/lib (for Tomcat 5.5) or to {Tomcat_Home}/lib (for Tomcat 6) - e.g. mysql-connector-java-5.0.4.jar.</li>
<li>Add the sample war file to {Tomcat_Home}/webapps
<ul>
<li>sample-advanced-webapp.war</li>
</ul>
</li>
<li>Define a DataSource by adding a datasource definition to {Tomcat_Home}/conf/server.xml.
<ul>
<li>Find the end-of-section marker </GlobalNamingResources> and add the following lines just above it:</li>
</ul>
<pre STYLE="{font-style:italic}">
<!-- Global Datasource for MySQL ajaxdastest database -->
<Resource name="jdbc/ajaxdastest"
type="javax.sql.DataSource" auth="Container"
description="MySQL database for DAS Advanced sample"
maxActive="100" maxIdle="30" maxWait="10000"
username="dastest" password="dastest"
driverClassName="com.mysql.jdbc.Driver"
url="jdbc:mysql://localhost/ajaxdastest?createDatabaseIfNotExist=true"/>
</pre>
<b>Requirement:</b> MySQL service should be up with configured port open for TCPIP communication.
<br>
<br>
As the new utility, dbConfig is embedded in this sample war, the MySQL database "dastest" will get created with
required tables and data when the web application gets loaded for the first time in tomcat. Please note that,
in the binary distribution, WEB-INF/classes/CompanyWebDBConfig.xml has SQL Table creation syntax for Derby.
To make it compatible to MySQL, simply replace GENERATED ALWAYS AS IDENTITY with AUTO_INCREMENT for all
table creation statements. (For this unjar the .war, change CompanyWebDBConfig.xml and jar the .war
back with changed CompanyWebDBConfig.xml)
<br>
<br>
</li>
<li>Start tomcat and point your browser to: <a href="http://localhost:8080/sample-advanced-webapp/">http://localhost:8080/sample-advanced-webapp/</a></li>
</ul>
<h2>Sample Architecture</h2>
<p>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.</p>
<h3><u>Client Side Files</u></h3>
<h4><u>Javascripts</u></h4>
<p></p>
<ul>
<li><b>Ajax.js:</b> <br>
Ajax.js and dasmenu.js are generic (not DAS specific) and reusable by any web sample.</li>
<li><b>Dasmenu.js:</b> <br>
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.</li>
</ul>
<p>Used for menu/submenu rendering, is quite generic and can be used to display any menu.</p>
<h4><u>HTMLs & jsps (DAS specific files)</u></h4>
<ul>
<li><b>DASMenu.html</b> and <b>DASWebSampleFrame.html</b> 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.</li>
</ul>
<h4><u>Serverside files</u></h4>
<ul>
<li><b>CommandServlet.java</b> and <b>ServiceProcessor.java</b> <br>
Used for invoking required service and returning results back to ajax.js. These files are not DAS specific.</li>
<li><b>DASQueryProcessor.java</b> <br>
Specific to DAS sample, has logic to invoke required sample example.</li>
</ul>
|