summaryrefslogtreecommitdiffstats
path: root/site/trunk/site-publish/getting-started-with-tuscany.html
diff options
context:
space:
mode:
Diffstat (limited to 'site/trunk/site-publish/getting-started-with-tuscany.html')
-rw-r--r--site/trunk/site-publish/getting-started-with-tuscany.html814
1 files changed, 814 insertions, 0 deletions
diff --git a/site/trunk/site-publish/getting-started-with-tuscany.html b/site/trunk/site-publish/getting-started-with-tuscany.html
new file mode 100644
index 0000000000..dcb2a4901d
--- /dev/null
+++ b/site/trunk/site-publish/getting-started-with-tuscany.html
@@ -0,0 +1,814 @@
+
+<!--
+
+ 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 : Getting Started with Tuscany</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=67902">
+ <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="sca-overview.html" title="SCA Overview">SCA Overview</A>&nbsp;&gt;&nbsp;<A href="sca-java.html" title="SCA Java">SCA Java</A>&nbsp;&gt;&nbsp;<A href="java-sca-documentation-menu.html" title="Java SCA Documentation Menu">Java SCA Documentation Menu</A>&nbsp;&gt;&nbsp;<A href="" title="Getting Started with Tuscany">Getting Started with Tuscany</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="GettingStartedwithTuscany-Ready%2CSet%2CGoGettingstartedwithTuscany"></A>Ready, Set, Go - Getting started with Tuscany</H1>
+
+<P>This article will show you how to download a Tuscany distribution, add the distribution as a user library in Eclipse, create the Store sample as a Java project, and then run the Store and use it from a web browser.</P>
+
+<DIV class="panelMacro"><TABLE class="infoMacro"><COLGROUP><COL width="24"><COL></COLGROUP><TR><TD valign="top"><IMG src="https://cwiki.apache.org/confluence/images/icons/emoticons/information.gif" width="16" height="16" align="absmiddle" alt="" border="0"></TD><TD>Although this guide show some images based on the Java SCA 1.3.2 release, you should be able to use latest Java SCA release while going to the necessary steps for this guide.</TD></TR></TABLE></DIV>
+
+<P><A href="http://cwiki.apache.org/confluence/display/TUSCANYWIKI/Getting%20Started%20with%20Apache%20Tuscany" class="external-link" rel="nofollow"><IMG class="emoticon" src="https://cwiki.apache.org/confluence/images/icons/emoticons/star_yellow.gif" height="16" width="16" align="absmiddle" alt="" border="0"> &quot;Get Started with Store Demo in Eclipse video&quot;</A></P>
+
+<H2><A name="GettingStartedwithTuscany-InstalltheTuscanyDistribution%26nbsp%3B"></A>Install the Tuscany Distribution&nbsp;</H2>
+
+<P>The first thing you do is to create a file system folder into which you will download the TUSCANY distribution.</P>
+
+<P><SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/tuscany_folder.jpg" style="border: 0px solid black"></SPAN></P>
+
+<P>Next you download the latest release distribution. Launch your browser and enter the following URL.<BR>
+Latest Release - <A href="http://cwiki.apache.org/TUSCANY/sca-java-releases.html" class="external-link" rel="nofollow">http://cwiki.apache.org/TUSCANY/sca-java-releases.html</A><BR>
+Download both the <B><EM>bin zip</EM></B> as well as the <B><EM>src zip</EM></B> to the folder that you created on your disk. Once you completed the download you should see the following on your disk.</P>
+
+<P><SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/release_zips.jpg" style="border: 0px solid black"></SPAN><BR>
+&nbsp;<BR>
+Next you unzip the <B><EM>bin zip</EM></B> in place, you should see the following folder file structure on your disk after unzip is complete.<BR>
+<SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/folder_structure.jpg" style="border: 0px solid black"></SPAN></P>
+
+<H2><A name="GettingStartedwithTuscany-SetupEclipseforTuscany"></A>Setup Eclipse for Tuscany</H2>
+
+<P>Start Eclipse and create a User Library to contain the TUSCANY runtime jar's as well as their<BR>
+depending jar's.</P>
+
+<P>From the menu bar select <B><EM>Window</EM></B> and then <B><EM>Preferences...</EM></B> . The Preferences dialog will appear,<BR>
+in its left navigation tree select <B><EM>Java</EM></B>, followed by <B><EM>Build Path</EM></B>, and followed by <B><EM>User Libraries</EM></B>.<BR>
+Select the <B><EM>New...</EM></B> pushbutton on the right of the New Libraries dialog to create a new user library.</P>
+
+<P><SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/New_User_Lib.png" style="border: 0px solid black"></SPAN></P>
+
+<P>The user library created is empty, select the <B><EM>Add JARs...</EM></B> pushbutton on the right to add all the<BR>
+jar's from your Tuscany installation <B><EM>lib folder</EM></B>. When completed all the jar's will appear under the<BR>
+TUSCANY user library.</P>
+
+<P><SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/Tuscany_User_Lib.png" style="border: 0px solid black"></SPAN></P>
+
+<P>Since some of you maybe interested in <B><EM>debugging</EM></B> also the Tuscany runtime code we will attach<BR>
+the Tuscany source to the Tuscany runtime jar in the following step. In the User Libraies dialog<BR>
+scroll down until you see the <B><EM>Tuscany runtime jar</EM></B> and select its <B><EM>Source attachment.</EM></B></P>
+
+<P><SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/source_attachment.jpg" style="border: 0px solid black"></SPAN></P>
+
+<P>Select the <B><EM>Edit...</EM></B> pushbutton on the right and in the Edit dialog use the <B><EM>External File...</EM></B> pushbutton<BR>
+to the select the Tuscany <B><EM>src zip</EM></B> that we downloaded earlier.</P>
+
+<P><SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/source_attachment_config.jpg" style="border: 0px solid black"></SPAN></P>
+
+<P>Select <B><EM>OK</EM></B> to complete this and the Preferences dialog, and you are done with the Tuscany setup<BR>
+for Eclipse.</P>
+
+<H2><A name="GettingStartedwithTuscany-Createyour1stCompositeServiceApplication"></A>Create your 1st Composite Service Application</H2>
+
+<P>The following shows the composition diagram for the composite service application you are about<BR>
+to create.</P>
+
+<P><SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/first_composite.png" style="border: 0px solid black"></SPAN></P>
+
+<P>The composite service application you will create is a composition of four services. The composed<BR>
+service provided is that of an on-line store.<BR>
+There is a Catalog service which you can ask for catalog items, and depending on its currency<BR>
+code property configuration it will provide the item prices in USD or EUR. The Catalog service is not<BR>
+doing the currency conversion itself it references a CurrencyConverter service to do that task. Then<BR>
+there is the ShoppingCart service into which items chosen from the catalog can be added, it is<BR>
+implemented as a REST service. The Catalog is bound using the JSONRPC binding, and the<BR>
+ShoppingCart service is bound using the ATOM binding. Finally there is the Store user facing<BR>
+service that provides the browser based user interface of the store. The Store service makes use of<BR>
+the Catalog and ShoppingCart service using the JSONRPC, and ATOM binding respectively.</P>
+
+<H2><A name="GettingStartedwithTuscany-CreateaJavaProject"></A>Create a Java Project</H2>
+
+<P>In this step you create a Java Project in Eclipse to hold the composite service application.<BR>
+Click on the <B><EM>New Java Project</EM></B> button <SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/new_java_project.png" style="border: 0px solid black"></SPAN>&nbsp; in the toolbar to launch the project creation dialog.<BR>
+Next you enter &quot;store&quot; as the <B><EM>Project name</EM></B>, and for <B><EM>Project Layout</EM></B> select <B><EM>Create separate</EM></B><BR>
+<B><EM>folders for sources and class files.</EM></B><BR>
+<SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/new_java_project_dlg.png" style="border: 0px solid black"></SPAN><BR>
+&nbsp;<BR>
+<SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/project_layout.png" style="border: 0px solid black"></SPAN><BR>
+&nbsp;<BR>
+Hit the <B><EM>Next</EM></B> button, and on the following page go to the <B><EM>Libraries</EM></B> tab. Use the <B><EM>Add Library...</EM></B><BR>
+button on the right to add the TUSCANY user library to the project.<BR>
+&nbsp;<BR>
+<SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/new_java_project_lib.png" style="border: 0px solid black"></SPAN><BR>
+&nbsp;<BR>
+&nbsp;<BR>
+Hit the <B><EM>Finish</EM></B> button to complete the <B><EM>New Java Project</EM></B> dialog to create the &quot;store&quot; java project.&nbsp;<BR>
+&nbsp;<BR>
+<SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/new_java_project_folder.png" style="border: 0px solid black"></SPAN><BR>
+&nbsp;<BR>
+&nbsp;</P>
+
+<H2><A name="GettingStartedwithTuscany-ConstructServices"></A>Construct Services</H2>
+
+<P>First you create two package folders into which later in this step you place service implementations.<BR>
+Select the &quot;store&quot; project and click on the <B><EM>New Java Package</EM></B> button <SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/new_java_pkg_btn.png" style="border: 0px solid black"></SPAN> in the toolbar to launch<BR>
+the package creation dialog.</P>
+
+<P>Next you enter &quot;services&quot; as the package <B><EM>Name</EM></B>, and press the <B><EM>Finish</EM></B> button to complete the<BR>
+dialog.<BR>
+<SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/new_java_pkg_dlg.png" style="border: 0px solid black"></SPAN><BR>
+&nbsp;<BR>
+Repeat the previous step to create another package named &quot;ufservices&quot;. The store project now<BR>
+should look as follows.<BR>
+&nbsp;<BR>
+<SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/new_java_pkg_folder.png" style="border: 0px solid black"></SPAN><BR>
+&nbsp;<BR>
+In the following you will place in the &quot;services&quot; package the regular services, and in the &quot;ufservices&quot;<BR>
+package the user facing services of the composite service application you create.</P>
+
+<H3><A name="GettingStartedwithTuscany-Catalog"></A><EM>Catalog</EM></H3>
+
+<P>In this step you create the Catalog service interface and implementation.<BR>
+Select the &quot;services&quot; package. Next you click on the dropdown arrow next to the <B><EM>New Java Class</EM></B><BR>
+button&nbsp; <SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/class_btn.png" style="border: 0px solid black"></SPAN>&nbsp; and select the <B><EM>New Java Interface</EM></B>&nbsp;&nbsp;&nbsp;<SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/interface_btn.png" style="border: 0px solid black"></SPAN> option from the dropdown list. In the dialog<BR>
+enter &quot;Catalog&quot; as the <B><EM>Name</EM></B> of the interface and select the Finish button to complete the dialog.<BR>
+The Java editor will open on the new created Java interface. Replace the content of the editor by<BR>
+<B><EM>copy-paste</EM></B> of the following Java interface code snippet.</P>
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+<SPAN class="code-keyword">package</SPAN> services;
+
+<SPAN class="code-keyword">import</SPAN> org.osoa.sca.annotations.Remotable;
+
+@Remotable
+<SPAN class="code-keyword">public</SPAN> <SPAN class="code-keyword">interface</SPAN> Catalog {
+ Item[] get();
+}
+</PRE>
+</DIV></DIV>
+<P>Select the &quot;services&quot; package again. Select the <B><EM>New Java Class</EM></B> button <SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/class_btn.png" style="border: 0px solid black"></SPAN> . In the dialog enter<BR>
+&quot;CatalogImpl&quot; as the <B><EM>Name</EM></B> of the class, add &quot;Catalog&quot; as the interface this class implements, and<BR>
+then select <B><EM>Finish</EM></B> to complete the dialog.</P>
+
+<P>The Java editor will open on the new created Java class. Replace the content of the editor by<BR>
+<B><EM>copy-paste</EM></B> of the following Java class code snippet.</P>
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+<SPAN class="code-keyword">package</SPAN> services;
+
+<SPAN class="code-keyword">import</SPAN> java.util.ArrayList;
+<SPAN class="code-keyword">import</SPAN> java.util.List;
+
+<SPAN class="code-keyword">import</SPAN> org.osoa.sca.annotations.Init;
+<SPAN class="code-keyword">import</SPAN> org.osoa.sca.annotations.Property;
+<SPAN class="code-keyword">import</SPAN> org.osoa.sca.annotations.Reference;
+
+<SPAN class="code-keyword">public</SPAN> class CatalogImpl <SPAN class="code-keyword">implements</SPAN> Catalog {
+ @Property
+ <SPAN class="code-keyword">public</SPAN> <SPAN class="code-object">String</SPAN> currencyCode = <SPAN class="code-quote">&quot;USD&quot;</SPAN>;
+ @Reference
+ <SPAN class="code-keyword">public</SPAN> CurrencyConverter currencyConverter;
+
+ <SPAN class="code-keyword">private</SPAN> List&lt;Item&gt; catalog = <SPAN class="code-keyword">new</SPAN> ArrayList&lt;Item&gt;();
+
+ @Init
+ <SPAN class="code-keyword">public</SPAN> void init() {
+ <SPAN class="code-object">String</SPAN> currencySymbol = currencyConverter
+ .getCurrencySymbol(currencyCode);
+ catalog.add(<SPAN class="code-keyword">new</SPAN> Item(<SPAN class="code-quote">&quot;Apple&quot;</SPAN>, currencySymbol
+ + currencyConverter.getConversion(<SPAN class="code-quote">&quot;USD&quot;</SPAN>, currencyCode, 2.99)));
+ catalog.add(<SPAN class="code-keyword">new</SPAN> Item(<SPAN class="code-quote">&quot;Orange&quot;</SPAN>, currencySymbol
+ + currencyConverter.getConversion(<SPAN class="code-quote">&quot;USD&quot;</SPAN>, currencyCode, 3.55)));
+ catalog.add(<SPAN class="code-keyword">new</SPAN> Item(<SPAN class="code-quote">&quot;Pear&quot;</SPAN>, currencySymbol
+ + currencyConverter.getConversion(<SPAN class="code-quote">&quot;USD&quot;</SPAN>, currencyCode, 1.55)));
+ }
+
+ <SPAN class="code-keyword">public</SPAN> Item[] get() {
+ Item[] catalogArray = <SPAN class="code-keyword">new</SPAN> Item[catalog.size()];
+ catalog.toArray(catalogArray);
+ <SPAN class="code-keyword">return</SPAN> catalogArray;
+ }
+}
+</PRE>
+</DIV></DIV>
+<P>After completing these steps the content of the &quot;store&quot; project will look as follows.<BR>
+<SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/store_project.png" style="border: 0px solid black"></SPAN><BR>
+&nbsp;<BR>
+<B>Note:</B> CatalogImpl is red x'ed because it makes use of the CurrencyConverter interface that we<BR>
+have not implemented yet.<BR>
+&nbsp;</P>
+
+<H3><A name="GettingStartedwithTuscany-CurrencyConverter"></A><EM>CurrencyConverter</EM></H3>
+
+<P>In this step you create the CurrencyConverter service interface and implementation.<BR>
+You follow the same steps that you learned previously to create the interface and implementation.<BR>
+First create a Java interface in the &quot;services&quot; package named &quot;CurrencyConverter&quot; and <B><EM>copy-paste</EM></B><BR>
+the following Java interface code snippet into it.<BR>
+&nbsp;&nbsp;</P>
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+<SPAN class="code-keyword">package</SPAN> services;
+
+<SPAN class="code-keyword">import</SPAN> org.osoa.sca.annotations.Remotable;
+
+@Remotable
+<SPAN class="code-keyword">public</SPAN> <SPAN class="code-keyword">interface</SPAN> CurrencyConverter {
+ <SPAN class="code-keyword">public</SPAN> <SPAN class="code-object">double</SPAN> getConversion(<SPAN class="code-object">String</SPAN> fromCurrenycCode, <SPAN class="code-object">String</SPAN> toCurrencyCode, <SPAN class="code-object">double</SPAN> amount);
+
+ <SPAN class="code-keyword">public</SPAN> <SPAN class="code-object">String</SPAN> getCurrencySymbol(<SPAN class="code-object">String</SPAN> currencyCode);
+}
+
+</PRE>
+</DIV></DIV>
+<P>Next create a Java class in the &quot;services&quot; package named &quot;CurrencyConverterImpl&quot; and <B><EM>copy-paste</EM></B><BR>
+the following Java class code snippet into it.</P>
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+<SPAN class="code-keyword">package</SPAN> services;
+
+<SPAN class="code-keyword">public</SPAN> class CurrencyConverterImpl <SPAN class="code-keyword">implements</SPAN> CurrencyConverter {
+ <SPAN class="code-keyword">public</SPAN> <SPAN class="code-object">double</SPAN> getConversion(<SPAN class="code-object">String</SPAN> fromCurrencyCode, <SPAN class="code-object">String</SPAN> toCurrencyCode, <SPAN class="code-object">double</SPAN> amount) {
+ <SPAN class="code-keyword">if</SPAN> (toCurrencyCode.equals(<SPAN class="code-quote">&quot;USD&quot;</SPAN>))
+ <SPAN class="code-keyword">return</SPAN> amount;
+ <SPAN class="code-keyword">else</SPAN> <SPAN class="code-keyword">if</SPAN> (toCurrencyCode.equals(<SPAN class="code-quote">&quot;EUR&quot;</SPAN>))
+ <SPAN class="code-keyword">return</SPAN> ((<SPAN class="code-object">double</SPAN>)<SPAN class="code-object">Math</SPAN>.round(amount * 0.7256 * 100)) /100;
+ <SPAN class="code-keyword">return</SPAN> 0;
+ }
+
+ <SPAN class="code-keyword">public</SPAN> <SPAN class="code-object">String</SPAN> getCurrencySymbol(<SPAN class="code-object">String</SPAN> currencyCode) {
+ <SPAN class="code-keyword">if</SPAN> (currencyCode.equals(<SPAN class="code-quote">&quot;USD&quot;</SPAN>))
+ <SPAN class="code-keyword">return</SPAN> <SPAN class="code-quote">&quot;$&quot;</SPAN>;
+ <SPAN class="code-keyword">else</SPAN> <SPAN class="code-keyword">if</SPAN> (currencyCode.equals(<SPAN class="code-quote">&quot;EUR&quot;</SPAN>))
+ <SPAN class="code-keyword">return</SPAN> <SPAN class="code-quote">&quot;E&quot;</SPAN>; <SPAN class="code-comment">//<SPAN class="code-quote">&quot;&acirc;&sbquo;&not;&quot;</SPAN>;
+</SPAN> <SPAN class="code-keyword">return</SPAN> <SPAN class="code-quote">&quot;?&quot;</SPAN>;
+ }
+}
+</PRE>
+</DIV></DIV>
+<P>After completing these steps the content of the &quot;store&quot; project will look as follows.</P>
+
+<P><SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/store_project_1.png" style="border: 0px solid black"></SPAN></P>
+
+<H3><A name="GettingStartedwithTuscany-ShoppingCart"></A><EM>ShoppingCart</EM></H3>
+
+<P>In this step you create the Item model object, the Cart and Total service interfaces and the ShoppingCart service implementation.<BR>
+You follow the same steps that you learned previously to create the interface and implementation.</P>
+
+<P>Create a Java class in the &quot;services&quot; package named &quot;Item&quot; and <B><EM>copy-paste</EM></B> the<BR>
+following code snippet into it.</P>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+<SPAN class="code-keyword">package</SPAN> services;
+
+<SPAN class="code-keyword">public</SPAN> class Item {
+ <SPAN class="code-keyword">private</SPAN> <SPAN class="code-object">String</SPAN> name;
+ <SPAN class="code-keyword">private</SPAN> <SPAN class="code-object">String</SPAN> price;
+
+ <SPAN class="code-keyword">public</SPAN> Item() {
+ }
+
+ <SPAN class="code-keyword">public</SPAN> Item(<SPAN class="code-object">String</SPAN> name, <SPAN class="code-object">String</SPAN> price) {
+ <SPAN class="code-keyword">this</SPAN>.name = name;
+ <SPAN class="code-keyword">this</SPAN>.price = price;
+ }
+
+ <SPAN class="code-keyword">public</SPAN> <SPAN class="code-object">String</SPAN> getName() {
+ <SPAN class="code-keyword">return</SPAN> name;
+ }
+
+ <SPAN class="code-keyword">public</SPAN> void setName(<SPAN class="code-object">String</SPAN> name) {
+ <SPAN class="code-keyword">this</SPAN>.name = name;
+ }
+
+ <SPAN class="code-keyword">public</SPAN> <SPAN class="code-object">String</SPAN> getPrice() {
+ <SPAN class="code-keyword">return</SPAN> price;
+ }
+
+ <SPAN class="code-keyword">public</SPAN> void setPrice(<SPAN class="code-object">String</SPAN> price) {
+ <SPAN class="code-keyword">this</SPAN>.price = price;
+ }
+}
+</PRE>
+</DIV></DIV>
+
+<P>Create a Java interface in the &quot;services&quot; package named &quot;Cart&quot; and <B><EM>copy-paste</EM></B> the<BR>
+following code snippet into it.</P>
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+<SPAN class="code-keyword">package</SPAN> services;
+
+<SPAN class="code-keyword">import</SPAN> org.apache.tuscany.sca.data.collection.Collection;
+<SPAN class="code-keyword">import</SPAN> org.osoa.sca.annotations.Remotable;
+
+@Remotable
+<SPAN class="code-keyword">public</SPAN> <SPAN class="code-keyword">interface</SPAN> Cart <SPAN class="code-keyword">extends</SPAN> Collection&lt;<SPAN class="code-object">String</SPAN>, Item&gt; {
+
+}
+</PRE>
+</DIV></DIV>
+
+<P>Create a Java interface in the &quot;services&quot; package named &quot;Total&quot; and <B><EM>copy-paste</EM></B> the<BR>
+following code snippet into it.</P>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+<SPAN class="code-keyword">package</SPAN> services;
+
+<SPAN class="code-keyword">import</SPAN> org.osoa.sca.annotations.Remotable;
+
+@Remotable
+<SPAN class="code-keyword">public</SPAN> <SPAN class="code-keyword">interface</SPAN> Total {
+ <SPAN class="code-object">String</SPAN> getTotal();
+}
+</PRE>
+</DIV></DIV>
+
+<P>Create a Java class in the &quot;services&quot; package named &quot;ShoppingCartImpl&quot; and <B><EM>copy-paste</EM></B> the<BR>
+following Java class code snippet into it.</P>
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+<SPAN class="code-keyword">package</SPAN> services;
+
+<SPAN class="code-keyword">import</SPAN> java.util.ArrayList;
+<SPAN class="code-keyword">import</SPAN> java.util.HashMap;
+<SPAN class="code-keyword">import</SPAN> java.util.List;
+<SPAN class="code-keyword">import</SPAN> java.util.Map;
+<SPAN class="code-keyword">import</SPAN> java.util.UUID;
+
+<SPAN class="code-keyword">import</SPAN> org.apache.tuscany.sca.data.collection.Entry;
+<SPAN class="code-keyword">import</SPAN> org.apache.tuscany.sca.data.collection.NotFoundException;
+<SPAN class="code-keyword">import</SPAN> org.osoa.sca.annotations.Init;
+<SPAN class="code-keyword">import</SPAN> org.osoa.sca.annotations.Scope;
+
+@Scope(<SPAN class="code-quote">&quot;COMPOSITE&quot;</SPAN>)
+<SPAN class="code-keyword">public</SPAN> class ShoppingCartImpl <SPAN class="code-keyword">implements</SPAN> Cart, Total {
+
+ <SPAN class="code-keyword">private</SPAN> Map&lt;<SPAN class="code-object">String</SPAN>, Item&gt; cart;
+
+ @Init
+ <SPAN class="code-keyword">public</SPAN> void init() {
+ cart = <SPAN class="code-keyword">new</SPAN> HashMap&lt;<SPAN class="code-object">String</SPAN>, Item&gt;();
+ }
+
+ <SPAN class="code-keyword">public</SPAN> Entry&lt;<SPAN class="code-object">String</SPAN>, Item&gt;[] getAll() {
+ Entry&lt;<SPAN class="code-object">String</SPAN>, Item&gt;[] entries = <SPAN class="code-keyword">new</SPAN> Entry[cart.size()];
+ <SPAN class="code-object">int</SPAN> i = 0;
+ <SPAN class="code-keyword">for</SPAN> (Map.Entry&lt;<SPAN class="code-object">String</SPAN>, Item&gt; e : cart.entrySet()) {
+ entries[i++] = <SPAN class="code-keyword">new</SPAN> Entry&lt;<SPAN class="code-object">String</SPAN>, Item&gt;(e.getKey(), e.getValue());
+ }
+ <SPAN class="code-keyword">return</SPAN> entries;
+ }
+
+ <SPAN class="code-keyword">public</SPAN> Item get(<SPAN class="code-object">String</SPAN> key) <SPAN class="code-keyword">throws</SPAN> NotFoundException {
+ Item item = cart.get(key);
+ <SPAN class="code-keyword">if</SPAN> (item == <SPAN class="code-keyword">null</SPAN>) {
+ <SPAN class="code-keyword">throw</SPAN> <SPAN class="code-keyword">new</SPAN> NotFoundException(key);
+ } <SPAN class="code-keyword">else</SPAN> {
+ <SPAN class="code-keyword">return</SPAN> item;
+ }
+ }
+
+ <SPAN class="code-keyword">public</SPAN> <SPAN class="code-object">String</SPAN> post(<SPAN class="code-object">String</SPAN> key, Item item) {
+ <SPAN class="code-keyword">if</SPAN> (key == <SPAN class="code-keyword">null</SPAN>) {
+ key = <SPAN class="code-quote">&quot;cart-&quot;</SPAN> + UUID.randomUUID().toString();
+ }
+ cart.put(key, item);
+ <SPAN class="code-keyword">return</SPAN> key;
+ }
+
+ <SPAN class="code-keyword">public</SPAN> void put(<SPAN class="code-object">String</SPAN> key, Item item) <SPAN class="code-keyword">throws</SPAN> NotFoundException {
+ <SPAN class="code-keyword">if</SPAN> (!cart.containsKey(key)) {
+ <SPAN class="code-keyword">throw</SPAN> <SPAN class="code-keyword">new</SPAN> NotFoundException(key);
+ }
+ cart.put(key, item);
+ }
+
+ <SPAN class="code-keyword">public</SPAN> void delete(<SPAN class="code-object">String</SPAN> key) <SPAN class="code-keyword">throws</SPAN> NotFoundException {
+ <SPAN class="code-keyword">if</SPAN> (key == <SPAN class="code-keyword">null</SPAN> || key.equals(&quot;&quot;)) {
+ cart.clear();
+ } <SPAN class="code-keyword">else</SPAN> {
+ Item item = cart.remove(key);
+ <SPAN class="code-keyword">if</SPAN> (item == <SPAN class="code-keyword">null</SPAN>)
+ <SPAN class="code-keyword">throw</SPAN> <SPAN class="code-keyword">new</SPAN> NotFoundException(key);
+ }
+ }
+
+ <SPAN class="code-keyword">public</SPAN> Entry&lt;<SPAN class="code-object">String</SPAN>, Item&gt;[] query(<SPAN class="code-object">String</SPAN> queryString) {
+ List&lt;Entry&lt;<SPAN class="code-object">String</SPAN>, Item&gt;&gt; entries = <SPAN class="code-keyword">new</SPAN> ArrayList&lt;Entry&lt;<SPAN class="code-object">String</SPAN>, Item&gt;&gt;();
+ <SPAN class="code-keyword">if</SPAN> (queryString.startsWith(<SPAN class="code-quote">&quot;name=&quot;</SPAN>)) {
+ <SPAN class="code-object">String</SPAN> name = queryString.substring(5);
+ <SPAN class="code-keyword">for</SPAN> (Map.Entry&lt;<SPAN class="code-object">String</SPAN>, Item&gt; e : cart.entrySet()) {
+ Item item = e.getValue();
+ <SPAN class="code-keyword">if</SPAN> (item.getName().equals(name)) {
+ entries.add(<SPAN class="code-keyword">new</SPAN> Entry&lt;<SPAN class="code-object">String</SPAN>, Item&gt;(e.getKey(), e
+ .getValue()));
+ }
+ }
+ }
+ <SPAN class="code-keyword">return</SPAN> entries.toArray(<SPAN class="code-keyword">new</SPAN> Entry[entries.size()]);
+ }
+
+ <SPAN class="code-keyword">public</SPAN> <SPAN class="code-object">String</SPAN> getTotal() {
+ <SPAN class="code-object">double</SPAN> total = 0;
+ <SPAN class="code-object">String</SPAN> currencySymbol = &quot;&quot;;
+ <SPAN class="code-keyword">if</SPAN> (!cart.isEmpty()) {
+ Item item = cart.values().iterator().next();
+ currencySymbol = item.getPrice().substring(0, 1);
+ }
+ <SPAN class="code-keyword">for</SPAN> (Item item : cart.values()) {
+ total += <SPAN class="code-object">Double</SPAN>.valueOf(item.getPrice().substring(1));
+ }
+ <SPAN class="code-keyword">return</SPAN> currencySymbol + <SPAN class="code-object">String</SPAN>.valueOf(total);
+ }
+}
+</PRE>
+</DIV></DIV>
+<P><B>Note:</B> Since the Tuscany conversational support is not ready yet the cart is realized through a hack.<BR>
+The cart field is defined as static.</P>
+
+<P>After completing these steps the content of the &quot;store&quot; project will look as follows.</P>
+
+<P><SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/store_project_2.png" style="border: 0px solid black"></SPAN><BR>
+&nbsp;</P>
+
+<H3><A name="GettingStartedwithTuscany-%7B%7DStore%7B%7D"></A><B><EM>Store</EM></B></H3>
+
+<P>In this step you create the user facing Store service that will run in a Web browser and provide the<BR>
+user interface to the other services you created.</P>
+
+<P>Select the &quot;ufservices&quot; package. <B><EM>Right click</EM></B> to get the context menu, select <B><EM>New</EM></B>, and then <B><EM>File</EM></B>. In<BR>
+the <B><EM>New File</EM></B> dialog enter &quot;store.html&quot; for the <B><EM>File name</EM></B>, and then select <B><EM>Finish</EM></B> to complete the<BR>
+dialog.</P>
+
+<P>The Text editor will open on the new created html file. Replace the content of the editor by <B><EM>copy-paste</EM></B><BR>
+of the following html snippet.</P>
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+&lt;html&gt;
+&lt;head&gt;
+&lt;title&gt;Store&lt;/title&gt;
+
+&lt;script type=<SPAN class="code-quote">&quot;text/javascript&quot;</SPAN> src=<SPAN class="code-quote">&quot;store.js&quot;</SPAN>&gt;&lt;/script&gt;
+
+&lt;script language=<SPAN class="code-quote">&quot;JavaScript&quot;</SPAN>&gt;
+
+ <SPAN class="code-comment">//@Reference
+</SPAN> <SPAN class="code-keyword">var</SPAN> catalog = <SPAN class="code-keyword">new</SPAN> tuscany.sca.Reference(<SPAN class="code-quote">&quot;catalog&quot;</SPAN>);
+
+ <SPAN class="code-comment">//@Reference
+</SPAN> <SPAN class="code-keyword">var</SPAN> shoppingCart = <SPAN class="code-keyword">new</SPAN> tuscany.sca.Reference(<SPAN class="code-quote">&quot;shoppingCart&quot;</SPAN>);
+
+ <SPAN class="code-comment">//@Reference
+</SPAN> <SPAN class="code-keyword">var</SPAN> shoppingTotal = <SPAN class="code-keyword">new</SPAN> tuscany.sca.Reference(<SPAN class="code-quote">&quot;shoppingTotal&quot;</SPAN>);
+
+ <SPAN class="code-keyword">var</SPAN> catalogItems;
+
+ function catalog_getResponse(items) {
+ <SPAN class="code-keyword">var</SPAN> catalog = &quot;&quot;;
+ <SPAN class="code-keyword">for</SPAN> (<SPAN class="code-keyword">var</SPAN> i=0; i&lt;items.length; i++) {
+ <SPAN class="code-keyword">var</SPAN> item = items[i].name + ' - ' + items[i].price;
+ catalog += '&lt;input name=<SPAN class="code-quote">&quot;items&quot;</SPAN> type=<SPAN class="code-quote">&quot;checkbox&quot;</SPAN> value=&quot;' +
+ item + '&quot;&gt;' + item + ' &lt;br&gt;';
+ }
+ document.getElementById('catalog').innerHTML=catalog;
+ catalogItems = items;
+ }
+
+ function shoppingCart_getResponse(feed) {
+ <SPAN class="code-keyword">if</SPAN> (feed != <SPAN class="code-keyword">null</SPAN>) {
+ <SPAN class="code-keyword">var</SPAN> entries = feed.getElementsByTagName(<SPAN class="code-quote">&quot;entry&quot;</SPAN>);
+ <SPAN class="code-keyword">var</SPAN> list = &quot;&quot;;
+ <SPAN class="code-keyword">for</SPAN> (<SPAN class="code-keyword">var</SPAN> i=0; i&lt;entries.length; i++) {
+ <SPAN class="code-keyword">var</SPAN> content = entries[i].getElementsByTagName(<SPAN class="code-quote">&quot;content&quot;</SPAN>)[0];
+ <SPAN class="code-keyword">var</SPAN> name = content.getElementsByTagName(<SPAN class="code-quote">&quot;name&quot;</SPAN>)[0].firstChild.nodeValue;
+ <SPAN class="code-keyword">var</SPAN> price = content.getElementsByTagName(<SPAN class="code-quote">&quot;price&quot;</SPAN>)[0].firstChild.nodeValue;
+ list += name + ' - ' + price + ' &lt;br&gt;';
+ }
+ document.getElementById(<SPAN class="code-quote">&quot;shoppingCart&quot;</SPAN>).innerHTML = list;
+
+ <SPAN class="code-keyword">if</SPAN> (entries.length != 0) {
+ shoppingTotal.getTotal(shoppingTotal_getTotalResponse);
+ }
+ }
+ }
+
+ function shoppingTotal_getTotalResponse(total) {
+ document.getElementById('total').innerHTML = total;
+ }
+
+ function shoppingCart_postResponse(entry) {
+ shoppingCart.get(&quot;&quot;, shoppingCart_getResponse);
+ }
+
+ function addToCart() {
+ <SPAN class="code-keyword">var</SPAN> items = document.catalogForm.items;
+ <SPAN class="code-keyword">var</SPAN> j = 0;
+ <SPAN class="code-keyword">for</SPAN> (<SPAN class="code-keyword">var</SPAN> i=0; i&lt;items.length; i++)
+ <SPAN class="code-keyword">if</SPAN> (items[i].checked) {
+ <SPAN class="code-keyword">var</SPAN> entry = '&lt;entry xmlns=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//www.w3.org/2005/Atom&quot;</SPAN>&gt;&lt;title&gt;item&lt;/title&gt;&lt;content type=<SPAN class="code-quote">&quot;text/xml&quot;</SPAN>&gt;' +
+</SPAN> '&lt;Item xmlns=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//services/&quot;</SPAN>&gt;' +
+</SPAN> '&lt;name xmlns=<SPAN class="code-quote">&quot;&quot;&gt;' + catalogItems[i].name + '&lt;/name&gt;' + '&lt;price xmlns=&quot;</SPAN>&quot;&gt;' + catalogItems[i].price + '&lt;/price&gt;' +
+ '&lt;/Item&gt;' + '&lt;/content&gt;&lt;/entry&gt;';
+ shoppingCart.post(entry, shoppingCart_postResponse);
+ items[i].checked = <SPAN class="code-keyword">false</SPAN>;
+ }
+ }
+ function checkoutCart() {
+ document.getElementById('store').innerHTML='&lt;h2&gt;' +
+ 'Thanks <SPAN class="code-keyword">for</SPAN> Shopping With Us!&lt;/h2&gt;'+
+ '&lt;h2&gt;Your Order&lt;/h2&gt;'+
+ '&lt;form name=<SPAN class="code-quote">&quot;orderForm&quot;</SPAN>&gt;'+
+ document.getElementById('shoppingCart').innerHTML+
+ '&lt;br&gt;'+
+ document.getElementById('total').innerHTML+
+ '&lt;br&gt;'+
+
+ '&lt;br&gt;'+
+ '&lt;input type=<SPAN class="code-quote">&quot;submit&quot;</SPAN> value=<SPAN class="code-quote">&quot;Continue Shopping&quot;</SPAN>&gt;'+
+ '&lt;/form&gt;';
+ shoppingCart.del(&quot;&quot;, <SPAN class="code-keyword">null</SPAN>);
+ }
+ function deleteCart() {
+ shoppingCart.del(&quot;&quot;, <SPAN class="code-keyword">null</SPAN>);
+ document.getElementById('shoppingCart').innerHTML = &quot;&quot;;
+ document.getElementById('total').innerHTML = &quot;&quot;;
+ }
+
+ function init() {
+ catalog.get(catalog_getResponse);
+ shoppingCart.get(&quot;&quot;, shoppingCart_getResponse);
+ }
+
+&lt;/script&gt;
+
+&lt;/head&gt;
+
+&lt;body onload=<SPAN class="code-quote">&quot;init()&quot;</SPAN>&gt;
+&lt;h1&gt;Store&lt;/h1&gt;
+ &lt;div id=<SPAN class="code-quote">&quot;store&quot;</SPAN>&gt;
+ &lt;h2&gt;Catalog&lt;/h2&gt;
+ &lt;form name=<SPAN class="code-quote">&quot;catalogForm&quot;</SPAN>&gt;
+ &lt;div id=<SPAN class="code-quote">&quot;catalog&quot;</SPAN> &gt;&lt;/div&gt;
+ &lt;br&gt;
+ &lt;input type=<SPAN class="code-quote">&quot;button&quot;</SPAN> onClick=<SPAN class="code-quote">&quot;addToCart()&quot;</SPAN> value=<SPAN class="code-quote">&quot;Add to Cart&quot;</SPAN>&gt;
+ &lt;/form&gt;
+
+ &lt;br&gt;
+
+ &lt;h2&gt;Your Shopping Cart&lt;/h2&gt;
+ &lt;form name=<SPAN class="code-quote">&quot;shoppingCartForm&quot;</SPAN>&gt;
+ &lt;div id=<SPAN class="code-quote">&quot;shoppingCart&quot;</SPAN>&gt;&lt;/div&gt;
+ &lt;br&gt;
+ &lt;div id=<SPAN class="code-quote">&quot;total&quot;</SPAN>&gt;&lt;/div&gt;
+ &lt;br&gt;
+ &lt;input type=<SPAN class="code-quote">&quot;button&quot;</SPAN> onClick=<SPAN class="code-quote">&quot;checkoutCart()&quot;</SPAN> value=<SPAN class="code-quote">&quot;Checkout&quot;</SPAN>&gt;
+ &lt;input type=<SPAN class="code-quote">&quot;button&quot;</SPAN> onClick=<SPAN class="code-quote">&quot;deleteCart()&quot;</SPAN> value=<SPAN class="code-quote">&quot;Empty&quot;</SPAN>&gt;
+ &lt;a href=<SPAN class="code-quote">&quot;../ShoppingCart/Cart/&quot;</SPAN>&gt;(feed)&lt;/a&gt;
+ &lt;/form&gt;
+ &lt;/div&gt;
+&lt;/body&gt;
+&lt;/html&gt;
+</PRE>
+</DIV></DIV>
+<P>After completing these steps the content of the &quot;store&quot; project will look as follows.</P>
+
+<P>&nbsp;<SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/store_project_3.jpg" style="border: 0px solid black"></SPAN></P>
+
+<H2><A name="GettingStartedwithTuscany-ComposeServices"></A>Compose Services</H2>
+
+<P>Now that you have all the required service implementations you compose them together to provide<BR>
+the store composite service. The composition is stored in a .composite file.</P>
+
+<P>Select the &quot;src&quot; folder of the &quot;store&quot; project. <B><EM>Right click</EM></B> to get the context menu, select <B><EM>New</EM></B>, and<BR>
+then <B><EM>File</EM></B>. In the <B><EM>New File</EM></B> dialog enter &quot;store.composite&quot; for the <B><EM>File name</EM></B>, and then select <B><EM>Finish</EM></B><BR>
+to complete the dialog.</P>
+
+<P>The Text editor will open on the new created composite file. Replace the content of the editor by<BR>
+<B><EM>copy-paste</EM></B> of the following composite snippet.</P>
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+&lt;?xml version=<SPAN class="code-quote">&quot;1.0&quot;</SPAN> encoding=<SPAN class="code-quote">&quot;UTF-8&quot;</SPAN>?&gt;
+&lt;composite xmlns=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//www.osoa.org/xmlns/sca/1.0&quot;</SPAN>
+</SPAN> xmlns:t=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//tuscany.apache.org/xmlns/sca/1.0&quot;</SPAN>
+</SPAN> xmlns:s=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//store&quot;</SPAN>
+</SPAN> targetNamespace=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//store&quot;</SPAN>
+</SPAN> name=<SPAN class="code-quote">&quot;store&quot;</SPAN>&gt;
+
+ &lt;component name=<SPAN class="code-quote">&quot;store&quot;</SPAN>&gt;
+ &lt;t:implementation.widget location=<SPAN class="code-quote">&quot;ufservices/store.html&quot;</SPAN> /&gt;
+ &lt;service name=<SPAN class="code-quote">&quot;Widget&quot;</SPAN>&gt;
+ &lt;t:binding.http uri=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//localhost:8080/store&quot;</SPAN> /&gt;
+</SPAN> &lt;/service&gt;
+ &lt;reference name=<SPAN class="code-quote">&quot;catalog&quot;</SPAN> target=<SPAN class="code-quote">&quot;Catalog&quot;</SPAN>&gt;
+ &lt;t:binding.jsonrpc /&gt;
+ &lt;/reference&gt;
+ &lt;reference name=<SPAN class="code-quote">&quot;shoppingCart&quot;</SPAN> target=<SPAN class="code-quote">&quot;ShoppingCart/Cart&quot;</SPAN>&gt;
+ &lt;t:binding.atom /&gt;
+ &lt;/reference&gt;
+ &lt;reference name=<SPAN class="code-quote">&quot;shoppingTotal&quot;</SPAN> target=<SPAN class="code-quote">&quot;ShoppingCart/Total&quot;</SPAN>&gt;
+ &lt;t:binding.jsonrpc /&gt;
+ &lt;/reference&gt;
+ &lt;/component&gt;
+
+ &lt;component name=<SPAN class="code-quote">&quot;Catalog&quot;</SPAN>&gt;
+ &lt;implementation.java class=<SPAN class="code-quote">&quot;services.CatalogImpl&quot;</SPAN> /&gt;
+ &lt;property name=<SPAN class="code-quote">&quot;currencyCode&quot;</SPAN>&gt;USD&lt;/property&gt;
+ &lt;service name=<SPAN class="code-quote">&quot;Catalog&quot;</SPAN>&gt;
+ &lt;t:binding.jsonrpc uri=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//localhost:8080/Catalog&quot;</SPAN>/&gt;
+</SPAN> &lt;/service&gt;
+ &lt;reference name=<SPAN class="code-quote">&quot;currencyConverter&quot;</SPAN> target=<SPAN class="code-quote">&quot;CurrencyConverter&quot;</SPAN> /&gt;
+ &lt;/component&gt;
+
+ &lt;component name=<SPAN class="code-quote">&quot;ShoppingCart&quot;</SPAN>&gt;
+ &lt;implementation.java class=<SPAN class="code-quote">&quot;services.ShoppingCartImpl&quot;</SPAN> /&gt;
+ &lt;service name=<SPAN class="code-quote">&quot;Cart&quot;</SPAN>&gt;
+ &lt;t:binding.atom uri=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//localhost:8080/ShoppingCart/Cart&quot;</SPAN> /&gt;
+</SPAN> &lt;/service&gt;
+ &lt;service name=<SPAN class="code-quote">&quot;Total&quot;</SPAN>&gt;
+ &lt;t:binding.jsonrpc uri=<SPAN class="code-quote">&quot;http:<SPAN class="code-comment">//localhost:8080/Total&quot;</SPAN>/&gt;
+</SPAN> &lt;/service&gt;
+ &lt;/component&gt;
+
+ &lt;component name=<SPAN class="code-quote">&quot;CurrencyConverter&quot;</SPAN>&gt;
+ &lt;implementation.java class=<SPAN class="code-quote">&quot;services.CurrencyConverterImpl&quot;</SPAN> /&gt;
+ &lt;/component&gt;
+&lt;/composite&gt;
+</PRE>
+</DIV></DIV>
+<P>After completing these steps the content of the &quot;store&quot; project will look as follows.</P>
+
+<P><SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/store_project_4.jpg" style="border: 0px solid black"></SPAN><BR>
+&nbsp;</P>
+
+<H2><A name="GettingStartedwithTuscany-LaunchServices"></A>Launch Services</H2>
+
+<P>In this step you create the code to launch the Tuscany runtime with the new store composite service you created.</P>
+
+<P>Select the &quot;store&quot; project and click on the <B><EM>New Java Package</EM></B> button <SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/new_java_pkg_btn.png" style="border: 0px solid black"></SPAN> in the toolbar to start the package creation dialog. Use the dialog to create a new package named &quot;launch&quot;.</P>
+
+<P>Select the &quot;launch&quot; package. Select the <B><EM>New Java Class</EM></B> button&nbsp; <SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/class_btn.png" style="border: 0px solid black"></SPAN>&nbsp;. In the dialog enter &quot;Launch&quot; as the Name of the class, check the checkbox for creating a main method stub, and then select Finish to complete the dialog.</P>
+
+<P>The Java editor will open on the new created Java class. Replace the content of the editor by copy-paste of the following Java class code snippet.</P>
+
+<DIV class="code panel" style="border-width: 1px;"><DIV class="codeContent panelContent">
+<PRE class="code-java">
+
+<SPAN class="code-keyword">package</SPAN> launch;
+
+<SPAN class="code-keyword">import</SPAN> org.apache.tuscany.sca.host.embedded.SCADomain;
+
+<SPAN class="code-keyword">public</SPAN> class Launch {
+ <SPAN class="code-keyword">public</SPAN> <SPAN class="code-keyword">static</SPAN> void main(<SPAN class="code-object">String</SPAN>[] args) <SPAN class="code-keyword">throws</SPAN> Exception {
+ <SPAN class="code-object">System</SPAN>.out.println(<SPAN class="code-quote">&quot;Starting ...&quot;</SPAN>);
+ SCADomain scaDomain = SCADomain.newInstance(<SPAN class="code-quote">&quot;store.composite&quot;</SPAN>);
+ <SPAN class="code-object">System</SPAN>.out.println(<SPAN class="code-quote">&quot;store.composite ready <SPAN class="code-keyword">for</SPAN> big business !!!&quot;</SPAN>);
+ <SPAN class="code-object">System</SPAN>.in.read();
+ <SPAN class="code-object">System</SPAN>.out.println(<SPAN class="code-quote">&quot;Stopping ...&quot;</SPAN>);
+ scaDomain.close();
+ <SPAN class="code-object">System</SPAN>.out.println();
+ }
+}
+</PRE>
+</DIV></DIV>
+
+
+<P>Congratulations you completed your 1st composite service applications, now its time to take it into<BR>
+action.</P>
+
+<H2><A name="GettingStartedwithTuscany-UseServices"></A>Use Services</H2>
+
+<P>In this step you launch and use the store composite service application you created.</P>
+
+<P>First select the &quot;Launch&quot; class in the &quot;launch&quot; package of your &quot;store&quot; project. <B><EM>Right click</EM></B> to get the<BR>
+context menu, select <B><EM>Run As</EM></B>, and then <B><EM>Java application</EM></B>. The Tuscany runtime will start up adding<BR>
+the store composition to its domain.</P>
+
+<P>The Eclipse console will show the following messages.</P>
+
+<P>&nbsp;<SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/eclipse_console.png" style="border: 0px solid black"></SPAN></P>
+
+<P>&nbsp;Next Launch your Web browser and enter the following address:</P>
+
+<P><A href="http://localhost:8080/store/store.html" class="external-link" rel="nofollow">http://localhost:8080/store/store.html</A>&nbsp;</P>
+
+<P>&nbsp;You get to the Store user facing service of the composite service application.</P>
+
+<P><SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/store_page.png" style="border: 0px solid black"></SPAN></P>
+
+<P>You can select items from the Catalog and add them to your Shopping Cart.</P>
+
+<P><B>Note:</B> When adding items for the first time you will be asked for <B><EM>userid and password</EM></B> by the<BR>
+browser. Enter &quot;admin&quot; for both.</P>
+
+<P> <SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/store_page_1.png" style="border: 0px solid black"></SPAN></P>
+
+<P>Since the ShoppingCart service is bound using the ATOM binding, you can also look at the<BR>
+shopping card content in ATOM feed form by clicking on the feed icon <SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/atom_feed.png" style="border: 0px solid black"></SPAN>. You get the browsers default rendering for ATOM feeds.</P>
+
+<P>&nbsp;<SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/atom_feeds_page.png" style="border: 0px solid black"></SPAN></P>
+
+<P>&nbsp;Use the browser back button to get back to the Store page.</P>
+
+<P><SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/store_page_2.png" style="border: 0px solid black"></SPAN></P>
+
+<P>And then you can Checkout to complete your order.</P>
+
+<P><SPAN class="image-wrap" style=""><IMG src="getting-started-with-tuscany.data/store_page_3.png" style="border: 0px solid black"></SPAN></P>
+
+<P>Congratulations, you have created an accessible, flexible, reusable Store application using Tuscany SCA technology.</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>