You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@tuscany.apache.org by js...@apache.org on 2009/09/14 07:55:12 UTC

svn commit: r814480 - /tuscany/cpp/sca/samples/store/

Author: jsdelfino
Date: Mon Sep 14 05:55:11 2009
New Revision: 814480

URL: http://svn.apache.org/viewvc?rev=814480&view=rev
Log:
Starting to implement the store sample in C++. Assembling the components manually in code for now.

Added:
    tuscany/cpp/sca/samples/store/
    tuscany/cpp/sca/samples/store/Makefile.am
    tuscany/cpp/sca/samples/store/cart.hpp
    tuscany/cpp/sca/samples/store/catalog.hpp
    tuscany/cpp/sca/samples/store/catalogs.composite
    tuscany/cpp/sca/samples/store/currency-composite.hpp
    tuscany/cpp/sca/samples/store/currency.composite
    tuscany/cpp/sca/samples/store/currency.hpp
    tuscany/cpp/sca/samples/store/item.hpp
    tuscany/cpp/sca/samples/store/store-composite.hpp
    tuscany/cpp/sca/samples/store/store-solution.hpp
    tuscany/cpp/sca/samples/store/store-test.cpp
    tuscany/cpp/sca/samples/store/store-ui.hpp
    tuscany/cpp/sca/samples/store/store.composite

Added: tuscany/cpp/sca/samples/store/Makefile.am
URL: http://svn.apache.org/viewvc/tuscany/cpp/sca/samples/store/Makefile.am?rev=814480&view=auto
==============================================================================
--- tuscany/cpp/sca/samples/store/Makefile.am (added)
+++ tuscany/cpp/sca/samples/store/Makefile.am Mon Sep 14 05:55:11 2009
@@ -0,0 +1,41 @@
+#  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.
+
+deploydir=$(prefix)/store/deploy
+EXTRA_DIST = *.composite
+deploy_DATA = *.composite
+
+storedir=$(deploydir)
+
+store_PROGRAMS = store-test
+
+store_test_SOURCES = \
+store-test.cpp
+
+store_test_LDADD = \
+-L${TUSCANY_SCACPP}/lib \
+  -ltuscany_sca \
+-L${TUSCANY_SCACPP}/extensions/cpp/lib \
+  -ltuscany_sca_cpp \
+-L${TUSCANY_SDOCPP}/lib \
+  -ltuscany_sdo
+	
+INCLUDES = \
+-I$(TUSCANY_SCACPP)/extensions/cpp/include \
+-I${TUSCANY_SCACPP}/include \
+-I${TUSCANY_SDOCPP}/include \
+-I.

Added: tuscany/cpp/sca/samples/store/cart.hpp
URL: http://svn.apache.org/viewvc/tuscany/cpp/sca/samples/store/cart.hpp?rev=814480&view=auto
==============================================================================
--- tuscany/cpp/sca/samples/store/cart.hpp (added)
+++ tuscany/cpp/sca/samples/store/cart.hpp Mon Sep 14 05:55:11 2009
@@ -0,0 +1,75 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef SCA_CART_HPP_
+#define SCA_CART_HPP_
+
+#include <string.h>
+#include "tuscany/function.hpp"
+#include "tuscany/list.hpp"
+#include "currency.hpp"
+#include "item.hpp"
+#include "catalog.hpp"
+
+namespace tuscany
+{
+
+const double accum(const double total, const Item& item) {
+    return total + item.price;
+}
+
+class ShoppingCart {
+public:
+    virtual const list<Item> getAll() const = 0;
+
+    virtual const bool post(const Item& item) = 0;
+
+    virtual const bool deleteAll() = 0;
+
+    virtual const double getTotal() const = 0;
+};
+
+class ShoppingCartImpl : public ShoppingCart {
+public:
+    list<Item> cart;
+
+    virtual const list<Item> getAll() const {
+        return cart;
+    }
+
+    virtual const bool post(const Item& item) {
+        cart = cons(item, cart);
+        return true;
+    }
+
+    virtual const bool deleteAll() {
+        cart = list<Item>();
+        return true;
+    }
+
+    virtual const double getTotal() const {
+        lambda<double(double, Item)> a(accum);
+        return reduce(a, 0.0, cart);
+    }
+};
+
+}
+#endif /* SCA_CART_HPP_ */

Added: tuscany/cpp/sca/samples/store/catalog.hpp
URL: http://svn.apache.org/viewvc/tuscany/cpp/sca/samples/store/catalog.hpp?rev=814480&view=auto
==============================================================================
--- tuscany/cpp/sca/samples/store/catalog.hpp (added)
+++ tuscany/cpp/sca/samples/store/catalog.hpp Mon Sep 14 05:55:11 2009
@@ -0,0 +1,65 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef SCA_CATALOG_HPP_
+#define SCA_CATALOG_HPP_
+
+#include <string.h>
+#include "tuscany/list.hpp"
+#include "currency.hpp"
+#include "item.hpp"
+
+namespace tuscany
+{
+
+class Catalog {
+public:
+
+    virtual const double convert(const double price) const = 0;
+
+    virtual const list<Item> get() const = 0;
+};
+
+class CatalogImpl : public Catalog {
+public:
+
+    const string currencyCode;
+    const CurrencyConverter& currencyConverter;
+
+    CatalogImpl(const CurrencyConverter& currencyConverter) :
+        currencyCode("USD"), currencyConverter(currencyConverter) {
+    }
+
+    virtual const double convert(const double price) const {
+        return currencyConverter.convert("USD", currencyCode, price);
+    }
+
+    virtual const list<Item> get() const {
+        const string currencySymbol = currencyConverter.getSymbol(currencyCode);
+        return makeList(
+                Item("Apple", currencyCode, currencySymbol, convert(2.99)),
+                Item("Orange", currencyCode, currencySymbol, convert(3.55)),
+                Item("Pear", currencyCode, currencySymbol, convert(1.55)));
+    }
+};
+
+}
+#endif /* SCA_CATALOG_HPP_ */

Added: tuscany/cpp/sca/samples/store/catalogs.composite
URL: http://svn.apache.org/viewvc/tuscany/cpp/sca/samples/store/catalogs.composite?rev=814480&view=auto
==============================================================================
--- tuscany/cpp/sca/samples/store/catalogs.composite (added)
+++ tuscany/cpp/sca/samples/store/catalogs.composite Mon Sep 14 05:55:11 2009
@@ -0,0 +1,43 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.    
+-->
+<composite	xmlns="http://www.osoa.org/xmlns/sca/1.0"
+		xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
+		targetNamespace="http://services"			
+		name="catalogs">
+		
+	<component name="FruitsCatalogWebService">
+		<implementation.java class="services.FruitsCatalogImpl"/>
+		<service name="Catalog">
+			<binding.ws/>
+		</service> 
+		<property name="currencyCode">USD</property>
+		<reference name="currencyConverter" target="CurrencyConverterWebService">
+			<binding.ws/>
+		</reference>
+	</component> 
+ 	
+	<component name="VegetablesCatalogWebService">
+		<implementation.java class="services.VegetablesCatalogImpl"/>
+		<service name="Catalog">
+			<binding.ws/>
+		</service> 
+	</component>
+ 	
+</composite>

Added: tuscany/cpp/sca/samples/store/currency-composite.hpp
URL: http://svn.apache.org/viewvc/tuscany/cpp/sca/samples/store/currency-composite.hpp?rev=814480&view=auto
==============================================================================
--- tuscany/cpp/sca/samples/store/currency-composite.hpp (added)
+++ tuscany/cpp/sca/samples/store/currency-composite.hpp Mon Sep 14 05:55:11 2009
@@ -0,0 +1,52 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef SCA_CURRENCYCOMPOSITE_HPP_
+#define SCA_CURRENCYCOMPOSITE_HPP_
+
+#include <string.h>
+#include <math.h>
+#include "currency.hpp"
+
+namespace tuscany
+{
+
+class Currency : public CurrencyConverter {
+};
+
+class CurrencyImpl : public Currency {
+public:
+    const CurrencyConverterImpl currencyConverter;
+
+    CurrencyImpl() : currencyConverter(CurrencyConverterImpl()) {
+    }
+
+    virtual const double convert(const string& fromCurrencyCode, const string& toCurrencyCode, const double amount) const {
+        return currencyConverter.convert(fromCurrencyCode, toCurrencyCode, amount);
+    }
+
+    virtual const string getSymbol(const string& currencyCode) const {
+        return currencyConverter.getSymbol(currencyCode);
+    }
+};
+
+}
+#endif /* SCA_CURRENCYCOMPOSITE_HPP_ */

Added: tuscany/cpp/sca/samples/store/currency.composite
URL: http://svn.apache.org/viewvc/tuscany/cpp/sca/samples/store/currency.composite?rev=814480&view=auto
==============================================================================
--- tuscany/cpp/sca/samples/store/currency.composite (added)
+++ tuscany/cpp/sca/samples/store/currency.composite Mon Sep 14 05:55:11 2009
@@ -0,0 +1,32 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.    
+-->
+<composite xmlns="http://www.osoa.org/xmlns/sca/1.0"
+		xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
+		targetNamespace="http://services"	
+		name="currency">
+		
+	<component name="CurrencyConverterWebService">
+		<implementation.java class="services.CurrencyConverterImpl"/>
+		<service name="CurrencyConverter">
+			<binding.ws/>
+		</service>
+	</component>
+
+</composite>

Added: tuscany/cpp/sca/samples/store/currency.hpp
URL: http://svn.apache.org/viewvc/tuscany/cpp/sca/samples/store/currency.hpp?rev=814480&view=auto
==============================================================================
--- tuscany/cpp/sca/samples/store/currency.hpp (added)
+++ tuscany/cpp/sca/samples/store/currency.hpp Mon Sep 14 05:55:11 2009
@@ -0,0 +1,62 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef SCA_CURRENCY_HPP_
+#define SCA_CURRENCY_HPP_
+
+#include <string.h>
+#include <math.h>
+
+using std::string;
+
+namespace tuscany
+{
+
+class CurrencyConverter {
+public:
+
+    virtual const double convert(const string& fromCurrencyCode, const string& toCurrencyCode, const double amount) const = 0;
+
+    virtual const string getSymbol(const string& currencyCode) const = 0;
+};
+
+class CurrencyConverterImpl : public CurrencyConverter {
+public:
+
+    virtual const double convert(const string& fromCurrencyCode, const string& toCurrencyCode, const double amount) const {
+        if(toCurrencyCode == "USD")
+            return amount;
+        if(toCurrencyCode == "EUR")
+            return round(amount * 0.7256 * 100) / 100;
+        return amount;
+    }
+
+    virtual const string getSymbol(const string& currencyCode) const {
+        if(currencyCode == "USD")
+            return "$";
+        if(currencyCode == "EUR")
+            return "E";
+        return "?";
+    }
+};
+
+}
+#endif /* SCA_CURRENCY_HPP_ */

Added: tuscany/cpp/sca/samples/store/item.hpp
URL: http://svn.apache.org/viewvc/tuscany/cpp/sca/samples/store/item.hpp?rev=814480&view=auto
==============================================================================
--- tuscany/cpp/sca/samples/store/item.hpp (added)
+++ tuscany/cpp/sca/samples/store/item.hpp Mon Sep 14 05:55:11 2009
@@ -0,0 +1,47 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef SCA_ITEM_HPP_
+#define SCA_ITEM_HPP_
+
+#include <string.h>
+
+namespace tuscany
+{
+
+class Item {
+public:
+    string name;
+    double price;
+    string currencyCode;
+    string currencySymbol;
+
+    Item() {
+    }
+
+    Item(const string& name, const string& currencyCode, const string& currencySymbol, const double price) :
+        name(name), price(price), currencyCode(currencyCode), currencySymbol(currencySymbol) {
+    }
+
+};
+
+}
+#endif /* SCA_ITEM_HPP_ */

Added: tuscany/cpp/sca/samples/store/store-composite.hpp
URL: http://svn.apache.org/viewvc/tuscany/cpp/sca/samples/store/store-composite.hpp?rev=814480&view=auto
==============================================================================
--- tuscany/cpp/sca/samples/store/store-composite.hpp (added)
+++ tuscany/cpp/sca/samples/store/store-composite.hpp Mon Sep 14 05:55:11 2009
@@ -0,0 +1,69 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef SCA_STORECOMPOSITE_HPP_
+#define SCA_STORECOMPOSITE_HPP_
+
+#include <string.h>
+#include "tuscany/list.hpp"
+#include "currency.hpp"
+#include "currency-composite.hpp"
+#include "item.hpp"
+#include "catalog.hpp"
+#include "cart.hpp"
+#include "store-ui.hpp"
+
+namespace tuscany
+{
+
+class Store : public StoreUI {
+};
+
+class StoreImpl : public Store {
+public:
+    const CatalogImpl catalog;
+    ShoppingCartImpl cart;
+    StoreUIImpl storeUI;
+
+    StoreImpl(const Currency& currency) :
+        catalog(CatalogImpl(currency)), cart(ShoppingCartImpl()), storeUI(StoreUIImpl(catalog, cart)) {
+    }
+
+    virtual const list<Item> getCatalog() const {
+        return storeUI.getCatalog();
+    }
+
+    virtual const list<Item> getCart() const {
+        return storeUI.getCart();
+    }
+
+    virtual const double getTotal() const {
+        return storeUI.getTotal();
+    }
+
+    virtual const bool post(const Item& item) {
+        return storeUI.post(item);
+    }
+
+};
+
+}
+#endif /* SCA_STORECOMPOSITE_HPP_ */

Added: tuscany/cpp/sca/samples/store/store-solution.hpp
URL: http://svn.apache.org/viewvc/tuscany/cpp/sca/samples/store/store-solution.hpp?rev=814480&view=auto
==============================================================================
--- tuscany/cpp/sca/samples/store/store-solution.hpp (added)
+++ tuscany/cpp/sca/samples/store/store-solution.hpp Mon Sep 14 05:55:11 2009
@@ -0,0 +1,63 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef SCA_STORESOLUTION_HPP_
+#define SCA_STORESOLUTION_HPP_
+
+#include <string.h>
+#include "tuscany/list.hpp"
+#include "store-composite.hpp"
+#include "currency-composite.hpp"
+
+namespace tuscany
+{
+
+class StoreSolution : public Store {
+};
+
+class StoreSolutionImpl : public StoreSolution {
+public:
+    const CurrencyImpl currency;
+    StoreImpl store;
+
+    StoreSolutionImpl() :
+        currency(CurrencyImpl()), store(StoreImpl(currency)) {
+    }
+
+    virtual const list<Item> getCatalog() const {
+        return store.getCatalog();
+    }
+
+    virtual const list<Item> getCart() const {
+        return store.getCart();
+    }
+
+    virtual const double getTotal() const {
+        return store.getTotal();
+    }
+
+    virtual const bool post(const Item& item) {
+        return store.post(item);
+    }
+};
+
+}
+#endif /* SCA_STORESOLUTION_HPP_ */

Added: tuscany/cpp/sca/samples/store/store-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/cpp/sca/samples/store/store-test.cpp?rev=814480&view=auto
==============================================================================
--- tuscany/cpp/sca/samples/store/store-test.cpp (added)
+++ tuscany/cpp/sca/samples/store/store-test.cpp Mon Sep 14 05:55:11 2009
@@ -0,0 +1,58 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+/**
+ * Store Test case.
+ */
+
+#include <iostream>
+#include <string>
+#include <assert.h>
+#include "store-solution.hpp"
+
+using std::cout;
+using std::endl;
+
+namespace tuscany
+{
+
+bool testComponentAssembly() {
+    StoreSolutionImpl store = StoreSolutionImpl();
+    assert(length(store.getCatalog()) == 3);
+    assert(store.post(car(store.getCatalog())) == true);
+    assert(store.post(cadr(store.getCatalog())) == true);
+    assert(length(store.getCart()) == 2);
+    assert(store.getTotal() == 6.54);
+    return true;
+}
+
+}
+
+int main() {
+    using namespace tuscany;
+
+    cout << "Testing..." << endl;
+
+    testComponentAssembly();
+    cout << "OK" << endl;
+
+    return 0;
+}

Added: tuscany/cpp/sca/samples/store/store-ui.hpp
URL: http://svn.apache.org/viewvc/tuscany/cpp/sca/samples/store/store-ui.hpp?rev=814480&view=auto
==============================================================================
--- tuscany/cpp/sca/samples/store/store-ui.hpp (added)
+++ tuscany/cpp/sca/samples/store/store-ui.hpp Mon Sep 14 05:55:11 2009
@@ -0,0 +1,73 @@
+/*
+ * 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.
+ */
+
+/* $Rev$ $Date$ */
+
+#ifndef SCA_STOREUI_HPP_
+#define SCA_STOREUI_HPP_
+
+#include <string.h>
+#include "tuscany/list.hpp"
+#include "currency.hpp"
+#include "item.hpp"
+#include "catalog.hpp"
+#include "cart.hpp"
+
+namespace tuscany
+{
+
+class StoreUI {
+public:
+
+    virtual const list<Item> getCatalog() const =0;
+
+    virtual const list<Item> getCart() const = 0;
+
+    virtual const double getTotal() const =0;
+
+    virtual const bool post(const Item& item) = 0;
+};
+
+class StoreUIImpl : public StoreUI {
+public:
+    const Catalog& catalog;
+    ShoppingCart& cart;
+
+    StoreUIImpl(const Catalog& catalog, ShoppingCart& cart) : catalog(catalog), cart(cart) {
+    }
+
+    virtual const list<Item> getCatalog() const {
+        return catalog.get();
+    }
+
+    virtual const list<Item> getCart() const {
+        return cart.getAll();
+    }
+
+    virtual const double getTotal() const {
+        return cart.getTotal();
+    }
+
+    virtual const bool post(const Item& item) {
+        return cart.post(item);
+    }
+};
+
+}
+#endif /* SCA_STOREUI_HPP_ */

Added: tuscany/cpp/sca/samples/store/store.composite
URL: http://svn.apache.org/viewvc/tuscany/cpp/sca/samples/store/store.composite?rev=814480&view=auto
==============================================================================
--- tuscany/cpp/sca/samples/store/store.composite (added)
+++ tuscany/cpp/sca/samples/store/store.composite Mon Sep 14 05:55:11 2009
@@ -0,0 +1,64 @@
+<?xml version="1.0" encoding="UTF-8"?>
+<!--
+ * 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.    
+-->
+<composite	xmlns="http://www.osoa.org/xmlns/sca/1.0"
+		xmlns:t="http://tuscany.apache.org/xmlns/sca/1.0"
+		targetNamespace="http://store"
+		name="store">
+		
+    <component name="Store">
+        <t:implementation.widget location="uiservices/store.html"/>
+        <service name="Widget">
+        	<t:binding.http uri="/ui"/>
+        </service>
+		<reference name="catalog" target="StoreCatalog">
+		 	<t:binding.jsonrpc/>
+		 </reference>
+		 <reference name="shoppingCart" target="StoreShoppingCart/Cart">
+		 	<t:binding.atom/>
+		 </reference>
+		 <reference name="shoppingTotal" target="StoreShoppingCart/Total">
+		 	<t:binding.jsonrpc/>
+		 </reference>
+    </component>
+    
+	<component name="StoreCatalog">
+		<implementation.java class="services.FruitsCatalogImpl"/> 
+		<property name="currencyCode">USD</property>
+		<service name="Catalog">
+			<t:binding.jsonrpc/>
+   		</service>
+		<reference name="currencyConverter" target="StoreCurrencyConverter"/>	
+	</component> 
+ 	
+	<component name="StoreShoppingCart">
+		<implementation.java class="services.ShoppingCartImpl"/>
+		<service name="Cart">
+			<t:binding.atom uri="/ShoppingCart/Cart"/>
+		</service>    	
+		<service name="Total">
+			<t:binding.jsonrpc/>
+		</service>    	
+	</component>
+    
+	<component name="StoreCurrencyConverter">
+		<implementation.java class="services.CurrencyConverterImpl"/>
+	</component>     
+
+</composite>