summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/samples/store-cluster
diff options
context:
space:
mode:
authorjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-10-25 03:18:16 +0000
committerjsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68>2010-10-25 03:18:16 +0000
commita2a2cb76e9582af32b6803be7fa99af074dc04ae (patch)
treed0ef504321e72fe16afd23f385f20386530f5dfc /sca-cpp/trunk/samples/store-cluster
parent0dd33c3859618f3a385583d7344230f0e1eb1004 (diff)
Support python method invocation style on references, ref.func(...) in addition to ref('func', ...). Minor cleanup of the various samples, renamed gettotal to total and getcatalog to items, for consistency with the python sample.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1026939 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/samples/store-cluster')
-rw-r--r--sca-cpp/trunk/samples/store-cluster/domains/jane/fruits-catalog.py8
-rw-r--r--sca-cpp/trunk/samples/store-cluster/domains/jane/shopping-cart.py12
-rw-r--r--sca-cpp/trunk/samples/store-cluster/domains/jane/store.py18
-rw-r--r--sca-cpp/trunk/samples/store-cluster/domains/joe/fruits-catalog.py8
-rw-r--r--sca-cpp/trunk/samples/store-cluster/domains/joe/shopping-cart.py12
-rw-r--r--sca-cpp/trunk/samples/store-cluster/domains/joe/store.py18
-rw-r--r--sca-cpp/trunk/samples/store-cluster/htdocs/domains/jane/index.html8
-rw-r--r--sca-cpp/trunk/samples/store-cluster/htdocs/domains/joe/index.html8
-rwxr-xr-xsca-cpp/trunk/samples/store-cluster/server-test4
9 files changed, 48 insertions, 48 deletions
diff --git a/sca-cpp/trunk/samples/store-cluster/domains/jane/fruits-catalog.py b/sca-cpp/trunk/samples/store-cluster/domains/jane/fruits-catalog.py
index fb85d12bc7..fb20b4ff27 100644
--- a/sca-cpp/trunk/samples/store-cluster/domains/jane/fruits-catalog.py
+++ b/sca-cpp/trunk/samples/store-cluster/domains/jane/fruits-catalog.py
@@ -17,11 +17,11 @@
# Catalog implementation
-def getcatalog(converter, currencyCode):
- code = currencyCode()
+def items(converter, currencyCode):
+ code = currencyCode.eval()
def convert(price):
- return converter("convert", "USD", code, price)
- symbol = converter("symbol", code)
+ return converter.convert("USD", code, price)
+ symbol = converter.symbol(code)
return (
(("'name", "Passion"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(2.99))),
(("'name", "Mango"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(3.55))),
diff --git a/sca-cpp/trunk/samples/store-cluster/domains/jane/shopping-cart.py b/sca-cpp/trunk/samples/store-cluster/domains/jane/shopping-cart.py
index e315b2f1ca..44484ea5d2 100644
--- a/sca-cpp/trunk/samples/store-cluster/domains/jane/shopping-cart.py
+++ b/sca-cpp/trunk/samples/store-cluster/domains/jane/shopping-cart.py
@@ -21,12 +21,12 @@ import sys
# Convert a particular host and user email to a cart id
def cartid(host, email):
- return ("cart", host(), email())
+ return ("cart", host.eval(), email.eval())
# Get the shopping cart from the cache
# Return an empty cart if not found
def getcart(id, cache):
- cart = cache("get", id)
+ cart = cache.get(id)
if cart is None:
return ()
return cart
@@ -35,7 +35,7 @@ def getcart(id, cache):
def post(collection, item, cache, host, email):
id = str(uuid.uuid1())
cart = ((item[0], id, item[2]),) + getcart(cartid(host, email), cache)
- cache("put", cartid(host, email), cart)
+ cache.put(cartid(host, email), cart)
return (id,)
@@ -51,13 +51,13 @@ def find(id, cart):
# Get items from the cart
def get(id, cache, host, email):
if id == ():
- return ("Your Cart", email()) + getcart(cartid(host, email), cache)
+ return ("Your Cart", email.eval()) + getcart(cartid(host, email), cache)
return find(id[0], getcart(cartid(host, email), cache))
# Delete items from the cart
def delete(id, cache, host, email):
if id == ():
- return cache("delete", cartid(host, email))
+ return cache.delete(cartid(host, email))
return True
# Return the price of an item
@@ -71,6 +71,6 @@ def sum(items):
return price(items[0]) + sum(items[1:])
# Return the total price of the items in the cart
-def gettotal(cache, host, email):
+def total(cache, host, email):
return sum(getcart(cartid(host, email), cache))
diff --git a/sca-cpp/trunk/samples/store-cluster/domains/jane/store.py b/sca-cpp/trunk/samples/store-cluster/domains/jane/store.py
index 0b4e0f72fd..ff82f1d327 100644
--- a/sca-cpp/trunk/samples/store-cluster/domains/jane/store.py
+++ b/sca-cpp/trunk/samples/store-cluster/domains/jane/store.py
@@ -18,23 +18,23 @@
# Store implementation
def post(item, catalog, shoppingCart, shoppingTotal):
- return shoppingCart("post", item)
+ return shoppingCart.post(item)
def getall(catalog, shoppingCart, shoppingTotal):
- return shoppingCart("getall")
+ return shoppingCart.getall()
def get(id, catalog, shoppingCart, shoppingTotal):
- return shoppingCart("get", id)
+ return shoppingCart.get(id)
-def getcatalog(catalog, shoppingCart, shoppingTotal):
- return catalog("getcatalog")
+def items(catalog, shoppingCart, shoppingTotal):
+ return catalog.items()
-def gettotal(catalog, shoppingCart, shoppingTotal):
- return shoppingCart("gettotal")
+def total(catalog, shoppingCart, shoppingTotal):
+ return shoppingCart.total()
def deleteall(catalog, shoppingCart, shoppingTotal):
- return shoppingCart("deleteall")
+ return shoppingCart.deleteall()
def delete(id, catalog, shoppingCart, shoppingTotal):
- return shoppingCart("delete", id)
+ return shoppingCart.delete(id)
diff --git a/sca-cpp/trunk/samples/store-cluster/domains/joe/fruits-catalog.py b/sca-cpp/trunk/samples/store-cluster/domains/joe/fruits-catalog.py
index b5eb035ae3..6644421683 100644
--- a/sca-cpp/trunk/samples/store-cluster/domains/joe/fruits-catalog.py
+++ b/sca-cpp/trunk/samples/store-cluster/domains/joe/fruits-catalog.py
@@ -17,11 +17,11 @@
# Catalog implementation
-def getcatalog(converter, currencyCode):
- code = currencyCode()
+def items(converter, currencyCode):
+ code = currencyCode.eval()
def convert(price):
- return converter("convert", "USD", code, price)
- symbol = converter("symbol", code)
+ return converter.convert("USD", code, price)
+ symbol = converter.symbol(code)
return (
(("'name", "Apple"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(2.99))),
(("'name", "Orange"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(3.55))),
diff --git a/sca-cpp/trunk/samples/store-cluster/domains/joe/shopping-cart.py b/sca-cpp/trunk/samples/store-cluster/domains/joe/shopping-cart.py
index e315b2f1ca..44484ea5d2 100644
--- a/sca-cpp/trunk/samples/store-cluster/domains/joe/shopping-cart.py
+++ b/sca-cpp/trunk/samples/store-cluster/domains/joe/shopping-cart.py
@@ -21,12 +21,12 @@ import sys
# Convert a particular host and user email to a cart id
def cartid(host, email):
- return ("cart", host(), email())
+ return ("cart", host.eval(), email.eval())
# Get the shopping cart from the cache
# Return an empty cart if not found
def getcart(id, cache):
- cart = cache("get", id)
+ cart = cache.get(id)
if cart is None:
return ()
return cart
@@ -35,7 +35,7 @@ def getcart(id, cache):
def post(collection, item, cache, host, email):
id = str(uuid.uuid1())
cart = ((item[0], id, item[2]),) + getcart(cartid(host, email), cache)
- cache("put", cartid(host, email), cart)
+ cache.put(cartid(host, email), cart)
return (id,)
@@ -51,13 +51,13 @@ def find(id, cart):
# Get items from the cart
def get(id, cache, host, email):
if id == ():
- return ("Your Cart", email()) + getcart(cartid(host, email), cache)
+ return ("Your Cart", email.eval()) + getcart(cartid(host, email), cache)
return find(id[0], getcart(cartid(host, email), cache))
# Delete items from the cart
def delete(id, cache, host, email):
if id == ():
- return cache("delete", cartid(host, email))
+ return cache.delete(cartid(host, email))
return True
# Return the price of an item
@@ -71,6 +71,6 @@ def sum(items):
return price(items[0]) + sum(items[1:])
# Return the total price of the items in the cart
-def gettotal(cache, host, email):
+def total(cache, host, email):
return sum(getcart(cartid(host, email), cache))
diff --git a/sca-cpp/trunk/samples/store-cluster/domains/joe/store.py b/sca-cpp/trunk/samples/store-cluster/domains/joe/store.py
index 0b4e0f72fd..811b05c580 100644
--- a/sca-cpp/trunk/samples/store-cluster/domains/joe/store.py
+++ b/sca-cpp/trunk/samples/store-cluster/domains/joe/store.py
@@ -18,23 +18,23 @@
# Store implementation
def post(item, catalog, shoppingCart, shoppingTotal):
- return shoppingCart("post", item)
+ return shoppingCart.post(item)
def getall(catalog, shoppingCart, shoppingTotal):
- return shoppingCart("getall")
+ return shoppingCart.getall()
def get(id, catalog, shoppingCart, shoppingTotal):
- return shoppingCart("get", id)
+ return shoppingCart.get(id)
-def getcatalog(catalog, shoppingCart, shoppingTotal):
- return catalog("getcatalog")
+def items(catalog, shoppingCart, shoppingTotal):
+ return catalog.items()
-def gettotal(catalog, shoppingCart, shoppingTotal):
- return shoppingCart("gettotal")
+def total(catalog, shoppingCart, shoppingTotal):
+ return shoppingCart.total()
def deleteall(catalog, shoppingCart, shoppingTotal):
- return shoppingCart("deleteall")
+ return shoppingCart.deletall()
def delete(id, catalog, shoppingCart, shoppingTotal):
- return shoppingCart("delete", id)
+ return shoppingCart.delete(id)
diff --git a/sca-cpp/trunk/samples/store-cluster/htdocs/domains/jane/index.html b/sca-cpp/trunk/samples/store-cluster/htdocs/domains/jane/index.html
index b60e18690a..376b15f6c1 100644
--- a/sca-cpp/trunk/samples/store-cluster/htdocs/domains/jane/index.html
+++ b/sca-cpp/trunk/samples/store-cluster/htdocs/domains/jane/index.html
@@ -36,7 +36,7 @@ var shoppingTotal = new tuscany.sca.Reference("shoppingTotal");
var catalogItems;
-function catalog_getcatalogResponse(items, exception) {
+function catalog_itemsResponse(items, exception) {
if (exception){
alert(exception.message);
return;
@@ -64,11 +64,11 @@ function shoppingCart_getResponse(feed) {
}
document.getElementById("shoppingCart").innerHTML = list;
- shoppingTotal.apply("gettotal", shoppingTotal_gettotalResponse);
+ shoppingTotal.apply("total", shoppingTotal_totalResponse);
}
}
-function shoppingTotal_gettotalResponse(total, exception) {
+function shoppingTotal_totalResponse(total, exception) {
if (exception) {
alert(exception.message);
return;
@@ -119,7 +119,7 @@ function deleteCart() {
function init() {
try {
- catalog.apply("getcatalog", catalog_getcatalogResponse);
+ catalog.apply("items", catalog_itemsResponse);
shoppingCart.get("", shoppingCart_getResponse);
} catch(e){
alert(e);
diff --git a/sca-cpp/trunk/samples/store-cluster/htdocs/domains/joe/index.html b/sca-cpp/trunk/samples/store-cluster/htdocs/domains/joe/index.html
index 37ed010229..e3675dc2d3 100644
--- a/sca-cpp/trunk/samples/store-cluster/htdocs/domains/joe/index.html
+++ b/sca-cpp/trunk/samples/store-cluster/htdocs/domains/joe/index.html
@@ -36,7 +36,7 @@ var shoppingTotal = new tuscany.sca.Reference("shoppingTotal");
var catalogItems;
-function catalog_getcatalogResponse(items, exception) {
+function catalog_itemsResponse(items, exception) {
if (exception){
alert(exception.message);
return;
@@ -64,11 +64,11 @@ function shoppingCart_getResponse(feed) {
}
document.getElementById("shoppingCart").innerHTML = list;
- shoppingTotal.apply("gettotal", shoppingTotal_gettotalResponse);
+ shoppingTotal.apply("total", shoppingTotal_totalResponse);
}
}
-function shoppingTotal_gettotalResponse(total, exception) {
+function shoppingTotal_totalResponse(total, exception) {
if (exception) {
alert(exception.message);
return;
@@ -119,7 +119,7 @@ function deleteCart() {
function init() {
try {
- catalog.apply("getcatalog", catalog_getcatalogResponse);
+ catalog.apply("items", catalog_itemsResponse);
shoppingCart.get("", shoppingCart_getResponse);
} catch(e){
alert(e);
diff --git a/sca-cpp/trunk/samples/store-cluster/server-test b/sca-cpp/trunk/samples/store-cluster/server-test
index 2f657c4ce5..7f6ff4ead6 100755
--- a/sca-cpp/trunk/samples/store-cluster/server-test
+++ b/sca-cpp/trunk/samples/store-cluster/server-test
@@ -36,8 +36,8 @@ rc=$?
# Test Catalog
if [ "$rc" = "0" ]; then
- $curl_prefix/bin/curl http://joe.sca-store.com/references/Store/catalog -X POST -H "Content-type: application/json-rpc" --data @../store-cpp/htdocs/test/getcatalog-request.txt >tmp/getcatalog-result.txt 2>/dev/null
- diff tmp/getcatalog-result.txt ../store-cpp/htdocs/test/getcatalog-result.txt
+ $curl_prefix/bin/curl http://joe.sca-store.com/references/Store/catalog -X POST -H "Content-type: application/json-rpc" --data @../store-cpp/htdocs/test/items-request.txt >tmp/items-result.txt 2>/dev/null
+ diff tmp/items-result.txt ../store-cpp/htdocs/test/items-result.txt
rc=$?
fi