summaryrefslogtreecommitdiffstats
path: root/branches/sca-java-M2/samples/standalone/calculator-combo/readme.html
blob: f8b33b440d2cda1c09e85127daec3052502fe7a7 (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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<!--
 * 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=iso-8859-1"><meta http-equiv="Content-Style-Type" content="text/css"><title>Tuscany
Calculator-Combo Sample</title><!-- LINK rel="stylesheet" href="ait.css" type="text/css" --><!-- maven -->
<style type="text/css" media="all">
@import url("../../../../css/maven-base.css");
@import url("../../../../css/maven-theme.css");
@import url("../../../../css/site.css");
</style><link rel="stylesheet" href="./css/print.css" type="text/css" media="print"><!-- end maven --></head>
<body>
<H3>Tuscany Calculator-Combo - A Simple SCA Assembly involving Java,
JavaScript, Ruby, RMI and WebServices</H3>
<H3>Overview</H3>
<TABLE border="0">
	<TBODY>
		<TR>
			<TD width="100%" valign="top" align="left"> The objective of this sample is to provide simple demonstration of an SCA application assembly involving different implementation and binding technlogies. <BR>This sample is an SCA Standalone Calculator Application called &quot;Calculator Combo&quot;  assembling Calculator  functions implemented in Java, JavaScript and Ruby and references to the external RMI and WebService implementations of the Calculator funtions. Besides, this assembly also includes a component that is implemented as a Composite and there is also a simple demonstration of property configuration of components.
			
			<BR>
			<BR>This sample depends on two other samples which are :-
			<BR>
			i) The CalculatorRmiService  SCA Standalone Assembly which assembles  Calculator functions implemented in Java and exposing the Calculator as RMI Services<BR>
			ii) The  Calculator WebService  that  assembles Calculator functions  implemented in Java and exposing  them as WebServices
			</TD>
		</TR>
	</TBODY>
</TABLE>
<H3>Location</H3>
<P>The source for this sample is located &nbsp;in the paths -  <I>samples\standalone\calculator-combo</I>
 of the source
distribution.<BR>
<BR>
If there is binary distribution available for these samples, then you may find these samples packaged as <I>sample-calculator-combo.jar.</I></P>
<H3>Building &amp; Running the Calculator-Combo Sample Source</H3>
<P>If you are working with a source distribution, then you must first
build the source of this sample. <BR>
- Ensure that you have Java 5 installed on your system.<BR>
- Next, you must have Maven 2.0.4 installed on your system. Look up
http://maven.apache.org/download.html for downloading and installing
Maven.</P>
<H4>Building the Calculator-Combo Sample</H4>
<TABLE border="0">
	<TBODY>
		<TR>
			<TD valign="top"></TD>
			<TD valign="top">Having installed Maven, open a command line console
			and switch over to the directory on your local system, where you have
			extracted the source.<BR>
			- Now switch futher into the subdirectory <I>samples\standalone\calcualtor-combo.
			</I>Within this directory execute the following command
			<TABLE border="0">
				<TBODY>
					<TR>
						<TD><FONT color="purple">&gt;</FONT></TD>
						<TD><FONT color="purple" face="Courier New">mvn</FONT></TD>
					</TR>
				</TBODY>
			</TABLE>
			This will build the <I>calculator-combo</I> sample, package a JAR
			file for the composite and make it available in the sub-directory <I>samples\standalone\calculator-combo/target</I></TD>
			<TD></TD>
		</TR>
	</TBODY>
</TABLE>
<H4><BR>
Setting up Tuscany Standalone Runtime </H4>
<P>To run these samples you need the Tuscany Standalone Runtime. This is
available as a distribution that can be conveniently unpacked and setup
in the samples directory itself. For this, do the following: -</P>
<TABLE border="0">
	<TBODY>
		<TR>
			<TD valign="top" align="right">i)</TD>
			<TD>From the directory <I>samples\standalone\calculator-combo</I>
			execute the following command
			<TABLE border="0">
				<TBODY>
					<TR>
						<TD><FONT color="purple">&gt;</FONT></TD>
						<TD><FONT color="purple" face="Courier New">mvn dependency:unpack</FONT></TD>
					</TR>
				</TBODY>
			</TABLE>
			This will unpack the Tuscany Standalone Runtime Distribution to the <I>target\distribution
			</I>sub-directory within the present working directory - <I>samples\standalone\calculator-combo</I></TD>
		</TR>
		<TR>
			<TD valign="top">ii)</TD>
			<TD>This sample would require the following extensions of Tuscany : -<BR>RMI Binding Extension, JavaSCript Container Extension, Axis2 Binding Extension, Ruby Container Extension. <BR>The jar files of all of these extensions have to copied from the the <I>contrib </I>sub-directory
			into the <I>extensions </I>directory of the distribution. ie. execute
			the following from the <I>samples\standalone\calculator-combo </I>sub-directory:
			-
			<TABLE>
				<TBODY>
					<TR>
						<TD valign="top"><FONT color="purple">&gt;</FONT></TD>
						<TD><FONT color="purple" face="Courier New">copy
						target\distribution\contrib\rmi-1.0-incubator-M2.jar <FONT
							color="purple" face="Courier New">target\distribution\extensions\rmi-1.0-incubator-M2.jar</FONT></FONT></TD>
					</TR>
					<TR>
						<TD valign="top"><FONT color="purple">&gt;</FONT></TD><TD><FONT color="purple" face="Courier New">copy
						target\distribution\contrib\axis2-1.0-incubator-M2.jar <FONT color="purple" face="Courier New">target\distribution\extensions\axis2-1.0-incubator-M2.jar</FONT></FONT></TD>
						
					</TR>
					<TR>
						<TD valign="top"><FONT color="purple">&gt;</FONT></TD><TD><FONT color="purple" face="Courier New">copy
						target\distribution\contrib\javascript-1.0-incubator-M2.jar <FONT color="purple" face="Courier New">target\distribution\extensions\javascript-1.0-incubator-M2.jar</FONT></FONT></TD>
						
					</TR>
					<TR>
						<TD valign="top"><FONT color="purple">&gt;</FONT></TD><TD><FONT color="purple" face="Courier New">copy
						target\distribution\contrib\ruby-1.0-incubator-M2.jar <FONT color="purple" face="Courier New">target\distribution\extensions\ruby-1.0-incubator-M2.jar</FONT></FONT></TD>
						
					</TR>
					<TR>
						<TD valign="top"><FONT color="purple">&gt;</FONT></TD>
						<TD><FONT color="purple" face="Courier New">copy
						target\distribution\contrib\databinding-sdo-1.0-incubator-M2.jar <FONT
							color="purple" face="Courier New">target\distribution\extensions\databinding-sdo-1.0-incubator-M2.jar</FONT></FONT></TD>
					</TR>
				</TBODY>
			</TABLE>
			<I>Note</I> : <I>If you are working with SNAPSHOTs versions of
			Tuscany Extensions then the files in the above commands must be substituted with the corresponding SNAPSHOT versions. For example <B>rmi-1.0-incubator-M2.jar</B> in
			the above command must be substituted with <B>rmi-1.0-incubator-M2-SNAPSHOT.jar</B></I></TD>
		</TR>
	</TBODY>
</TABLE>
<H4>Running the Calculator-Combo Sample
</H4>
<P>Now that the sample source has been built and the Tuscany Standalone
Runtime setup, you may run the Calculator-Combo sample as follows: -</P>
<TABLE border="0">
	<TBODY>
		<TR>
			<TD valign="top">i)</TD>
			<TD>Ensure that the Calculator-RMIService Sample and the Calculator WebService samples are running. You can find them under <I>samples\standalone\calcualtorRMIService </I>and <I>samples\webapp\calcualtorws</I> directories of the samples source distribution respectively. Details pertaining to building and running these samples can be found in the respective readme.html files under each of them.</TD>
		</TR>
		<TR>
			<TD valign="top">ii)</TD><TD>Switch to the <I>samples\standalone\calculator-combo\target\distribution
			</I>sub-directory and execute the following command:
			<TABLE>
				<TBODY>
					<TR>
						<TD><FONT color="purple">&gt;</FONT></TD>
						<TD><FONT color="purple" face="Courier New">java -jar
						bin\launcher.jar ..\sample-calculator-combo.jar</FONT></TD>
					</TR>
				</TBODY>
			</TABLE>
			</TD>
			
		</TR>
		<TR>
			<TD valign="top">iii)</TD>
			<TD>You will initially observe messages that relate to resolution of
			dependencies required to run this sample and finlly see the following
			message on your console<BR>
			<FONT color="green" face="Courier New"></FONT><FONT
				face="Courier New" color="green" size="+0">***************************************<BR>
			Starting the Calculator Combo sample!!!<BR>
			***************************************<BR>
			Invoking Java Implementation ...<BR>
			3 + 2 = 5.0<BR>
			Invoking Ruby Implementation ...<BR>
			3 - 2 = 1.0<BR>
			Invoking over RMI Reference...<BR>
			3 * 2 = 6.0<BR>
			Invoking WebService Implementation ...<BR>
			3 / 2 = 1.5<BR>
			Invoking Scientific Calculator Composite Implementation ...<BR>
			.....Invoking Java Implementation ...<BR>
			.....Average of 1,2,3,4,5,6,7,8,9 = 5.0<BR>
			.....Invoking JavaScript Implementation ...<BR>
			.....Square Root of 81 = 9.0<BR>
			.....Invoking Java Implementation configued for Property ...<BR>
			.....Sine 90 Degrees = 1.0<BR>
			.....Cos 90 Degrees = 6.123233995736766E-17<BR>
			.....Tan 90 Degrees = 1.633123935319537E16</FONT><FONT color="green"></FONT></TD>
		</TR>
	</TBODY>
</TABLE>
<P>Thus   we see the Calculator Combo demonstrating the assembly of different technologies to provide a wholesome Calculator Service to the external world.<BR>
</P><H2>Code Overview</H2>
<P>The source files are physically organized as shown below:<BR>
</P>
<table style="text-align: left; width: 100%;" border="1" cellpadding="2" cellspacing="2"><tbody><tr><td>
<pre>
<B><U></U></B><B><U>Calculator Combo</U></B>
+---main<BR>    +---java<BR>    |   +---calculator
<I>               &lt;Interfaces and Implementations for Calculator Functions&gt;

</I>            +---client
                   CalculatorClient.java
    +---resources
        +---wsdl
               calculator.wsdl
    +---webapp
        +---WEB-INF
               default.scdl
               web.xml</pre></td></tr></tbody></table>
<P><B> <BR>
</B></P>
<P><B>Calculator Combo Sample (Standalone Deployment)</B></P><TABLE border="1">
	<TBODY>
		<TR>
			<TD width="230" valign="top">default.scdl</TD>
			<TD width="396" valign="top">- Defines an assembly of calculator
			functions implemented in Java and exposed as a WebService using the
			Axis2 binding.<BR>- Defines a SciCalculatorComponent that is implemented by an SCA Composite defined in  sci_calc.scdl </TD>
		</TR>
		<TR>
			<TD width="230" valign="top">sci_calc.scdl</TD>
			<TD width="396" valign="top">- Defines an assembley of advanced calculator functions implemented in Java<BR>- Uses a property configuration called 'trig-metric' that configures the metric that is  used when invoking trignometric functions (sin, cos, tan)</TD>
		</TR>
		<TR>
			<TD width="230">AddService.java<BR>
			AddServiceImpl.java<BR>
			DivideService.java<BR>MathService.java<BR>
			MathServiceImpl.java<BR>
			MultiplyService.java<BR>
			MultiplyServiceImpl.java<BR>
			SubtractService.java<BR>
			SubtractServiceImpl.java</TD>
			<TD width="396">Java Interfaces and Java Implementations for various calculator
			functions. <I>
			</I></TD>
		</TR>
		<TR>
			<TD width="230">CalculatorService.java<BR>
			CalculatorServiceImpl.java</TD>
			<TD width="396">- Defines the coarse grained Calculator Interface and
			Implementation. This calculator implementation delegates function
			requests to other granular implemenations listed above. <BR>- Holds a reference to the RMI Calculator Service which is invoked to provide the 'multiply' function</TD>
		</TR>
		<TR>
			<TD width="230">DivideServiceImpl.java</TD>
			<TD width="396">- Provides an implementation for the DivideService and is called by the CalculatorService to provide the 'divide' function<BR>- Holds a reference to the Calculator WebService which is invoked to provide the 'divide' function.</TD>
		</TR>
		<TR>
			<TD width="230">SciCalculatorService<BR>SciCalculatorService
			</TD>
			<TD width="396">Java Interface and Implementation for advanced functions of the calculator (avg, sqrt, sin, cos, tan, ...)</TD>
		</TR>
		<TR>
			<TD width="230">SqrtService.java</TD>
			<TD width="396">Provides an interface defintion for the JavaScript ComponentType definition of the square-root service</TD>
		</TR>
		<TR>
			<TD width="230">calculator.wsdl</TD>
			<TD width="396">- Defines the Calculator service using WSDL to enable
			the CalculatorServiceImpl to be exposed as a Axis2 WebService<BR>- This wsdl is required to establish the client binding to the Calculator WebService
			</TD>
		</TR>
		<TR>
			<TD width="230">Sqrt.componentType</TD>
			<TD width="396">Provides the component type information (component type sidefile) for the JavaScript implementation of the Square-Root service</TD>
		</TR>
		<TR>
			<TD width="230">Sqrt.js</TD>
			<TD width="396">A JavaScript implementation for the square-root function</TD>
		</TR>
		<TR>
			<TD width="230">SubtractImpl.componentType</TD>
			<TD width="396">Provides the component type information (component type sidefile) for the Ruby implementation of the Subtract service</TD>
		</TR>
		<TR>
			<TD width="230">SubtractImpl.rb</TD>
			<TD width="396">A Ruby implementation for the Subtract function</TD>
		</TR>
	</TBODY>
</TABLE>
<P><B></B></P>
</body></html>