The objective of this sample is to provide simple demonstration of an SCA application assembly involving different implementation and binding technlogies. This sample is an SCA Standalone Calculator Application called "Calculator Combo" 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. This sample depends on two other samples which are :- i) The CalculatorRmiService SCA Standalone Assembly which assembles Calculator functions implemented in Java and exposing the Calculator as RMI Services ii) The Calculator WebService that assembles Calculator functions implemented in Java and exposing them as WebServices |
The source for this sample is located in the paths - samples\standalone\calculator-combo
of the source
distribution.
If there is binary distribution available for these samples, then you may find these samples packaged as sample-calculator-combo.jar.
If you are working with a source distribution, then you must first
build the source of this sample.
- Ensure that you have Java 5 installed on your system.
- 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.
Having installed Maven, open a command line console
and switch over to the directory on your local system, where you have
extracted the source. - Now switch futher into the subdirectory samples\standalone\calcualtor-combo. Within this directory execute the following command
|
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: -
i) | From the directory samples\standalone\calculator-combo
execute the following command
|
||||||||||
ii) | This sample would require the following extensions of Tuscany : - RMI Binding Extension, JavaSCript Container Extension, Axis2 Binding Extension, Ruby Container Extension. The jar files of all of these extensions have to copied from the the contrib sub-directory into the extensions directory of the distribution. ie. execute the following from the samples\standalone\calculator-combo sub-directory: -
|
Now that the sample source has been built and the Tuscany Standalone Runtime setup, you may run the Calculator-Combo sample as follows: -
i) | Ensure that the Calculator-RMIService Sample and the Calculator WebService samples are running. You can find them under samples\standalone\calcualtorRMIService and samples\webapp\calcualtorws 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. | ||
ii) | Switch to the samples\standalone\calculator-combo\target\distribution
sub-directory and execute the following command:
|
||
iii) | 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 *************************************** Starting the Calculator Combo sample!!! *************************************** Invoking Java Implementation ... 3 + 2 = 5.0 Invoking Ruby Implementation ... 3 - 2 = 1.0 Invoking over RMI Reference... 3 * 2 = 6.0 Invoking WebService Implementation ... 3 / 2 = 1.5 Invoking Scientific Calculator Composite Implementation ... .....Invoking Java Implementation ... .....Average of 1,2,3,4,5,6,7,8,9 = 5.0 .....Invoking JavaScript Implementation ... .....Square Root of 81 = 9.0 .....Invoking Java Implementation configued for Property ... .....Sine 90 Degrees = 1.0 .....Cos 90 Degrees = 6.123233995736766E-17 .....Tan 90 Degrees = 1.633123935319537E16 |
Thus we see the Calculator Combo demonstrating the assembly of different technologies to provide a wholesome Calculator Service to the external world.
The source files are physically organized as shown below:
Calculator Combo +---main |
Calculator Combo Sample (Standalone Deployment)
default.scdl | - Defines an assembly of calculator
functions implemented in Java and exposed as a WebService using the
Axis2 binding. - Defines a SciCalculatorComponent that is implemented by an SCA Composite defined in sci_calc.scdl |
sci_calc.scdl | - Defines an assembley of advanced calculator functions implemented in Java - Uses a property configuration called 'trig-metric' that configures the metric that is used when invoking trignometric functions (sin, cos, tan) |
AddService.java AddServiceImpl.java DivideService.java MathService.java MathServiceImpl.java MultiplyService.java MultiplyServiceImpl.java SubtractService.java SubtractServiceImpl.java |
Java Interfaces and Java Implementations for various calculator functions. |
CalculatorService.java CalculatorServiceImpl.java |
- Defines the coarse grained Calculator Interface and
Implementation. This calculator implementation delegates function
requests to other granular implemenations listed above. - Holds a reference to the RMI Calculator Service which is invoked to provide the 'multiply' function |
DivideServiceImpl.java | - Provides an implementation for the DivideService and is called by the CalculatorService to provide the 'divide' function - Holds a reference to the Calculator WebService which is invoked to provide the 'divide' function. |
SciCalculatorService SciCalculatorService |
Java Interface and Implementation for advanced functions of the calculator (avg, sqrt, sin, cos, tan, ...) |
SqrtService.java | Provides an interface defintion for the JavaScript ComponentType definition of the square-root service |
calculator.wsdl | - Defines the Calculator service using WSDL to enable
the CalculatorServiceImpl to be exposed as a Axis2 WebService - This wsdl is required to establish the client binding to the Calculator WebService |
Sqrt.componentType | Provides the component type information (component type sidefile) for the JavaScript implementation of the Square-Root service |
Sqrt.js | A JavaScript implementation for the square-root function |
SubtractImpl.componentType | Provides the component type information (component type sidefile) for the Ruby implementation of the Subtract service |
SubtractImpl.rb | A Ruby implementation for the Subtract function |