summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--cpp/sca/samples/store/Makefile.am41
-rw-r--r--cpp/sca/samples/store/cart.hpp75
-rw-r--r--cpp/sca/samples/store/catalog.hpp65
-rw-r--r--cpp/sca/samples/store/catalogs.composite43
-rw-r--r--cpp/sca/samples/store/currency-composite.hpp52
-rw-r--r--cpp/sca/samples/store/currency.composite32
-rw-r--r--cpp/sca/samples/store/currency.hpp62
-rw-r--r--cpp/sca/samples/store/item.hpp47
-rw-r--r--cpp/sca/samples/store/store-composite.hpp69
-rw-r--r--cpp/sca/samples/store/store-solution.hpp63
-rw-r--r--cpp/sca/samples/store/store-test.cpp58
-rw-r--r--cpp/sca/samples/store/store-ui.hpp73
-rw-r--r--cpp/sca/samples/store/store.composite64
13 files changed, 744 insertions, 0 deletions
diff --git a/cpp/sca/samples/store/Makefile.am b/cpp/sca/samples/store/Makefile.am
new file mode 100644
index 0000000000..0277b96cfe
--- /dev/null
+++ b/cpp/sca/samples/store/Makefile.am
@@ -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.
diff --git a/cpp/sca/samples/store/cart.hpp b/cpp/sca/samples/store/cart.hpp
new file mode 100644
index 0000000000..764fdbd34f
--- /dev/null
+++ b/cpp/sca/samples/store/cart.hpp
@@ -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_ */
diff --git a/cpp/sca/samples/store/catalog.hpp b/cpp/sca/samples/store/catalog.hpp
new file mode 100644
index 0000000000..76cab8576f
--- /dev/null
+++ b/cpp/sca/samples/store/catalog.hpp
@@ -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_ */
diff --git a/cpp/sca/samples/store/catalogs.composite b/cpp/sca/samples/store/catalogs.composite
new file mode 100644
index 0000000000..154d475165
--- /dev/null
+++ b/cpp/sca/samples/store/catalogs.composite
@@ -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>
diff --git a/cpp/sca/samples/store/currency-composite.hpp b/cpp/sca/samples/store/currency-composite.hpp
new file mode 100644
index 0000000000..d9bdd93949
--- /dev/null
+++ b/cpp/sca/samples/store/currency-composite.hpp
@@ -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_ */
diff --git a/cpp/sca/samples/store/currency.composite b/cpp/sca/samples/store/currency.composite
new file mode 100644
index 0000000000..7a3f70e299
--- /dev/null
+++ b/cpp/sca/samples/store/currency.composite
@@ -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>
diff --git a/cpp/sca/samples/store/currency.hpp b/cpp/sca/samples/store/currency.hpp
new file mode 100644
index 0000000000..045f993230
--- /dev/null
+++ b/cpp/sca/samples/store/currency.hpp
@@ -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_ */
diff --git a/cpp/sca/samples/store/item.hpp b/cpp/sca/samples/store/item.hpp
new file mode 100644
index 0000000000..eab80106fd
--- /dev/null
+++ b/cpp/sca/samples/store/item.hpp
@@ -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_ */
diff --git a/cpp/sca/samples/store/store-composite.hpp b/cpp/sca/samples/store/store-composite.hpp
new file mode 100644
index 0000000000..1a235d3674
--- /dev/null
+++ b/cpp/sca/samples/store/store-composite.hpp
@@ -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_ */
diff --git a/cpp/sca/samples/store/store-solution.hpp b/cpp/sca/samples/store/store-solution.hpp
new file mode 100644
index 0000000000..4ed4fba551
--- /dev/null
+++ b/cpp/sca/samples/store/store-solution.hpp
@@ -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_ */
diff --git a/cpp/sca/samples/store/store-test.cpp b/cpp/sca/samples/store/store-test.cpp
new file mode 100644
index 0000000000..96ce6af997
--- /dev/null
+++ b/cpp/sca/samples/store/store-test.cpp
@@ -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;
+}
diff --git a/cpp/sca/samples/store/store-ui.hpp b/cpp/sca/samples/store/store-ui.hpp
new file mode 100644
index 0000000000..4e8578cc2f
--- /dev/null
+++ b/cpp/sca/samples/store/store-ui.hpp
@@ -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_ */
diff --git a/cpp/sca/samples/store/store.composite b/cpp/sca/samples/store/store.composite
new file mode 100644
index 0000000000..b3f3140c8c
--- /dev/null
+++ b/cpp/sca/samples/store/store.composite
@@ -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>