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 2010/02/22 07:08:35 UTC

svn commit: r912491 - in /tuscany/sca-cpp/trunk: components/cache/ components/chat/ components/queue/ components/webservice/ kernel/ modules/java/ modules/java/org/apache/tuscany/ modules/java/test/ modules/python/ modules/scheme/ modules/server/ test/...

Author: jsdelfino
Date: Mon Feb 22 06:08:34 2010
New Revision: 912491

URL: http://svn.apache.org/viewvc?rev=912491&view=rev
Log:
Moved component start calls from HTTPD postConfig to childInit, to give components an opportunity to start and setup connections and resources in each HTTPD child process. Adjusted utility components and test cases to this change. Minor code cleanup of Java components and integration tests.

Modified:
    tuscany/sca-cpp/trunk/components/cache/mcache.cpp
    tuscany/sca-cpp/trunk/components/chat/chat.composite
    tuscany/sca-cpp/trunk/components/chat/chatter.cpp
    tuscany/sca-cpp/trunk/components/chat/xmpp.hpp
    tuscany/sca-cpp/trunk/components/queue/queue-listener.cpp
    tuscany/sca-cpp/trunk/components/webservice/webservice-client.cpp
    tuscany/sca-cpp/trunk/kernel/value.hpp
    tuscany/sca-cpp/trunk/modules/java/eval.hpp
    tuscany/sca-cpp/trunk/modules/java/org/apache/tuscany/ClassLoader.java
    tuscany/sca-cpp/trunk/modules/java/org/apache/tuscany/IterableUtil.java
    tuscany/sca-cpp/trunk/modules/java/test/CalcImpl.java
    tuscany/sca-cpp/trunk/modules/python/eval.hpp
    tuscany/sca-cpp/trunk/modules/scheme/primitive.hpp
    tuscany/sca-cpp/trunk/modules/server/impl-test.cpp
    tuscany/sca-cpp/trunk/modules/server/mod-cpp.hpp
    tuscany/sca-cpp/trunk/modules/server/mod-eval.hpp
    tuscany/sca-cpp/trunk/modules/server/server-test.scm
    tuscany/sca-cpp/trunk/test/store-cpp/shopping-cart.cpp
    tuscany/sca-cpp/trunk/test/store-java/store/FruitsCatalogImpl.java
    tuscany/sca-cpp/trunk/test/store-java/store/ShoppingCartImpl.java
    tuscany/sca-cpp/trunk/test/store-python/shopping-cart.py
    tuscany/sca-cpp/trunk/test/store-scheme/shopping-cart.scm

Modified: tuscany/sca-cpp/trunk/components/cache/mcache.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/cache/mcache.cpp?rev=912491&r1=912490&r2=912491&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/cache/mcache.cpp (original)
+++ tuscany/sca-cpp/trunk/components/cache/mcache.cpp Mon Feb 22 06:08:34 2010
@@ -125,7 +125,7 @@
 
 const tuscany::value apply(const tuscany::list<tuscany::value>& params) {
     const tuscany::value func(car(params));
-    if (func == "start" || func == "restart")
+    if (func == "start")
         return tuscany::mcache::start(cdr(params));
     return tuscany::mkfailure<tuscany::value>();
 }

Modified: tuscany/sca-cpp/trunk/components/chat/chat.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/chat/chat.composite?rev=912491&r1=912490&r2=912491&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/chat/chat.composite (original)
+++ tuscany/sca-cpp/trunk/components/chat/chat.composite Mon Feb 22 06:08:34 2010
@@ -46,7 +46,7 @@
         <service name="print">
             <t:binding.http uri="print"/>
         </service>
-        <reference name="report" target="print-sender"/>
+        <reference name="report" target="print-chatter"/>
     </component>     
 
 </composite>

Modified: tuscany/sca-cpp/trunk/components/chat/chatter.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/chat/chatter.cpp?rev=912491&r1=912490&r2=912491&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/chat/chatter.cpp (original)
+++ tuscany/sca-cpp/trunk/components/chat/chatter.cpp Mon Feb 22 06:08:34 2010
@@ -110,7 +110,7 @@
 
         // Disconnect and shutdown the worker thread
         disconnect(const_cast<XMPPClient&>(xc));
-        shutdown(const_cast<worker&>(w));
+        cancel(const_cast<worker&>(w));
         debug("chat::chatter::stopped");
 
         return failable<value>(value(lambda<value(const list<value>&)>()));
@@ -154,7 +154,7 @@
 
 const tuscany::value apply(const tuscany::list<tuscany::value>& params) {
     const tuscany::value func(car(params));
-    if (func == "start" || func == "restart")
+    if (func == "start")
         return tuscany::chat::start(cdr(params));
     return tuscany::mkfailure<tuscany::value>();
 }

Modified: tuscany/sca-cpp/trunk/components/chat/xmpp.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/chat/xmpp.hpp?rev=912491&r1=912490&r2=912491&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/chat/xmpp.hpp (original)
+++ tuscany/sca-cpp/trunk/components/chat/xmpp.hpp Mon Feb 22 06:08:34 2010
@@ -318,7 +318,8 @@
     debug("chat::listen");
     xc.listener = listener;
     xmpp_handler_add(xc.conn, messageHandler, NULL, "message", NULL, &xc);
-    while(xc.connected && !isNil(xc.listener))
+    xc.ctx->loop_status = XMPP_LOOP_RUNNING;
+    while(xc.connected && !isNil(xc.listener) && xc.ctx->loop_status == XMPP_LOOP_RUNNING)
         xmpp_run_once(xc.ctx, 1000L);
     return true;
 }

Modified: tuscany/sca-cpp/trunk/components/queue/queue-listener.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/queue/queue-listener.cpp?rev=912491&r1=912490&r2=912491&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/queue/queue-listener.cpp (original)
+++ tuscany/sca-cpp/trunk/components/queue/queue-listener.cpp Mon Feb 22 06:08:34 2010
@@ -100,9 +100,9 @@
         debug("queue::listener::stop");
 
         // TODO check why stop() and close() hang in child processes
-        //stop(const_cast<QpidSubscription&>(qsub));
-        //close(const_cast<QpidSession&>(qs));
-        //close(const_cast<QpidConnection&>(qc));
+        stop(const_cast<QpidSubscription&>(qsub));
+        close(const_cast<QpidSession&>(qs));
+        close(const_cast<QpidConnection&>(qc));
         cancel(const_cast<worker&>(w));
 
         debug("queue::listener::stopped");
@@ -150,7 +150,7 @@
 
 const tuscany::value apply(const tuscany::list<tuscany::value>& params) {
     const tuscany::value func(car(params));
-    if (func == "start" || func == "restart")
+    if (func == "start")
         return tuscany::queue::start(cdr(params));
     return tuscany::mkfailure<tuscany::value>();
 }

Modified: tuscany/sca-cpp/trunk/components/webservice/webservice-client.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/webservice/webservice-client.cpp?rev=912491&r1=912490&r2=912491&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/webservice/webservice-client.cpp (original)
+++ tuscany/sca-cpp/trunk/components/webservice/webservice-client.cpp Mon Feb 22 06:08:34 2010
@@ -57,7 +57,7 @@
 
 const tuscany::value apply(const tuscany::list<tuscany::value>& params) {
     const tuscany::value func(car(params));
-    if (func == "start" || func == "restart")
+    if (func == "start")
         return tuscany::mkfailure<tuscany::value>();
     return tuscany::webservice::apply(func, cdr(params));
 }

Modified: tuscany/sca-cpp/trunk/kernel/value.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/kernel/value.hpp?rev=912491&r1=912490&r2=912491&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/kernel/value.hpp (original)
+++ tuscany/sca-cpp/trunk/kernel/value.hpp Mon Feb 22 06:08:34 2010
@@ -557,6 +557,15 @@
 }
 
 /**
+ * Convert a list of values to a list of other things.
+ */
+template<typename T> const list<T> convertValues(const list<value>& l) {
+    if (isNil(l))
+        return list<T>();
+    return cons<T>(car(l), convertValues<T>(cdr(l)));
+}
+
+/**
  * Convert a path string value to a list of values.
  */
 const list<string> pathTokens(const char* p) {

Modified: tuscany/sca-cpp/trunk/modules/java/eval.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/java/eval.hpp?rev=912491&r1=912490&r2=912491&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/java/eval.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/java/eval.hpp Mon Feb 22 06:08:34 2010
@@ -501,7 +501,7 @@
 
         // The start, stop, and restart functions are optional
         const value fn = car<value>(expr);
-        if (fn == "start" || fn == "restart" || "stop")
+        if (fn == "start" || fn == "stop")
             return value(lambda<value(const list<value>&)>());
 
         return mkfailure<value>(string("Couldn't find function: ") + car<value>(expr) + " : " + lastException(jr));

Modified: tuscany/sca-cpp/trunk/modules/java/org/apache/tuscany/ClassLoader.java
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/java/org/apache/tuscany/ClassLoader.java?rev=912491&r1=912490&r2=912491&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/java/org/apache/tuscany/ClassLoader.java (original)
+++ tuscany/sca-cpp/trunk/modules/java/org/apache/tuscany/ClassLoader.java Mon Feb 22 06:08:34 2010
@@ -19,8 +19,6 @@
 
 package org.apache.tuscany;
 
-import static org.apache.tuscany.ClassLoader.Test.*;
-
 import java.io.File;
 import java.net.MalformedURLException;
 import java.net.URL;
@@ -36,7 +34,7 @@
     }
 
     /**
-     * Create a class loader for an SCA contribution path. 
+     * Create a class loader for an SCA contribution path.
      */
     static java.lang.ClassLoader valueOf(final String path) throws MalformedURLException {
         return new ClassLoader(new File(path).toURI().toURL());

Modified: tuscany/sca-cpp/trunk/modules/java/org/apache/tuscany/IterableUtil.java
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/java/org/apache/tuscany/IterableUtil.java?rev=912491&r1=912490&r2=912491&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/java/org/apache/tuscany/IterableUtil.java (original)
+++ tuscany/sca-cpp/trunk/modules/java/org/apache/tuscany/IterableUtil.java Mon Feb 22 06:08:34 2010
@@ -20,7 +20,6 @@
 package org.apache.tuscany;
 
 import static java.util.Arrays.*;
-import static org.apache.tuscany.IterableUtil.Test.*;
 
 import java.util.AbstractList;
 import java.util.ArrayList;
@@ -369,10 +368,10 @@
 
     public static void main(final String[] args) {
         System.out.println("Testing...");
-        
+
         Test.class.getClassLoader().setDefaultAssertionStatus(true);
         new Test().testList();
-        
+
         System.out.println("OK");
     }
 

Modified: tuscany/sca-cpp/trunk/modules/java/test/CalcImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/java/test/CalcImpl.java?rev=912491&r1=912490&r2=912491&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/java/test/CalcImpl.java (original)
+++ tuscany/sca-cpp/trunk/modules/java/test/CalcImpl.java Mon Feb 22 06:08:34 2010
@@ -19,33 +19,34 @@
 
 package test;
 
-import java.util.List;
 import java.util.ArrayList;
+import java.util.List;
+
 import org.apache.tuscany.Service;
 
 public class CalcImpl {
-    
-    public Double add(Double x, Double y, Adder adder) {
+
+    public Double add(final Double x, final Double y, final Adder adder) {
         return adder.add(x, y);
     }
-    
-    public Double addEval(Double x, Double y, Service adder) {
+
+    public Double addEval(final Double x, final Double y, final Service adder) {
         return adder.eval("add", x, y);
     }
-    
-    public Double mult(Double x, Double y) {
+
+    public Double mult(final Double x, final Double y) {
         return x * y;
     }
-    
-    public Boolean even(Double x) {
-        return (double)(((int)(double)x / 2) * 2) == (double)x;
+
+    public Boolean even(final Double x) {
+        return (double)((int)(double)x / 2 * 2) == (double)x;
     }
-    
-    public Iterable<Double> square(Iterable<Double> l) {
-        List r = new ArrayList();
-        for (Double x: l)
+
+    public Iterable<Double> square(final Iterable<Double> l) {
+        final List<Double> r = new ArrayList<Double>();
+        for(final Double x : l)
             r.add(x * x);
         return r;
     }
-    
+
 }

Modified: tuscany/sca-cpp/trunk/modules/python/eval.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/python/eval.hpp?rev=912491&r1=912490&r2=912491&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/python/eval.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/python/eval.hpp Mon Feb 22 06:08:34 2010
@@ -241,7 +241,7 @@
 
         // The start, stop, and restart functions are optional
         const value fn = car<value>(expr);
-        if (fn == "start" || fn == "restart" || fn == "stop") {
+        if (fn == "start" || fn == "stop") {
             PyErr_Clear();
             return value(lambda<value(const list<value>&)>());
         }

Modified: tuscany/sca-cpp/trunk/modules/scheme/primitive.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/scheme/primitive.hpp?rev=912491&r1=912490&r2=912491&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/scheme/primitive.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/scheme/primitive.hpp Mon Feb 22 06:08:34 2010
@@ -179,10 +179,6 @@
     return lambda<value(const list<value>&)>();
 }
 
-const value restartProc(unused const list<value>& args) {
-    return lambda<value(const list<value>&)>();
-}
-
 const value applyPrimitiveProcedure(const value& proc, list<value>& args) {
     const lambda<value(const list<value>&)> func(cadr((list<value>)proc));
     return func(args);
@@ -236,8 +232,7 @@
     + "log"
     + "uuid"
     + "start"
-    + "stop"
-    + "restart";
+    + "stop";
 }
 
 const list<value> primitiveProcedureObjects() {
@@ -262,8 +257,7 @@
     + primitiveProcedure(logProc)
     + primitiveProcedure(uuidProc)
     + primitiveProcedure(startProc)
-    + primitiveProcedure(stopProc)
-    + primitiveProcedure(restartProc);
+    + primitiveProcedure(stopProc);
 }
 
 const bool isFalse(const value& exp) {

Modified: tuscany/sca-cpp/trunk/modules/server/impl-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/server/impl-test.cpp?rev=912491&r1=912490&r2=912491&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/server/impl-test.cpp (original)
+++ tuscany/sca-cpp/trunk/modules/server/impl-test.cpp Mon Feb 22 06:08:34 2010
@@ -34,7 +34,7 @@
 namespace server {
 
 const failable<value> get(unused const list<value>& params) {
-    return value(string("Hey"));
+    return value(mklist<value>("text/html", mklist<value>("Hey")));
 }
 
 const failable<value> post(unused const list<value>& params) {

Modified: tuscany/sca-cpp/trunk/modules/server/mod-cpp.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/server/mod-cpp.hpp?rev=912491&r1=912490&r2=912491&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/server/mod-cpp.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/server/mod-cpp.hpp Mon Feb 22 06:08:34 2010
@@ -50,10 +50,10 @@
         return v;
 
     // Report a failure with an empty reason as 'function not supported'
-    // Except for the start, stop, and restart functions, which are optional
+    // Except for the start, and stop functions, which are optional
     const value reason = cadr(v);
     if (length(reason) == 0) {
-        if (func == "start" || func == "restart" || func == "stop")
+        if (func == "start" || func == "stop")
             return mklist<value>(lambda<value(const list<value>&)>());
         return mklist<value>(value(), string("Function not supported: ") + func);
     }

Modified: tuscany/sca-cpp/trunk/modules/server/mod-eval.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/server/mod-eval.hpp?rev=912491&r1=912490&r2=912491&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/server/mod-eval.hpp (original)
+++ tuscany/sca-cpp/trunk/modules/server/mod-eval.hpp Mon Feb 22 06:08:34 2010
@@ -104,15 +104,22 @@
         return httpd::writeResult(json::jsonResult(id, content(val), cx), "application/json-rpc", r);
     }
 
-    // Evaluate the GET expression and return an ATOM entry or feed representing a resource
+    // Evaluate the GET expression
     const list<value> path(pathValues(r->uri));
     const failable<value> val = failableResult(impl(cons<value>("get", mklist<value>(cddr(path)))));
     if (!hasContent(val))
         return mkfailure<int>(reason(val));
+    const value c = content(val);
+
+    // Write returned content-type / content-list pair
+    if (isList(cadr<value>(c)))
+        return httpd::writeResult(convertValues<string>(cadr<value>(c)), car<value>(c), r);
+
+    // Write returned ATOM feed or entry
     if (isNil(cddr(path)))
-        return httpd::writeResult(atom::writeATOMFeed(atom::feedValuesToElements(content(val))), "application/atom+xml;type=feed", r);
+        return httpd::writeResult(atom::writeATOMFeed(atom::feedValuesToElements(c)), "application/atom+xml;type=feed", r);
     else
-        return httpd::writeResult(atom::writeATOMEntry(atom::entryValuesToElements(content(val))), "application/atom+xml;type=entry", r);
+        return httpd::writeResult(atom::writeATOMEntry(atom::entryValuesToElements(c)), "application/atom+xml;type=entry", r);
 }
 
 /**
@@ -375,7 +382,7 @@
 /**
  * Configure the components declared in the deployed composite.
  */
-const failable<bool> confComponents(const string& lifecycle, ServerConf& sc, server_rec& server) {
+const failable<bool> confComponents(ServerConf& sc, server_rec& server) {
     if (sc.contributionPath == "" || sc.compositeName == "")
         return false;
 
@@ -383,20 +390,29 @@
     const failable<list<value> > comps = readComponents(sc.contributionPath + sc.compositeName);
     if (!hasContent(comps))
         return mkfailure<bool>(reason(comps));
-    const list<value> starts = componentToImplementationAssoc(sc, server, content(comps));
+    sc.implementations = componentToImplementationAssoc(sc, server, content(comps));
+    debug(sc.implementations, "modeval::confComponents::implementations");
+
+    // Store the implementation lambda functions in a tree for fast retrieval
+    sc.implTree = mkbtree(sort(sc.implementations));
+    return true;
+}
+
+/**
+ * Start the components declared in the deployed composite.
+ */
+const failable<bool> startComponents(ServerConf& sc) {
 
-    // Start or restart the component implementations
-    // Record the returned lambda functions
-    debug(starts, "modeval::confComponents::start");
-    const failable<list<value> > impls = applyLifecycleExpr(starts, mklist<value>(c_str(lifecycle)));
+    // Start the components and record the returned implementation lambda functions
+    debug(sc.implementations, "modeval::startComponents::start");
+    const failable<list<value> > impls = applyLifecycleExpr(sc.implementations, mklist<value>("start"));
     if (!hasContent(impls))
         return mkfailure<bool>(reason(impls));
     sc.implementations = content(impls);
-    debug(sc.implementations, "modeval::confComponents::implementations");
+    debug(sc.implementations, "modeval::startComponents::implementations");
 
     // Store the implementation lambda functions in a tree for fast retrieval
     sc.implTree = mkbtree(sort(sc.implementations));
-
     return true;
 }
 
@@ -458,7 +474,7 @@
     debug(sc.wiringServerName, "modeval::postConfig::wiringServerName");
     debug(sc.contributionPath, "modeval::postConfig::contributionPath");
     debug(sc.compositeName, "modeval::postConfig::compositeName");
-    const failable<bool> res = confComponents(count > 1? "restart" : "start", sc, *s);
+    const failable<bool> res = confComponents(sc, *s);
     if (!hasContent(res)) {
         cerr << "[Tuscany] Due to one or more errors mod_tuscany_eval loading failed. Causing apache to stop loading." << endl;
         return -1;
@@ -481,6 +497,13 @@
         exit(APEXIT_CHILDFATAL);
     }
 
+    // Start the components in the child process
+    const failable<bool> res = startComponents(*sc);
+    if (!hasContent(res)) {
+        cerr << "[Tuscany] Due to one or more errors mod_tuscany_eval loading failed. Causing apache to stop loading." << endl;
+        exit(APEXIT_CHILDFATAL);
+    }
+
     // Register a cleanup callback, called when the child is stopped or restarted
     apr_pool_pre_cleanup_register(p, (void*)sc, serverCleanup);
 }

Modified: tuscany/sca-cpp/trunk/modules/server/server-test.scm
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/modules/server/server-test.scm?rev=912491&r1=912490&r2=912491&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/modules/server/server-test.scm (original)
+++ tuscany/sca-cpp/trunk/modules/server/server-test.scm Mon Feb 22 06:08:34 2010
@@ -31,11 +31,11 @@
     '("Item" "111" ((javaClass "services.Item") (name "Apple") (currencyCode "USD") (currencySymbol "$") (price 2.99))))
 )
 
-(define (post coll entry)
+(define (post collection item)
   '("123456789")
 )
 
-(define (put id entry)
+(define (put id item)
   true
 )
 

Modified: tuscany/sca-cpp/trunk/test/store-cpp/shopping-cart.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/test/store-cpp/shopping-cart.cpp?rev=912491&r1=912490&r2=912491&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/test/store-cpp/shopping-cart.cpp (original)
+++ tuscany/sca-cpp/trunk/test/store-cpp/shopping-cart.cpp Mon Feb 22 06:08:34 2010
@@ -41,7 +41,7 @@
  * cart if not found.
  */
 const list<value> getcart(const value& id, const lambda<value(const list<value>&)> cache) {
-    const value cart = cache(mklist<value>("get", id));
+    const value cart = cache(mklist<value>("get", mklist<value>(id)));
     if (isNil(cart))
         return value(list<value>());
     return (list<value>)cart;
@@ -61,19 +61,12 @@
 /**
  * Post a new item to the cart. Create a new cart if necessary.
  */
-const failable<value> post(const value& item, const lambda<value(const list<value>&)> cache) {
+const failable<value> post(unused const list<value>& collection, const value& item, const lambda<value(const list<value>&)> cache) {
     const value id(uuid());
     const list<value> newItem(mklist<value>(car<value>(item), id, caddr<value>(item)));
     const list<value> cart(cons<value>(newItem, getcart(cartId, cache)));
-    cache(mklist<value>("put", cartId, cart));
-    return id;
-}
-
-/**
- * Return the contents of the cart.
- */
-const failable<value> getall(const lambda<value(const list<value>&)> cache) {
-    return value(append(mklist<value>(string("Your Cart"), cartId), getcart(cartId, cache)));
+    cache(mklist<value>("put", mklist<value>(cartId), cart));
+    return value(mklist<value>(id));
 }
 
 /**
@@ -87,21 +80,21 @@
     return find(id, cdr(cart));
 }
 
-const failable<value> get(const value& id, const lambda<value(const list<value>&)> cache) {
-    return find(id, getcart(cartId, cache));
-}
-
 /**
- * Delete the whole cart.
+ * Return items from the cart.
  */
-const failable<value> delall(const lambda<value(const list<value>&)> cache) {
-    return cache(mklist<value>("delete", cartId));
+const failable<value> get(const list<value>& id, const lambda<value(const list<value>&)> cache) {
+    if (isNil(id))
+        return value(append(mklist<value>(string("Your Cart"), cartId), getcart(cartId, cache)));
+    return find(car(id), getcart(cartId, cache));
 }
 
 /**
- * Delete an item from the cart.
+ * Delete items from the cart.
  */
-const failable<value> del(unused const value& id, unused const lambda<value(const list<value>&)> cache) {
+const failable<value> del(const list<value>& id, unused const lambda<value(const list<value>&)> cache) {
+    if (isNil(id))
+        return cache(mklist<value>("delete", mklist<value>(cartId)));
     return value(true);
 }
 
@@ -144,13 +137,9 @@
 const tuscany::value apply(const tuscany::list<tuscany::value>& params) {
     const tuscany::value func(car(params));
     if (func == "post")
-        return tuscany::store::post(cadr(params), caddr(params));
-    if (func == "getall")
-        return tuscany::store::getall(cadr(params));
+        return tuscany::store::post(cadr(params), caddr(params), cadddr(params));
     if (func == "get")
         return tuscany::store::get(cadr(params), caddr(params));
-    if (func == "deleteall")
-        return tuscany::store::delall(cadr(params));
     if (func == "delete")
         return tuscany::store::del(cadr(params), caddr(params));
     if (func == "gettotal")

Modified: tuscany/sca-cpp/trunk/test/store-java/store/FruitsCatalogImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/test/store-java/store/FruitsCatalogImpl.java?rev=912491&r1=912490&r2=912491&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/test/store-java/store/FruitsCatalogImpl.java (original)
+++ tuscany/sca-cpp/trunk/test/store-java/store/FruitsCatalogImpl.java Mon Feb 22 06:08:34 2010
@@ -19,34 +19,33 @@
 
 package store;
 
+import static org.apache.tuscany.IterableUtil.*;
+
 import org.apache.tuscany.Service;
-import static org.apache.tuscany.IterableUtil.list;
 
 /**
  * Catalog component implementation.
  */
 public class FruitsCatalogImpl {
-    
+
     /**
      * Returns the catalog.
      */
     public Iterable<?> get(final CurrencyConverter converter, final Service currencyCode) {
         final String code = currencyCode.eval();
-        
+
         class Converter {
-            Double convert(Double price) {
+            Double convert(final Double price) {
                 return converter.convert(code, "USD", price);
             }
-        };
+        }
 
-        Converter c = new Converter();
-        String symbol = converter.symbol(code);
-        
-        return list(
-                list(list("'javaClass", "services.Item"), list("'name", "Apple"), list("'currencyCode", code), list("'currencySymbol", symbol), list("'price", c.convert(2.99))),
+        final Converter c = new Converter();
+        final String symbol = converter.symbol(code);
+
+        return list(list(list("'javaClass", "services.Item"), list("'name", "Apple"), list("'currencyCode", code), list("'currencySymbol", symbol), list("'price", c.convert(2.99))),
                 list(list("'javaClass", "services.Item"), list("'name", "Orange"), list("'currencyCode", code), list("'currencySymbol", symbol), list("'price", c.convert(3.55))),
-                list(list("'javaClass", "services.Item"), list("'name", "Pear"), list("'currencyCode", code), list("'currencySymbol", symbol), list("'price", c.convert(1.55)))
-              );
+                list(list("'javaClass", "services.Item"), list("'name", "Pear"), list("'currencyCode", code), list("'currencySymbol", symbol), list("'price", c.convert(1.55))));
     }
 
     /**
@@ -55,5 +54,5 @@
     public Iterable<?> listMethods(final CurrencyConverter converter, final Service currencyCode) {
         return list("Service.get");
     }
-    
+
 }

Modified: tuscany/sca-cpp/trunk/test/store-java/store/ShoppingCartImpl.java
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/test/store-java/store/ShoppingCartImpl.java?rev=912491&r1=912490&r2=912491&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/test/store-java/store/ShoppingCartImpl.java (original)
+++ tuscany/sca-cpp/trunk/test/store-java/store/ShoppingCartImpl.java Mon Feb 22 06:08:34 2010
@@ -19,25 +19,26 @@
 
 package store;
 
-import org.apache.tuscany.Service;
-import java.lang.System;
-import java.util.UUID;
 import static org.apache.tuscany.IterableUtil.*;
 
+import java.util.UUID;
+
+import org.apache.tuscany.Service;
+
 /**
  * Shopping cart component implementation.
  */
 public class ShoppingCartImpl {
-    
+
     static String cartId = "1234";
-    
+
     /**
-     * Get the shopping cart from the cache. Return an empty
-     * cart if not found.
+     * Get the shopping cart from the cache. Return an empty cart if not found.
      */
-    public Iterable<?> getcart(String id, Service cache) {
-        Iterable<?> cart = cache.get(id);
-        if (cart == null)
+    public Iterable<?> getcart(final String id, final Service cache) {
+        final Iterable<String> iid = list(id);
+        final Iterable<?> cart = cache.get(iid);
+        if(cart == null)
             return list();
         return cart;
     }
@@ -52,72 +53,68 @@
     /**
      * Post a new item to the cart. Create a new cart if necessary.
      */
-    public String post(Iterable<?> item, Service cache) {
-        String id = uuid();
-        Iterable<?> newItem = list(car(item), id, caddr(item));
-        Iterable<?> cart = cons(newItem, getcart(cartId, cache));
-        cache.put(cartId, cart);
-        return id;
-    }
-
-    /**
-     * Return the contents of the cart.
-     */
-    public Iterable<?> getall(Service cache) {
-        return cons("Your Cart", cons(cartId, getcart(cartId, cache)));
+    public Iterable<String> post(final Iterable<String> collection, final Iterable<?> item, final Service cache) {
+        final String id = this.uuid();
+        final Iterable<?> newItem = list(car(item), id, caddr(item));
+        final Iterable<?> cart = cons(newItem, this.getcart(cartId, cache));
+        final Iterable<String> iid = list(cartId);
+        cache.put(iid, cart);
+        return list(id);
     }
 
     /**
      * Find an item in the cart.
      */
-    public Iterable<?> find(String id, Iterable<?> cart) {
-        if (isNil(cart))
+    public Iterable<?> find(final String id, final Iterable<?> cart) {
+        if(isNil(cart))
             return cons("Item", list("0", list()));
-        if (id.equals(cadr(car(cart))))
+        if(id.equals(cadr(car(cart))))
             return car(cart);
-        return find(id, cdr(cart));
-    }
-
-    public Iterable<?> get(String id, Service cache) {
-        return find(id, getcart(cartId, cache));
+        return this.find(id, cdr(cart));
     }
 
     /**
-     * Delete the whole cart.
+     * Return items from the cart.
      */
-    public Boolean deleteall(Service cache) {
-        return cache.delete(cartId);
+    public Iterable<?> get(final Iterable<String> id, final Service cache) {
+        if(isNil(id))
+            return cons("Your Cart", cons(cartId, this.getcart(cartId, cache)));
+        return this.find((String)car(id), this.getcart(cartId, cache));
     }
 
     /**
-     * Delete an item from the cart.
+     * Delete items from the cart.
      */
-    public Boolean delete(String id, Service cache) {
+    public Boolean delete(final Iterable<String> id, final Service cache) {
+        if(isNil(id)) {
+            final Iterable<String> iid = list(cartId);
+            return cache.delete(iid);
+        }
         return true;
     }
 
     /**
      * Return the price of an item.
      */
-    Double price(Iterable<?> item) {
+    Double price(final Iterable<?> item) {
         return Double.valueOf((String)cadr(assoc("'price", caddr(item))));
     }
 
     /**
      * Sum the prices of a list of items.
      */
-    Double sum(Iterable<?> items) {
-        if (isNil(items))
+    Double sum(final Iterable<?> items) {
+        if(isNil(items))
             return 0.0;
-        return price((Iterable<?>)car(items)) + sum(cdr(items));
+        return this.price((Iterable<?>)car(items)) + this.sum(cdr(items));
     }
 
     /**
      * Return the total price of the items in the cart.
      */
-    public Double gettotal(Service cache) {
-        Iterable<?> cart = getcart(cartId, cache);
-        return sum(cart);
+    public Double gettotal(final Service cache) {
+        final Iterable<?> cart = this.getcart(cartId, cache);
+        return this.sum(cart);
     }
 
     /**
@@ -126,5 +123,5 @@
     public Iterable<?> listMethods(final Service cache) {
         return list("Service.gettotal");
     }
-    
+
 }

Modified: tuscany/sca-cpp/trunk/test/store-python/shopping-cart.py
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/test/store-python/shopping-cart.py?rev=912491&r1=912490&r2=912491&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/test/store-python/shopping-cart.py (original)
+++ tuscany/sca-cpp/trunk/test/store-python/shopping-cart.py Mon Feb 22 06:08:34 2010
@@ -24,21 +24,18 @@
 # 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
 
 # Post a new item to the cart, create a new cart if necessary
-def post(item, cache):
+def post(collection, item, cache):
     id = str(uuid.uuid1())
     cart = ((item[0], id, item[2]),) + getcart(cartId, cache)
-    cache("put", cartId, cart)
-    return id
+    cache("put", (cartId,), cart)
+    return (id,)
 
-# Return the content of the cart
-def getall(cache):
-    return ("Your Cart", cartId) + getcart(cartId, cache)
 
 # Find an item in the cart
 def find(id, cart):
@@ -49,16 +46,16 @@
     else:
         return find(id, cart[1:])
 
-# Get an item from the cart
+# Get items from the cart
 def get(id, cache):
-    return find(id, getcart(cartId, cache))
+    if id == ():
+        return ("Your Cart", cartId) + getcart(cartId, cache)
+    return find(id[0], getcart(cartId, cache))
 
-# Delete the whole cart
-def deleteall(cache):
-    return cache("delete", cartId)
-
-# Delete an item from the  cart
+# Delete items from the  cart
 def delete(id, cache):
+    if id == ():
+        return cache("delete", (cartId,))
     return true
 
 # Return the price of an item
@@ -79,4 +76,3 @@
 # TODO remove these JSON-RPC specific functions
 def listMethods(cache):
     return ("Service.gettotal",)
-

Modified: tuscany/sca-cpp/trunk/test/store-scheme/shopping-cart.scm
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/test/store-scheme/shopping-cart.scm?rev=912491&r1=912490&r2=912491&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/test/store-scheme/shopping-cart.scm (original)
+++ tuscany/sca-cpp/trunk/test/store-scheme/shopping-cart.scm Mon Feb 22 06:08:34 2010
@@ -22,24 +22,19 @@
 ; Get the shopping cart from the cache
 ; Return an empty cart if not found
 (define (getcart id cache)
-  (define cart (cache "get" id))
+  (define cart (cache "get" (list id)))
   (if (nul cart)
     (list)
     cart)
 )
 
 ; Post a new item to the cart, create a new cart if necessary
-(define (post item cache)
+(define (post collection item cache)
   (define id (uuid))
   (define newItem (list (car item) id (caddr item)))
   (define cart (cons newItem (getcart cartId cache)))
-  (cache "put" cartId cart)
-  id
-)
-
-; Return the content of the cart
-(define (getall cache)
-  (cons "Your Cart" (cons cartId (getcart cartId cache)))
+  (cache "put" (list cartId) cart)
+  (list id)
 )
 
 ; Find an item in the cart
@@ -51,19 +46,20 @@
       (find id (cdr cart))))
 )
 
-; Get an item from the cart
+; Get items from the cart
 (define (get id cache)
-  (find id (getcart cartId cache))
+  (if (nul id)
+    (cons "Your Cart" (cons cartId (getcart cartId cache)))
+    (find (car id) (getcart cartId cache))
+  )
 )
 
-; Delete the whole cart
-(define (deleteall cache)
-  (cache "delete" cartId)
-)
-
-; Delete an item from the  cart
+; Delete items from the  cart
 (define (delete id cache)
-  true
+  (if (nul id)
+    (cache "delete" (list cartId))
+    true
+  )
 )
 
 ; Return the price of an item
@@ -86,4 +82,3 @@
 
 ; TODO remove these JSON-RPC specific functions
 (define (listMethods cache) (list "Service.gettotal"))
-