summaryrefslogtreecommitdiffstats
path: root/site/trunk/site-publish/web-sample.html
blob: b9f96d098f8b8ed1553c4c8585631c447ce18a30 (plain)
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
<!--

    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.
-->


<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<HTML>
    <HEAD>
		<!-- generateKeywords macro -->
	    <META name="description" content="Apache Tuscany">
        <META name="keywords" content="apache, apache tuscany, tuscany, service, services, fabric, soa, service oriented architecture,  sca, service component architecture, das, sdo, csa, ruby, opensource">
		<!-- generateKeywords macro end -->
		
        <LINK type="text/css" rel="stylesheet" href="http://tuscany.apache.org/stylesheets/default.css">
        <LINK rel="SHORTCUT ICON" href="https://cwiki.apache.org/confluence/display/TUSCANY/$images/favicon.ico">   
        <TITLE>Apache Tuscany : Web Sample</TITLE>
    <META http-equiv="Content-Type" content="text/html;charset=UTF-8"></HEAD>
    
    <BODY onload="init()">
        <!-- topNav macro -->
		<TABLE valign="top" border="0" cellspacing="0" cellpadding="0" width="100%" background="http://tuscany.apache.org/images/TuscanyLogoNEW_Text_120px_bg.jpg">
			<TR>
				<TD valing="top" align="left">
					<A href="https://cwiki.apache.org/confluence/pages/viewpage.action?spaceKey=TUSCANY&title=$siteroot"><IMG src="http://tuscany.apache.org/images/TuscanyLogoNEW_Text_120px_bg.jpg" height="91" width="25" border="0"></A>
				</TD>
				<TD>
					<A href="http://tuscany.apache.org/"><IMG src="http://tuscany.apache.org/images/TuscanyLogo.jpg" border="0"></A>
				</TD>
				
				<TD width="100%">
					&nbsp;
				</TD>

				<!-- Adds the edit page link to the top banner-->
				<TD valign="bottom">
					<DIV style="padding: 2px 10px; margin: 0px;">
						<A href="https://cwiki.apache.org/confluence/pages/editpage.action?pageId=53946">
						<IMG src="http://tuscany.apache.org/images/notep_16.gif" height="16" width="16" border="0" align="absmiddle" title="Edit Page"></A>
					</DIV>
				</TD>

			</TR>
		</TABLE>
        <!-- topNav macro end -->

		<!-- breadCrumbs macro -->
		<TABLE border="0" cellpadding="2" cellspacing="0" width="100%">
			<TR class="topBar">
				<TD align="left" valign="middle" class="topBarDiv" nowrap="true" width="100%">
					&nbsp;<A href="home.html" title="Apache Tuscany">Apache Tuscany</A>&nbsp;&gt;&nbsp;<A href="home.html" title="Home">Home</A>&nbsp;&gt;&nbsp;<A href="das-overview.html" title="DAS Overview">DAS Overview</A>&nbsp;&gt;&nbsp;<A href="das-java.html" title="DAS Java">DAS Java</A>&nbsp;&gt;&nbsp;<A href="das-java-documentation-menu.html" title="DAS Java Documentation Menu">DAS Java Documentation Menu</A>&nbsp;&gt;&nbsp;<A href="das-java-developer-guide.html" title="DAS Java Developer Guide">DAS Java Developer Guide</A>&nbsp;&gt;&nbsp;<A href="rdb-das-java.html" title="RDB DAS Java">RDB DAS Java</A>&nbsp;&gt;&nbsp;<A href="rdb-das-user-guide.html" title="RDB DAS - User Guide">RDB DAS - User Guide</A>&nbsp;&gt;&nbsp;<A href="" title="Web Sample">Web Sample</A>
				</TD>
				
				<TD align="right" valign="middle" class="topBarDiv" align="left" nowrap="true">
				<A href="http://mail-archives.apache.org/mod_mbox/tuscany-user">User List</A> | <A href="http://mail-archives.apache.org/mod_mbox/tuscany-dev">Dev List</A> | <A href="http://issues.apache.org/jira/browse/Tuscany">Issue Tracker</A>&nbsp;&nbsp;
				</TD>
			</TR>
		</TABLE>
		<!-- breadCrumbs macro end -->


        <TABLE border="0" cellpadding="0" width="100%" bgcolor="#FFFFFF">
            <TR>
                <TD align="left" valign="top">

					<!-- pageContent macro -->
					<DIV id="PageContent">
												
						<DIV class="pagecontent">
							<DIV class="wiki-content">
								<H1><A name="WebSample-TuscanyRDBDASSample%28companyweb%29"></A>Tuscany RDB DAS Sample (companyweb)</H1>

<P>This stand-alone sample demonstrates the SDO RDB Data Access Service in the context of a simple web application.</P>

<P>The application starts with a canned database of Companies and their related Departments.  Through the web page interface, a user can:</P>

<UL>
	<LI>Display all Companies in the database</LI>
	<LI>Display all Companies and related Departments</LI>
	<LI>Add a new Department to a Company</LI>
	<LI>Delete all Departments from a Company</LI>
	<LI>Change the names of Departments in a Company</LI>
</UL>


<P>So, this simple application covers all CRUD operations as well as the some relationship manipulation (adding a Department associates that Department with the Company).  The sample runs on Tomcat 5.5/6.x and employs a Derby database accessed via a DataSource.</P>

<H3><A name="WebSample-Runningthesample"></A>Running the sample</H3>
<P>There are two options for running this sample:</P>

<OL>
	<LI>Run from Tomcat configured by the build</LI>
	<LI>Deploying the CompanyWeb WAR into a Tomcat you configure yourself</LI>
</OL>



<P> 1. Running from Tomcat configured by the build<BR>
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/das/samples/testing/tomcat build (see java/das/samples/testing/tomcat/readme.htm )  and then access the application by pointing your browser to <A href="http://localhost:8080/sample-companyweb/" class="external-link" rel="nofollow">http://localhost:8080/sample-companyweb/</A>.  </P>


<P> 2. Deploying the CompanyWeb WAR into a Tomcat you configure yourself<BR>
Alternatively, you can deploy the sample to your own configured Tomcat installation by following the <BR>
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 <A href="http://incubator.apache.org/tuscany/java_das_overview.html" class="external-link" rel="nofollow">http://incubator.apache.org/tuscany/java_das_overview.html</A> .</P>

<H3><A name="WebSample-SetUp"></A>Set Up</H3>

<OL>
	<LI>Download and install the most recent stable version of Tomcat 5.5.  You can find it here:<BR>
         <A href="http://tomcat.apache.org/download-55.cgi" class="external-link" rel="nofollow">http://tomcat.apache.org/download-55.cgi</A></LI>
	<LI>Download the most recent official release of Derby from here: <A href="http://db.apache.org/derby/index.html" class="external-link" rel="nofollow">http://db.apache.org/derby/index.html</A>.<BR>
         The only file you'll need from this download is derby.jar</LI>
	<LI>Stop Tomcat</LI>
	<LI>Copy derby.jar (from the derby distribution) to <EM>Tomcat_Home</EM>/common/lib</LI>
	<LI>Add the sample war file to <EM>Tomcat_Home</EM>/webapps<BR>
              a.sample-companyweb-xxx.war (e.g. &quot;sample-companyweb-1.0-incubator-M2.war&quot;)</LI>
	<LI>Install the canned Derby database to Tomcat:<BR>
              a.First, create a new directory named &quot;Databases&quot; to hold the sample database.Create  <BR>
              Tomcat_Home / Databases<BR>
              b.Copy the dastest folder (and all its contents) from (_build directory root OR where samples <BR>
              were unzipped_/java/das/samples/companyweb) to <EM>Tomcat_Home</EM>/Databases (NOTE: If you are running <BR>
              this from a sample distribution, the canned database is available in the distribution, inside <BR>
              the databases directory. )         </LI>
	<LI>Define a DataSource by adding a datasource definition to <EM>Tomcat_Home</EM>/conf/server.xml.<BR>
             a.Find the end-of-section marker &lt;/GlobalNamingResources&gt; and add the following lines just above <BR>
             it: (Requirement: You must include the absolute path to the &quot;Databases&quot; directory in the above url<BR>
             attribute.  Fore example: url=&quot;jdbc:derby:c:\apache-tomcat-5.5.17\Databases/dastest&quot;/&gt;)
<DIV class="preformatted panel" style="border-width: 1px;"><DIV class="preformattedContent panelContent">
<PRE>        &lt;!-- Global Datasource for Derby dastest database --&gt;
         &lt;Resource name=&quot;jdbc/dastest&quot;
              type=&quot;javax.sql.DataSource&quot;  auth=&quot;Container&quot;
              description=&quot;Derby database for DAS Company sample&quot;
              maxActive=&quot;100&quot; maxIdle=&quot;30&quot; maxWait=&quot;10000&quot;
              username=&quot;&quot; password=&quot;&quot; 
              driverClassName=&quot;org.apache.derby.jdbc.EmbeddedDriver&quot;
              url=&quot;jdbc:derby:{absolute path}Databases/dastest&quot;/&gt;
</PRE>
</DIV></DIV></LI>
	<LI>Start tomcat and point your browser to: <A href="http://localhost:8080/sample-companyweb-" class="external-link" rel="nofollow">http://localhost:8080/sample-companyweb-</A> <EM>version</EM> <EM>tag</EM>/<BR>
         example: <A href="http://localhost:8080/sample-companyweb-1.0-incubator-M2/" class="external-link" rel="nofollow">http://localhost:8080/sample-companyweb-1.0-incubator-M2/</A></LI>
</OL>


<H3><A name="WebSample-SampleArchitecture"></A>Sample Architecture</H3>
<P>This is a simple, single-page, web application.  The main components of this application are:</P>
<UL>
	<LI>The RDB Data Access Service (DAS)</LI>
	<LI>SDO</LI>
	<LI>CompanyClient.java</LI>
	<LI>Company.jsp</LI>
	<LI>The canned Derby database</LI>
</UL>


<P>The CompanyClient uses the DAS directly and provides high-level services to the jsp such as:<BR>
public final List getCompanies()<BR>
This is a good place to look for how you might use the DAS in your own application.</P>

<P>The Company.jsp responds to client interaction by invoking services of the CompanyClient.  It receives data from the CompanyClient as SDO data graphs and manipulates SDOs directly to display data.</P>

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

<P>The DAS accepts directives (commands) from the CompanyClient and reads and writes to the derby database instance appropriately. </P>
							</DIV>
						</DIV>
					</DIV>	
		            <!-- pageContent macro end -->
					
                </TD>
            </TR>
        </TABLE>

		<!-- footer macro -->
				<SCRIPT src="http://www.google-analytics.com/urchin.js" type="text/javascript">
		</SCRIPT>
		<SCRIPT type="text/javascript">
		   _uacct = "UA-1174707-5";
		   urchinTracker();
		</SCRIPT>
		
				<A href="http://www.statcounter.com/" target="_blank"><IMG src="http://c26.statcounter.com/counter.php?sc_project=2619156&java=0&security=94bd7e7d&invisible=0" alt="website stats" border="0"></A>    

		<DIV class="footer">
			Copyright � 2003-2012, The Apache Software Foundation&nbsp;&nbsp;</BR>
                        Apache Tuscany and the Apache Tuscany project logo are trademarks of The Apache Software Foundation.
		</DIV>
		<!-- footer macro end -->

    </BODY>
</HTML>