tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsdelf...@apache.org
Subject svn commit: r1420007 [1/4] - in /tuscany/sca-cpp/trunk: ./ components/cache/ components/chat/ components/constdb/ components/filedb/ components/http/ components/kvdb/ components/log/ components/queue/ components/smtp/ components/sqldb/ components/webse...
Date Tue, 11 Dec 2012 06:13:13 GMT
Author: jsdelfino
Date: Tue Dec 11 06:13:02 2012
New Revision: 1420007

URL: http://svn.apache.org/viewvc?rev=1420007&view=rev
Log:
Changes to get successful C++11 based build. Code cleanup, dependency upgrades, and const + inline optimizations in components, samples, and app hosting server.

Added:
    tuscany/sca-cpp/trunk/patches/thrift-0.8.0.patch
      - copied, changed from r1419987, tuscany/sca-cpp/trunk/patches/thrift-0.2.0.patch
    tuscany/sca-cpp/trunk/unmaintained/components/
    tuscany/sca-cpp/trunk/unmaintained/components/kvdb/
    tuscany/sca-cpp/trunk/unmaintained/components/kvdb/Makefile.am
      - copied, changed from r1419987, tuscany/sca-cpp/trunk/components/kvdb/Makefile.am
    tuscany/sca-cpp/trunk/unmaintained/components/kvdb/client-test.cpp
      - copied, changed from r1419987, tuscany/sca-cpp/trunk/components/kvdb/client-test.cpp
    tuscany/sca-cpp/trunk/unmaintained/components/kvdb/kvdb-test
      - copied, changed from r1419987, tuscany/sca-cpp/trunk/components/kvdb/kvdb-test
    tuscany/sca-cpp/trunk/unmaintained/components/kvdb/kvdb.componentType
      - copied, changed from r1419987, tuscany/sca-cpp/trunk/components/kvdb/kvdb.componentType
    tuscany/sca-cpp/trunk/unmaintained/components/kvdb/kvdb.composite
      - copied, changed from r1419987, tuscany/sca-cpp/trunk/components/kvdb/kvdb.composite
    tuscany/sca-cpp/trunk/unmaintained/components/kvdb/kvdb.cpp
      - copied, changed from r1419987, tuscany/sca-cpp/trunk/components/kvdb/kvdb.cpp
    tuscany/sca-cpp/trunk/unmaintained/components/kvdb/leveldb
      - copied, changed from r1419987, tuscany/sca-cpp/trunk/components/kvdb/leveldb
    tuscany/sca-cpp/trunk/unmaintained/components/kvdb/leveldb-test.cpp
      - copied, changed from r1419987, tuscany/sca-cpp/trunk/components/kvdb/leveldb-test.cpp
    tuscany/sca-cpp/trunk/unmaintained/components/kvdb/leveldb.hpp
      - copied, changed from r1419987, tuscany/sca-cpp/trunk/components/kvdb/leveldb.hpp
    tuscany/sca-cpp/trunk/unmaintained/components/kvdb/server-test
      - copied, changed from r1419987, tuscany/sca-cpp/trunk/components/kvdb/server-test
Removed:
    tuscany/sca-cpp/trunk/components/kvdb/
    tuscany/sca-cpp/trunk/patches/thrift-0.2.0.patch
Modified:
    tuscany/sca-cpp/trunk/INSTALL
    tuscany/sca-cpp/trunk/README
    tuscany/sca-cpp/trunk/components/cache/Makefile.am
    tuscany/sca-cpp/trunk/components/cache/cache.composite
    tuscany/sca-cpp/trunk/components/cache/client-test.cpp
    tuscany/sca-cpp/trunk/components/cache/datacache.cpp
    tuscany/sca-cpp/trunk/components/cache/memcache-test.cpp
    tuscany/sca-cpp/trunk/components/cache/memcache.cpp
    tuscany/sca-cpp/trunk/components/cache/memcache.hpp
    tuscany/sca-cpp/trunk/components/cache/memocache.cpp
    tuscany/sca-cpp/trunk/components/cache/partitioner.cpp
    tuscany/sca-cpp/trunk/components/cache/select-test.scm
    tuscany/sca-cpp/trunk/components/chat/Makefile.am
    tuscany/sca-cpp/trunk/components/chat/chat-send.cpp
    tuscany/sca-cpp/trunk/components/chat/chat-sender.cpp
    tuscany/sca-cpp/trunk/components/chat/chat-sender2.cpp
    tuscany/sca-cpp/trunk/components/chat/chat-sendreceiver.cpp
    tuscany/sca-cpp/trunk/components/chat/client-test.cpp
    tuscany/sca-cpp/trunk/components/chat/xmpp-test.cpp
    tuscany/sca-cpp/trunk/components/chat/xmpp.hpp
    tuscany/sca-cpp/trunk/components/constdb/Makefile.am
    tuscany/sca-cpp/trunk/components/constdb/client-test.cpp
    tuscany/sca-cpp/trunk/components/constdb/constdb.cpp
    tuscany/sca-cpp/trunk/components/constdb/tinycdb-test.cpp
    tuscany/sca-cpp/trunk/components/constdb/tinycdb.hpp
    tuscany/sca-cpp/trunk/components/filedb/Makefile.am
    tuscany/sca-cpp/trunk/components/filedb/client-test.cpp
    tuscany/sca-cpp/trunk/components/filedb/file-test.cpp
    tuscany/sca-cpp/trunk/components/filedb/filedb.cpp
    tuscany/sca-cpp/trunk/components/filedb/filedb.hpp
    tuscany/sca-cpp/trunk/components/http/Makefile.am
    tuscany/sca-cpp/trunk/components/http/client-test.cpp
    tuscany/sca-cpp/trunk/components/http/httpdelete.cpp
    tuscany/sca-cpp/trunk/components/http/httpget.cpp
    tuscany/sca-cpp/trunk/components/http/httppatch.cpp
    tuscany/sca-cpp/trunk/components/http/httppost.cpp
    tuscany/sca-cpp/trunk/components/http/httpput.cpp
    tuscany/sca-cpp/trunk/components/log/Makefile.am
    tuscany/sca-cpp/trunk/components/log/client-test.cpp
    tuscany/sca-cpp/trunk/components/log/log.cpp
    tuscany/sca-cpp/trunk/components/log/logger.cpp
    tuscany/sca-cpp/trunk/components/log/scribe-cat.cpp
    tuscany/sca-cpp/trunk/components/log/scribe-status.cpp
    tuscany/sca-cpp/trunk/components/log/scribe.hpp
    tuscany/sca-cpp/trunk/components/queue/Makefile.am
    tuscany/sca-cpp/trunk/components/queue/client-test.cpp
    tuscany/sca-cpp/trunk/components/queue/qpid-test.cpp
    tuscany/sca-cpp/trunk/components/queue/qpid.hpp
    tuscany/sca-cpp/trunk/components/queue/queue-listener.cpp
    tuscany/sca-cpp/trunk/components/queue/queue-sender.cpp
    tuscany/sca-cpp/trunk/components/smtp/Makefile.am
    tuscany/sca-cpp/trunk/components/smtp/client-test.cpp
    tuscany/sca-cpp/trunk/components/smtp/smtppost.cpp
    tuscany/sca-cpp/trunk/components/sqldb/Makefile.am
    tuscany/sca-cpp/trunk/components/sqldb/client-test.cpp
    tuscany/sca-cpp/trunk/components/sqldb/pgsql-standby-test.cpp
    tuscany/sca-cpp/trunk/components/sqldb/pgsql-test.cpp
    tuscany/sca-cpp/trunk/components/sqldb/pgsql.hpp
    tuscany/sca-cpp/trunk/components/sqldb/sqldb.cpp
    tuscany/sca-cpp/trunk/components/webservice/Makefile.am
    tuscany/sca-cpp/trunk/components/webservice/axiom-test.cpp
    tuscany/sca-cpp/trunk/components/webservice/axis2-dispatcher.cpp
    tuscany/sca-cpp/trunk/components/webservice/axis2-service.cpp
    tuscany/sca-cpp/trunk/components/webservice/axis2-test.cpp
    tuscany/sca-cpp/trunk/components/webservice/axis2.hpp
    tuscany/sca-cpp/trunk/components/webservice/client-test.cpp
    tuscany/sca-cpp/trunk/components/webservice/echo-test
    tuscany/sca-cpp/trunk/components/webservice/server-test
    tuscany/sca-cpp/trunk/components/webservice/webservice-client.cpp
    tuscany/sca-cpp/trunk/components/webservice/webservice-listener.cpp
    tuscany/sca-cpp/trunk/configure.ac
    tuscany/sca-cpp/trunk/hosting/server/client-test.cpp
    tuscany/sca-cpp/trunk/hosting/server/client-test.hpp
    tuscany/sca-cpp/trunk/patches/scribe-2.2.patch
    tuscany/sca-cpp/trunk/samples/store-cpp/fruits-catalog.cpp
    tuscany/sca-cpp/trunk/samples/store-cpp/shopping-cart.cpp
    tuscany/sca-cpp/trunk/samples/store-java/Makefile.am
    tuscany/sca-cpp/trunk/samples/store-scheme/Makefile.am
    tuscany/sca-cpp/trunk/samples/store-scheme/script-test.cpp

Modified: tuscany/sca-cpp/trunk/INSTALL
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/INSTALL?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/INSTALL (original)
+++ tuscany/sca-cpp/trunk/INSTALL Tue Dec 11 06:13:02 2012
@@ -31,11 +31,11 @@ The installation script will display eac
 That's all you need to do to build and install the Tuscany SCA runtime on
 Ubuntu Server.
 
-Automated installation on Max OS X 10.7.4
-=========================================
+Automated installation on Max OS X 10.8
+=======================================
 
-Tuscany provides an automated install script for Mac OS X 10.7.4 and Xcode 4.1.
-You can start with a fresh Mac OS X 10.7.4 + Xcode 4.1 system and the script
+Tuscany provides an automated install script for Mac OS X 10.8 and Xcode 4.4.
+You can start with a fresh Mac OS X 10.8 + Xcode 4.4 system and the script
 will take care of all the download, build and installation steps for you.
 
 macos/macos-install:
@@ -89,12 +89,11 @@ XML:
 libxml2-2.7.7 (http://xmlsoft.org/)
 
 CURL:
-curl-7-24.0
+curl-7-28.0 (http://curl.haxx.se)
+built with c-ares-1.9.1 (http://c-ares.haxx.se)
 
 JSON:
-Mozilla SpiderMonkey libmozjs 1.8.5 and
-(https://developer.mozilla.org/en/SpiderMonkey)
-built with Mozilla nspr-4.8.8
+Jansson 2.4 (http://www.digip.org/jansson/)
 
 Key/value persistent store:
 tinycdb-0.77 (http://www.corpit.ru/mjt/tinycdb.html)
@@ -143,16 +142,13 @@ Apache Vysper 0.5 (http://mina.apache.or
 Libstrophe (http://code.stanziq.com/strophe/)
 build it from source at git://github.com/jsdelfino/libstrophe.git
 
-Key/value persistent store:
-Google LevelDB 1.2 (http://code.google.com/p/leveldb/)
-
 SQL database:
 PostgreSQL 9.1.2 (http://www.postgresql.org/)
 PgBouncer 1.5 (http://wiki.postgresql.org/wiki/PgBouncer)
 
 Logging:
 Facebook Scribe 2.2 (http://github.com/facebook/scribe/downloads)
-requires Apache Thrift 0.2.0 (http://incubator.apache.org/thrift/)
+requires Apache Thrift 0.8.0 (http://incubator.apache.org/thrift/)
 
 Cloud deployment:
 Apache Libcloud 0.3.1 (http://incubator.apache.org/libcloud/)
@@ -228,7 +224,7 @@ most useful options and the correspondin
 
 ./configure --prefix=$build/tuscany-sca-cpp-bin \
 --enable-threads --enable-maintainer-mode \
---with-curl=$build/curl-7.24.0-bin --with-libxml2=$build/libxml2-2.7.7-bin \
+--with-curl=$build/curl-7.28.0-bin --with-libxml2=$build/libxml2-2.7.7-bin \
 --with-apr=$build/apr-1.4.6-bin --with-apr-util=$build/apr-util-1.4.1-bin \
 --with-httpd=$build/httpd-2.4.2-bin \
 --with-memcached=$build/memcached-1.4.7-bin \
@@ -238,7 +234,7 @@ most useful options and the correspondin
 --enable-python --with-python=$build/python-2.7.3-bin \
 --enable-sqldb --with-pgsql=$build/postgresql-9.1.2-bin \
 --with-pgbouncer=$build/pgbouncer-1.5-bin \
---enable-log --with-thrift=$build/thrift-0.2.0-bin \
+--enable-log --with-thrift=$build/thrift-0.8.0-bin \
 --with-scribe=$build/scribe-2.2-bin \
 --enable-oauth --with-liboauth=$build/liboauth-0.9.1-bin \
 --enable-mod-security --with-mod-security=$build/modsecurity-apache-2.6.6-bin \

Modified: tuscany/sca-cpp/trunk/README
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/README?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/README (original)
+++ tuscany/sca-cpp/trunk/README Tue Dec 11 06:13:02 2012
@@ -6,8 +6,8 @@ in C++ and integrated with the Apache HT
 
 It supports SCA components written in C++ and Python. Experimental support
 for other programming languages is under construction. SCA bindings are
-available for the JSON-RPC, ATOMPub and RSS protocols. User signin is
-implemented using OpenID and OAuth.
+available for REST services and the JSON-RPC, ATOMPub and RSS protocols.
+User signin is implemented using OpenID and OAuth.
 
 Several useful SCA components are provided on top of the SCA runtime, which
 can be used to help assemble distributed SCA composite applications:
@@ -18,7 +18,6 @@ Constdb: fast persistent store for mostl
 Filedb: key/value persistent store, using plain files;
 Http: HTTP client, using Libcurl;
 Smtp: SMTP client, using Libcurl;
-Kvdb: fast key/value persistent store, using LevelDB;
 Log: distributed logger, using Facebook Scribe;
 Queue: AMQP queuing, using Apache Qpid/C;
 Sqldb: SQL database, using PostgreSQL and PgBouncer;
@@ -78,7 +77,6 @@ Here's a rough guide to the Tuscany SCA 
  |   |   |-- constdb          TinyCDB constant persistent store
  |   |   |-- filedb           Plain file persistent store
  |   |   |-- http             HTTP client
- |   |   |-- kvdb             LevelDB key/value persistent store
  |   |   |-- log              Scribe logger
  |   |   |-- queue            AMQP message queue
  |   |   |-- smtp             SMTP client
@@ -99,6 +97,7 @@ Here's a rough guide to the Tuscany SCA 
  |   |-- macos                Automated install on Mac OS X 10.7.4
  |   |-- ubuntu               Automated install on Ubuntu 12.04
  |   |-- patches              Temporary patches to some of the dependencies
+ |   |-- unmaintained         Unmaintained or outdated modules
  |
  |-- branches                 Topic and release branches
  |

Modified: tuscany/sca-cpp/trunk/components/cache/Makefile.am
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/cache/Makefile.am?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/cache/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/components/cache/Makefile.am Tue Dec 11 06:13:02 2012
@@ -50,7 +50,7 @@ memcache_test_SOURCES = memcache-test.cp
 memcache_test_LDFLAGS = -lxml2
 
 client_test_SOURCES = client-test.cpp
-client_test_LDFLAGS = -lxml2 -lcurl -lmozjs
+client_test_LDFLAGS = -lxml2 -lcurl -ljansson
 
 dist_noinst_SCRIPTS = memcached-test memcached-ssl-test server-test
 noinst_PROGRAMS = memcache-test client-test

Modified: tuscany/sca-cpp/trunk/components/cache/cache.composite
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/cache/cache.composite?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/cache/cache.composite (original)
+++ tuscany/sca-cpp/trunk/components/cache/cache.composite Tue Dec 11 06:13:02 2012
@@ -81,7 +81,7 @@
         <service name="selector">
             <binding.http uri="selector"/>
         </service>
-    </component>     
+    </component>
 
     <component name="partition1">
         <implementation.scheme script="partition1-test.scm"/>

Modified: tuscany/sca-cpp/trunk/components/cache/client-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/cache/client-test.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/cache/client-test.cpp (original)
+++ tuscany/sca-cpp/trunk/components/cache/client-test.cpp Tue Dec 11 06:13:02 2012
@@ -42,15 +42,15 @@ const string memocacheuri("http://localh
 const string partition1uri("http://localhost:8090/partitioner/a");
 const string partition2uri("http://localhost:8090/partitioner/b");
 
-bool testCache(const string& uri) {
-    http::CURLSession cs("", "", "", "", 0);
+const bool testCache(const string& uri) {
+    const http::CURLSession cs("", "", "", "", 0);
 
-    const list<value> i = list<value>() + "content" + (list<value>() + "item" 
-            + (list<value>() + "name" + string("Apple"))
-            + (list<value>() + "price" + string("$2.99")));
-    const list<value> a = list<value>() + (list<value>() + "entry" 
-            + (list<value>() + "title" + string("item"))
-            + (list<value>() + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
+    const list<value> i = nilListValue + "content" + (nilListValue + "item" 
+            + (nilListValue + "name" + string("Apple"))
+            + (nilListValue + "price" + string("$2.99")));
+    const list<value> a = nilListValue + (nilListValue + "entry" 
+            + (nilListValue + "title" + string("item"))
+            + (nilListValue + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
             + i);
 
     const failable<value> id = http::post(a, uri, cs);
@@ -63,18 +63,18 @@ bool testCache(const string& uri) {
         assert(content(val) == a);
     }
 
-    const list<value> j = list<value>() + "content" + (list<value>() + "item" 
-            + (list<value>() + "name" + string("Apple"))
-            + (list<value>() + "price" + string("$3.55")));
-    const list<value> b = list<value>() + (list<value>() + "entry" 
-            + (list<value>() + "title" + string("item"))
-            + (list<value>() + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
+    const list<value> j = nilListValue + "content" + (nilListValue + "item" 
+            + (nilListValue + "name" + string("Apple"))
+            + (nilListValue + "price" + string("$3.55")));
+    const list<value> b = nilListValue + (nilListValue + "entry" 
+            + (nilListValue + "title" + string("item"))
+            + (nilListValue + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
             + j);
 
     {
         const failable<value> r = http::put(b, uri + p, cs);
         assert(hasContent(r));
-        assert(content(r) == value(true));
+        assert(content(r) == trueValue);
     }
     {
         const failable<value> val = http::get(uri + p, cs);
@@ -84,7 +84,7 @@ bool testCache(const string& uri) {
     {
         const failable<value> r = http::del(uri + p, cs);
         assert(hasContent(r));
-        assert(content(r) == value(true));
+        assert(content(r) == trueValue);
     }
     {
         const failable<value> val = http::get(uri + p, cs);
@@ -94,16 +94,16 @@ bool testCache(const string& uri) {
     return true;
 }
 
-bool testMemcache() {
+const bool testMemcache() {
     return testCache(memcacheuri);
 }
 
-bool testDatacache() {
+const bool testDatacache() {
     return testCache(datacacheuri);
 }
 
-bool testMemocache() {
-    http::CURLSession cs("", "", "", "", 0);
+const bool testMemocache() {
+    const http::CURLSession cs("", "", "", "", 0);
 
     const failable<value> res = http::evalExpr(mklist<value>(string("add"), 33, 22), memocacheuri, cs);
     assert(hasContent(res));
@@ -116,8 +116,8 @@ bool testMemocache() {
     return true;
 }
 
-bool testPartitioner() {
-    http::CURLSession cs("", "", "", "", 0);
+const bool testPartitioner() {
+    const http::CURLSession cs("", "", "", "", 0);
 
     const failable<value> res1 = http::get(partition1uri, cs);
     assert(hasContent(res1));
@@ -130,35 +130,26 @@ bool testPartitioner() {
     return true;
 }
 
-struct getLoop {
-    const string path;
-    const value entry;
-    http::CURLSession& cs;
-    getLoop(const string& path, const value& entry, http::CURLSession& cs) : path(path), entry(entry), cs(cs) {
-    }
-    const bool operator()() const {
-        const failable<value> val = http::get(memcacheuri + path, cs);
-        assert(hasContent(val));
-        assert(content(val) == entry);
-        return true;
-    }
-};
-
-bool testGetPerf() {
-    const list<value> i = list<value>() + "content" + (list<value>() + "item" 
-            + (list<value>() + "name" + string("Apple"))
-            + (list<value>() + "price" + string("$4.55")));
-    const list<value> a = list<value>() + (list<value>() + "entry" 
-            + (list<value>() + "title" + string("item"))
-            + (list<value>() + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
+const bool testGetPerf() {
+    const list<value> i = nilListValue + "content" + (nilListValue + "item" 
+            + (nilListValue + "name" + string("Apple"))
+            + (nilListValue + "price" + string("$4.55")));
+    const list<value> a = nilListValue + (nilListValue + "entry" 
+            + (nilListValue + "title" + string("item"))
+            + (nilListValue + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
             + i);
 
-    http::CURLSession cs("", "", "", "", 0);
+    const http::CURLSession cs("", "", "", "", 0);
     const failable<value> id = http::post(a, memcacheuri, cs);
     assert(hasContent(id));
     const string p = path(content(id));
 
-    const lambda<bool()> gl = getLoop(p, a, cs);
+    const blambda gl = [p, a, cs]() -> const bool {
+        const failable<value> val = http::get(memcacheuri + p, cs);
+        assert(hasContent(val));
+        assert(content(val) == a);
+        return true;
+    };
     cout << "Cache get test " << time(gl, 5, 200) << " ms" << endl;
 
     return true;

Modified: tuscany/sca-cpp/trunk/components/cache/datacache.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/cache/datacache.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/cache/datacache.cpp (original)
+++ tuscany/sca-cpp/trunk/components/cache/datacache.cpp Tue Dec 11 06:13:02 2012
@@ -44,7 +44,7 @@ namespace datacache {
 /**
  * Get an item from the cache.
  */
-const failable<value> get(const value& key, const lambda<value(const list<value>&)>& rcache1, const lambda<value(const list<value>&)>& wcache1, const lambda<value(const list<value>&)>& rcache2, unused const lambda<value(const list<value>&)>& wcache2) {
+const failable<value> get(const value& key, const lvvlambda& rcache1, const lvvlambda& wcache1, const lvvlambda& rcache2, unused const lvvlambda& wcache2) {
 
     // Lookup level1 cache
     const value val1 = rcache1(mklist<value>("get", key));
@@ -68,7 +68,7 @@ const failable<value> get(const value& k
 /**
  * Post an item to the cache.
  */
-const failable<value> post(const value& key, const value& val, unused const lambda<value(const list<value>&)>& rcache1, const lambda<value(const list<value>&)>& wcache1, unused const lambda<value(const list<value>&)>& rcache2, const lambda<value(const list<value>&)>& wcache2) {
+const failable<value> post(const value& key, const value& val, unused const lvvlambda& rcache1, const lvvlambda& wcache1, unused const lvvlambda& rcache2, const lvvlambda& wcache2) {
     const value id = append<value>(key, mklist(mkuuid()));
 
     // Update level1 cache
@@ -83,7 +83,7 @@ const failable<value> post(const value& 
 /**
  * Put an item into the cache.
  */
-const failable<value> put(const value& key, const value& val, unused const lambda<value(const list<value>&)>& rcache1, const lambda<value(const list<value>&)>& wcache1, unused const lambda<value(const list<value>&)>& rcache2, const lambda<value(const list<value>&)>& wcache2) {
+const failable<value> put(const value& key, const value& val, unused const lvvlambda& rcache1, const lvvlambda& wcache1, unused const lvvlambda& rcache2, const lvvlambda& wcache2) {
 
     // Update level1 cache
     wcache1(mklist<value>("put", key, val));
@@ -91,13 +91,13 @@ const failable<value> put(const value& k
     // Update level2 cache
     wcache2(mklist<value>("put", key, val));
 
-    return value(true);
+    return trueValue;
 }
 
 /**
  * Delete an item from the cache.
  */
-const failable<value> del(const value& key, unused const lambda<value(const list<value>&)>& rcache1, const lambda<value(const list<value>&)>& wcache1, unused const lambda<value(const list<value>&)>& rcache2, const lambda<value(const list<value>&)>& wcache2) {
+const failable<value> del(const value& key, unused const lvvlambda& rcache1, const lvvlambda& wcache1, unused const lvvlambda& rcache2, const lvvlambda& wcache2) {
 
     // Delete from level1 cache
     wcache1(mklist<value>("delete", key));
@@ -105,7 +105,7 @@ const failable<value> del(const value& k
     // Delete from level2 cache
     wcache2(mklist<value>("delete", key));
 
-    return value(true);
+    return trueValue;
 }
 
 }

Modified: tuscany/sca-cpp/trunk/components/cache/memcache-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/cache/memcache-test.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/cache/memcache-test.cpp (original)
+++ tuscany/sca-cpp/trunk/components/cache/memcache-test.cpp Tue Dec 11 06:13:02 2012
@@ -33,7 +33,7 @@ namespace tuscany {
 namespace memcache {
 
 bool testMemCached() {
-    MemCached ch(mklist<string>("localhost:11211", "localhost:11212", "localhost:11213"));
+    const MemCached ch(mklist<string>("localhost:11211", "localhost:11212", "localhost:11213"));
     const value k = mklist<value>("a");
 
     assert(hasContent(post(k, string("AAA"), ch)));
@@ -46,24 +46,16 @@ bool testMemCached() {
     return true;
 }
 
-struct getLoop {
-    const value k;
-    MemCached& ch;
-    getLoop(const value& k, MemCached& ch) : k(k), ch(ch) {
-    }
-    const bool operator()() const {
-        gc_scoped_pool p;
-        assert(get(k, ch) == value(string("CCC")));
-        return true;
-    }
-};
-
-bool testGetPerf() {
+const bool testGetPerf() {
     const value k = mklist<value>("c");
-    MemCached ch(mklist<string>("localhost:11211", "localhost:11212", "localhost:11213"));
+    const MemCached ch(mklist<string>("localhost:11211", "localhost:11212", "localhost:11213"));
     assert(hasContent(post(k, string("CCC"), ch)));
 
-    const lambda<bool()> gl = getLoop(k, ch);
+    const blambda gl = [k, ch]() -> const bool {
+        const gc_scoped_pool p;
+        assert(get(k, ch) == value(string("CCC")));
+        return true;
+    };
     cout << "Memcached get test " << time(gl, 5, 200) << " ms" << endl;
     return true;
 }
@@ -72,7 +64,7 @@ bool testGetPerf() {
 }
 
 int main() {
-    tuscany::gc_scoped_pool p;
+    const tuscany::gc_scoped_pool p;
     tuscany::cout << "Testing..." << tuscany::endl;
 
     tuscany::memcache::testMemCached();

Modified: tuscany/sca-cpp/trunk/components/cache/memcache.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/cache/memcache.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/cache/memcache.cpp (original)
+++ tuscany/sca-cpp/trunk/components/cache/memcache.cpp Tue Dec 11 06:13:02 2012
@@ -37,14 +37,14 @@ namespace cache {
 /**
  * Get an item from the cache.
  */
-const failable<value> get(const list<value>& params, memcache::MemCached& ch) {
+const failable<value> get(const list<value>& params, const memcache::MemCached& ch) {
     return memcache::get(car(params), ch);
 }
 
 /**
  * Post an item to the cache.
  */
-const failable<value> post(const list<value>& params, memcache::MemCached& ch) {
+const failable<value> post(const list<value>& params, const memcache::MemCached& ch) {
     const value id = append<value>(car(params), mklist(mkuuid()));
     const failable<bool> val = memcache::post(id, cadr(params), ch);
     if (!hasContent(val))
@@ -55,7 +55,7 @@ const failable<value> post(const list<va
 /**
  * Put an item into the cache.
  */
-const failable<value> put(const list<value>& params, memcache::MemCached& ch) {
+const failable<value> put(const list<value>& params, const memcache::MemCached& ch) {
     const failable<bool> val = memcache::put(car(params), cadr(params), ch);
     if (!hasContent(val))
         return mkfailure<value>(val);
@@ -65,7 +65,7 @@ const failable<value> put(const list<val
 /**
  * Delete an item from the cache.
  */
-const failable<value> del(const list<value>& params, memcache::MemCached& ch) {
+const failable<value> del(const list<value>& params, const memcache::MemCached& ch) {
     const failable<bool> val = memcache::del(car(params), ch);
     if (!hasContent(val))
         return mkfailure<value>(val);
@@ -73,37 +73,12 @@ const failable<value> del(const list<val
 }
 
 /**
- * Component implementation lambda function.
- */
-class applyCache {
-public:
-    applyCache(memcache::MemCached& ch) : ch(ch) {
-    }
-
-    const value operator()(const list<value>& params) const {
-        const value func(car(params));
-        if (func == "get")
-            return get(cdr(params), ch);
-        if (func == "post")
-            return post(cdr(params), ch);
-        if (func == "put")
-            return put(cdr(params), ch);
-        if (func == "delete")
-            return del(cdr(params), ch);
-        return mkfailure<value>();
-    }
-
-private:
-    memcache::MemCached& ch;
-};
-
-/**
  * Convert a list of properties to a list of server addresses.
  */
 const list<string> servers(const list<value>& params) {
     if (isNil(params))
         return list<string>();
-    const value s = ((lambda<value(const list<value>&)>)car(params))(list<value>());
+    const value s = ((lvvlambda)car(params))(nilListValue);
     return cons<string>(s, servers(cdr(params)));
 }
 
@@ -112,10 +87,22 @@ const list<string> servers(const list<va
  */
 const failable<value> start(const list<value>& params) {
     // Connect to memcached
-    memcache::MemCached& ch = *(new (gc_new<memcache::MemCached>()) memcache::MemCached(servers(params)));
+    const memcache::MemCached& ch = *(new (gc_new<memcache::MemCached>()) memcache::MemCached(servers(params)));
 
     // Return the component implementation lambda function
-    return value(lambda<value(const list<value>&)>(applyCache(ch)));
+    const lvvlambda applyCache = [ch](const list<value>& params) -> const value {
+        const value func(car(params));
+        if (func == "get")
+            return get(cdr(params), ch);
+        if (func == "post")
+            return post(cdr(params), ch);
+        if (func == "put")
+            return put(cdr(params), ch);
+        if (func == "delete")
+            return del(cdr(params), ch);
+        return mkfailure<value>();
+    };
+    return value(applyCache);
 }
 
 }

Modified: tuscany/sca-cpp/trunk/components/cache/memcache.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/cache/memcache.hpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/cache/memcache.hpp (original)
+++ tuscany/sca-cpp/trunk/components/cache/memcache.hpp Tue Dec 11 06:13:02 2012
@@ -48,43 +48,28 @@ namespace memcache {
  */
 class MemCached {
 public:
-    MemCached() : owner(false) {
+    MemCached() : owner(false), mc(NULL) {
     }
 
-    MemCached(const string host, const int port) : p(), owner(true) {
-        debug(host, "memcache::memcached::host");
-        debug(port, "memcache::memcached::port");
-        apr_memcache_create(pool(p), 1, 0, &mc);
-        addServer(host, port);
+    MemCached(const string& host, const int port) : p(), owner(true), mc(mkmc(host, port)) {
     }
 
-    MemCached(const list<string>& servers) : p(), owner(true) {
-        debug(servers, "memcache::memcached::servers");
-        apr_memcache_create(pool(p), (apr_uint16_t)length(servers), 0, &mc);
-        addServers(servers);
+    MemCached(const list<string>& servers) : p(), owner(true), mc(mkmc(servers)) {
     }
 
     MemCached(const MemCached& c) : p(c.p), owner(false), mc(c.mc) {
         debug("memcache::memcached::copy");
     }
 
-    const MemCached& operator=(const MemCached& c) {
-        debug("memcache::memcached::operator=");
-        if(this == &c)
-            return *this;
-        p = c.p;
-        owner = false;
-        mc = c.mc;
-        return *this;
-    }
+    MemCached& operator=(const MemCached& c) = delete;
 
     ~MemCached() {
     }
 
 private:
-    gc_child_pool p;
-    bool owner;
-    apr_memcache_t* mc;
+    const gc_child_pool p;
+    const bool owner;
+    apr_memcache_t* const mc;
 
     friend const failable<bool> post(const value& key, const value& val, const MemCached& cache);
     friend const failable<bool> put(const value& key, const value& val, const MemCached& cache);
@@ -94,7 +79,7 @@ private:
     /**
      * Add servers to the memcached context.
      */
-    const failable<bool> addServer(const string& host, const int port) {
+    const failable<bool> addServer(apr_memcache_t* const m, const string& host, const int port) {
         apr_memcache_server_t *server;
         const apr_status_t sc = apr_memcache_server_create(pool(p), c_str(host), (apr_port_t)port, 1, 1, 1, 600, &server);
         if (sc != APR_SUCCESS) {
@@ -102,27 +87,48 @@ private:
             os << "Couldn't connect to memcached server: " << host << ":" << port;
             return mkfailure<bool>(str(os));
         }
-        const apr_status_t as = apr_memcache_add_server(mc, server);
+        const apr_status_t as = apr_memcache_add_server(m, server);
         if (as != APR_SUCCESS)
             return mkfailure<bool>("Couldn't add memcached server");
         return true;
     }
 
-    const failable<bool> addServers(const list<string>& servers) {
+    const failable<bool> addServers(apr_memcache_t* const m, const list<string>& servers) {
         if (isNil(servers))
             return true;
         const list<string> toks = tokenize(":", car(servers));
-        const failable<bool> r = addServer(car(toks), isNil(cdr(toks))? 11211 : atoi(c_str(cadr(toks))));
+        const failable<bool> r = addServer(m, car(toks), isNil(cdr(toks))? 11211 : atoi(c_str(cadr(toks))));
         if (!hasContent(r))
             return r;
-        return addServers(cdr(servers));
+        return addServers(m, cdr(servers));
+    }
+
+    /**
+     * Create memcached handle.
+     */
+    apr_memcache_t* const mkmc(const string& host, const int port) {
+        debug(host, "memcache::memcached::host");
+        debug(port, "memcache::memcached::port");
+        apr_memcache_t* m;
+        apr_memcache_create(pool(p), 1, 0, &m);
+        addServer(m, host, port);
+        return m;
     }
+
+    apr_memcache_t* const mkmc(const list<string>& servers) {
+        debug(servers, "memcache::memcached::servers");
+        apr_memcache_t* m;
+        apr_memcache_create(pool(p), (apr_uint16_t)length(servers), 0, &m);
+        addServers(m, servers);
+        return m;
+    }
+
 };
 
 /**
  * Replace spaces by tabs (as spaces are not allowed in memcached keys).
  */
-const char* nospaces(const char* s) {
+const char* const nospaces(const char* const s) {
     char* c = const_cast<char*>(s);
     for (; *c; c++)
         if (*c == ' ')
@@ -137,8 +143,8 @@ const failable<bool> post(const value& k
     debug(key, "memcache::post::key");
     debug(val, "memcache::post::value");
 
-    const string ks(scheme::writeValue(key));
-    const string vs(scheme::writeValue(val));
+    const string ks(write(content(scheme::writeValue(key))));
+    const string vs(write(content(scheme::writeValue(val))));
     const apr_status_t rc = apr_memcache_add(cache.mc, nospaces(c_str(ks)), const_cast<char*>(c_str(vs)), length(vs), 0, 27);
     if (rc != APR_SUCCESS) {
         ostringstream os;
@@ -157,8 +163,8 @@ const failable<bool> put(const value& ke
     debug(key, "memcache::put::key");
     debug(val, "memcache::put::value");
 
-    const string ks(scheme::writeValue(key));
-    const string vs(scheme::writeValue(val));
+    const string ks(write(content(scheme::writeValue(key))));
+    const string vs(write(content(scheme::writeValue(val))));
     const apr_status_t rc = apr_memcache_set(cache.mc, nospaces(c_str(ks)), const_cast<char*>(c_str(vs)), length(vs), 0, 27);
     if (rc != APR_SUCCESS) {
         ostringstream os;
@@ -176,17 +182,17 @@ const failable<bool> put(const value& ke
 const failable<value> get(const value& key, const MemCached& cache) {
     debug(key, "memcache::get::key");
 
-    const string ks(scheme::writeValue(key));
+    const string ks(write(content(scheme::writeValue(key))));
     char *data;
     apr_size_t size;
-    gc_local_pool lp;
+    const gc_local_pool lp;
     const apr_status_t rc = apr_memcache_getp(cache.mc, pool(lp), nospaces(c_str(ks)), &data, &size, NULL);
     if (rc != APR_SUCCESS) {
         ostringstream os;
         os << "Couldn't get memcached entry: " << key;
         return mkfailure<value>(str(os), 404, false);
     }
-    const value val(scheme::readValue(string(data, size)));
+    const value val(content(scheme::readValue(string(data, size))));
 
     debug(val, "memcache::get::result");
     return val;
@@ -198,7 +204,7 @@ const failable<value> get(const value& k
 const failable<bool> del(const value& key, const MemCached& cache) {
     debug(key, "memcache::delete::key");
 
-    const string ks(scheme::writeValue(key));
+    const string ks(write(content(scheme::writeValue(key))));
     const apr_status_t rc = apr_memcache_delete(cache.mc, nospaces(c_str(ks)), 0);
     if (rc != APR_SUCCESS) {
         ostringstream os;

Modified: tuscany/sca-cpp/trunk/components/cache/memocache.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/cache/memocache.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/cache/memocache.cpp (original)
+++ tuscany/sca-cpp/trunk/components/cache/memocache.cpp Tue Dec 11 06:13:02 2012
@@ -42,7 +42,7 @@ namespace memocache {
 /**
  * Memoize the value of a function application in a cache.
  */
-const failable<value> memoize(const list<value>& params, const lambda<value(const list<value>&)>& relay, const lambda<value(const list<value>&)>& cache) {
+const failable<value> memoize(const list<value>& params, const lvvlambda& relay, const lvvlambda& cache) {
     debug(params, "memocache::memoize::params");
 
     // Lookup memoized value from cache

Modified: tuscany/sca-cpp/trunk/components/cache/partitioner.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/cache/partitioner.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/cache/partitioner.cpp (original)
+++ tuscany/sca-cpp/trunk/components/cache/partitioner.cpp Tue Dec 11 06:13:02 2012
@@ -22,7 +22,7 @@
 /**
  * A partitioner component implementation which forwards data access requests to a
  * dynamically selected data store component. The selection is externalized, performed
- * by a selector component, responsible for selecting the target data store given the
+ * by a selector component, responsible for selecting the target data stores given the
  * data access request key and a list of references to available data store components.
  * This pattern can be used for sharding or load balancing for example.
  */
@@ -38,54 +38,89 @@ namespace tuscany {
 namespace partitioner {
 
 /**
- * Return the target partition for a key.
+ * Return a list of target partitions for a key.
  */
-const failable<lambda<value(const list<value>&)> > partition(const value& key, const lambda<value(const list<value>&)>& selector, const list<value>& partitions) {
+const failable<list<value> > partition(const value& key, const lvvlambda& selector, const list<value>& partitions) {
 
-    // Call the selector component to convert the given key to a partition number
+    // Call the selector component to convert the given key to a list of partitions
     const value p = selector(mklist<value>("get", key, partitions));
     if (isNil(p)) {
         ostringstream os;
-        os << "Couldn't get partition number: " << key;
-        return mkfailure<lambda<value(const list<value>&)> >(str(os), -1, false);
+        os << "Couldn't get partition: " << key;
+        return mkfailure<list<value> >(str(os), -1, false);
     }
-    return (const lambda<value(const list<value>&)>)p;
+    return (list<value>)p;
+}
+
+
+/**
+ * Get lists of items from a list of partitions.
+ */
+const failable<list<value> > getlist(const value& key, const list<value>& partitions) {
+    if (isNil(partitions))
+        return nilListValue;
+
+    const lvvlambda l = car(partitions);
+    const value val = l(mklist<value>("get", key));
+    if (isNil(val))
+        return getlist(key, cdr(partitions));
+    if (!isList(val)) {
+        ostringstream os;
+        os << "Couldn't get list of entries from partition: " << key;
+        return mkfailure<list<value> >(str(os), 500, false);
+    }
+
+    const failable<list<value> > cdrval = getlist(key, cdr(partitions));
+    if (!hasContent(cdrval))
+        return cdrval;
+
+    return append<value>((list<value>)val, content(cdrval));
 }
 
 /**
  * Get an item from a partition.
  */
-const failable<value> get(const value& key, const lambda<value(const list<value>&)>& selector, const list<value>& partitions) {
+const failable<value> get(const value& key, const lvvlambda& selector, const list<value>& partitions) {
 
     // Select partition
-    const failable<lambda<value(const list<value>&)> > p = partition(key, selector, partitions);
-    if (!hasContent(p))
-        return mkfailure<value>(p);
-
-    // Get from selected partition
-    const value val = content(p)(mklist<value>("get", key));
-    if (isNil(val)) {
-        ostringstream os;
-        os << "Couldn't get entry from partition: " << key;
-        return mkfailure<value>(str(os), 404, false);
+    const failable<list<value> > fp = partition(key, selector, partitions);
+    if (!hasContent(fp))
+        return mkfailure<value>(fp);
+    const list<value> p = content(fp);
+
+    // Get a single item from the selected partition
+    if (length(p) == 1) {
+        const lvvlambda l = car(p);
+        const value val = l(mklist<value>("get", key));
+        if (isNil(val)) {
+            ostringstream os;
+            os << "Couldn't get entry from partition: " << key;
+            return mkfailure<value>(str(os), 404, false);
+        }
+        return val;
     }
 
-    return val;
+    // Get list of items from the list of selected partitions
+    const failable<list<value> > val = getlist(key, p);
+    if (!hasContent(val))
+        return mkfailure<value>(val);
+    return (value)content(val);
 }
 
 /**
  * Post an item to a partition.
  */
-const failable<value> post(const value& key, const value& val, const lambda<value(const list<value>&)>& selector, const list<value>& partitions) {
+const failable<value> post(const value& key, const value& val, const lvvlambda& selector, const list<value>& partitions) {
     const value id = append<value>(key, mklist(mkuuid()));
 
     // Select partition
-    const failable<lambda<value(const list<value>&)> > p = partition(id, selector, partitions);
+    const failable<list<value> > p = partition(id, selector, partitions);
     if (!hasContent(p))
         return mkfailure<value>(p);
 
     // Put into select partition
-    content(p)(mklist<value>("put", id, val));
+    const lvvlambda l = car(content(p));
+    l(mklist<value>("post", id, val));
 
     return id;
 }
@@ -93,33 +128,35 @@ const failable<value> post(const value& 
 /**
  * Put an item into a partition.
  */
-const failable<value> put(const value& key, const value& val, const lambda<value(const list<value>&)>& selector, const list<value>& partitions) {
+const failable<value> put(const value& key, const value& val, const lvvlambda& selector, const list<value>& partitions) {
 
     // Select partition
-    const failable<lambda<value(const list<value>&)> > p = partition(key, selector, partitions);
+    const failable<list<value> > p = partition(key, selector, partitions);
     if (!hasContent(p))
         return mkfailure<value>(p);
 
     // Put into selected partition
-    content(p)(mklist<value>("put", key, val));
+    const lvvlambda l = car(content(p));
+    l(mklist<value>("put", key, val));
 
-    return value(true);
+    return trueValue;
 }
 
 /**
  * Delete an item from a partition.
  */
-const failable<value> del(const value& key, const lambda<value(const list<value>&)>& selector, const list<value>& partitions) {
+const failable<value> del(const value& key, const lvvlambda& selector, const list<value>& partitions) {
 
     // Select partition
-    const failable<lambda<value(const list<value>&)> > p = partition(key, selector, partitions);
+    const failable<list<value> > p = partition(key, selector, partitions);
     if (!hasContent(p))
         return mkfailure<value>(p);
 
     // Delete from selected partition
-    content(p)(mklist<value>("delete", key));
+    const lvvlambda l = car(content(p));
+    l(mklist<value>("delete", key));
 
-    return value(true);
+    return trueValue;
 }
 
 }

Modified: tuscany/sca-cpp/trunk/components/cache/select-test.scm
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/cache/select-test.scm?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/cache/select-test.scm (original)
+++ tuscany/sca-cpp/trunk/components/cache/select-test.scm Tue Dec 11 06:13:02 2012
@@ -17,5 +17,5 @@
 
 ; Partition selector test case
 
-(define (get key partitions) (if (= (car key) "a") (car partitions) (cadr partitions)))
+(define (get key partitions) (if (= (car key) "a") (list (car partitions)) (list (cadr partitions))))
 

Modified: tuscany/sca-cpp/trunk/components/chat/Makefile.am
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/chat/Makefile.am?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/chat/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/components/chat/Makefile.am Tue Dec 11 06:13:02 2012
@@ -58,7 +58,7 @@ xmpp_test_SOURCES = xmpp-test.cpp
 xmpp_test_LDFLAGS = -L${LIBSTROPHE_LIB} -R${LIBSTROPHE_LIB} -lstrophe -lssl -lresolv
 
 client_test_SOURCES = client-test.cpp
-client_test_LDFLAGS = -lxml2 -lcurl -lmozjs -L${LIBSTROPHE_LIB} -R${LIBSTROPHE_LIB} -lstrophe -lssl -lresolv
+client_test_LDFLAGS = -lxml2 -lcurl -ljansson -L${LIBSTROPHE_LIB} -R${LIBSTROPHE_LIB} -lstrophe -lssl -lresolv
 
 comp_PROGRAMS = chat-send
 
@@ -67,12 +67,18 @@ dist_noinst_SCRIPTS = server-test
 
 if WANT_VYSPER
 
+noinst_DATA += test/TestVysperServer.class
+
 AM_JAVACFLAGS = -cp `${top_builddir}/components/chat/vysper-classpath ${VYSPER_PREFIX}`${JAVAROOT}
 dist_noinst_JAVA = test/*.java
+.java.class:
+	${JAVAC} ${AM_JAVACFLAGS} test/*.java
+
 CLEANFILES = test/*.class
 
 dist_noinst_SCRIPTS += echo-test
-TESTS = echo-test server-test
+#TESTS = echo-test server-test
+
 endif
 
 endif

Modified: tuscany/sca-cpp/trunk/components/chat/chat-send.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/chat/chat-send.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/chat/chat-send.cpp (original)
+++ tuscany/sca-cpp/trunk/components/chat/chat-send.cpp Tue Dec 11 06:13:02 2012
@@ -37,7 +37,7 @@
 namespace tuscany {
 namespace chat {
 
-bool sendmsg(const string& jid, const string& pass, const string& to, const string& msg) {
+const bool sendmsg(const string& jid, const string& pass, const string& to, const string& msg) {
     XMPPClient xc(jid, pass);
     const failable<bool> c = connect(xc);
     assert(hasContent(c));
@@ -49,7 +49,7 @@ bool sendmsg(const string& jid, const st
 }
 }
 
-int main(unused const int argc, const char** argv) {
+int main(unused const int argc, const char** const argv) {
     tuscany::chat::sendmsg(argv[1], argv[2], argv[3], argv[4]);
     return 0;
 }

Modified: tuscany/sca-cpp/trunk/components/chat/chat-sender.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/chat/chat-sender.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/chat/chat-sender.cpp (original)
+++ tuscany/sca-cpp/trunk/components/chat/chat-sender.cpp Tue Dec 11 06:13:02 2012
@@ -51,45 +51,38 @@ const failable<value> post(const list<va
 }
 
 /**
- * Subscribe and listen to an XMPP session.
+ * Start the component.
  */
-class noop {
-public:
-    noop() {
-    }
-
-    const failable<bool> operator()(unused const value& jid, unused const value& val, unused XMPPClient& xc) const {
-        return true;
-    }
-};
-
-class subscribe {
-public:
-    subscribe(XMPPClient& xc) : xc(xc) {
-    }
+const failable<value> start(const list<value>& params) {
+    // Extract the the XMPP JID and password
+    const list<value> props = params;
+    const value jid = ((lvvlambda)car(props))(nilListValue);
+    const value pass = ((lvvlambda)cadr(props))(nilListValue);
+
+    // Create an XMPP client session
+    XMPPClient xc(jid, pass, false);
+    const failable<bool> r = connect(xc);
+    if (!hasContent(r))
+        return mkfailure<value>(r);
 
-    const failable<bool> operator()() const {
-        gc_pool pool;
+    // Subscribe and listen to XMPP session
+    const lambda<const failable<bool>()> subscribe = [xc]() -> const failable<bool> {
+        const gc_pool pool;
         debug("chat::subscribe::listen");
-        const failable<bool> r = listen(noop(), const_cast<XMPPClient&>(xc));
+        const lambda<const failable<bool>(const value&, const value&, XMPPClient&)> noop = [](unused const value& jid, unused const value& val, unused XMPPClient& xc) -> const failable<bool> {
+            return true;
+        };
+        const failable<bool> r = listen(noop, const_cast<XMPPClient&>(xc));
         debug("chat::subscribe::stopped");
         return r;
-    }
-
-private:
-    const lambda<failable<bool>(const value&, const value&, XMPPClient&)> l;
-    XMPPClient xc;
-};
+    };
 
-/**
- * Chatter component lambda function
- */
-class chatSender {
-public:
-    chatSender(XMPPClient& xc, worker& w) : xc(xc), w(w) {
-    }
+    // Listen and relay messages in a worker thread
+    worker w(3);
+    submit<failable<bool> >(w, subscribe);
 
-    const value operator()(const list<value>& params) const {
+    // Return the chat sender component lambda function
+    const lvvlambda chatSender = [xc, w](const list<value>& params) -> const value {
         const tuscany::value func(car(params));
         if (func == "post")
             return post(cdr(params), const_cast<XMPPClient&>(xc));
@@ -104,35 +97,9 @@ public:
         cancel(const_cast<worker&>(w));
         debug("chat::sender::stopped");
 
-        return failable<value>(value(lambda<value(const list<value>&)>()));
-    }
-
-private:
-    const XMPPClient xc;
-    worker w;
-};
-
-/**
- * Start the component.
- */
-const failable<value> start(const list<value>& params) {
-    // Extract the the XMPP JID and password
-    const list<value> props = params;
-    const value jid = ((lambda<value(const list<value>&)>)car(props))(list<value>());
-    const value pass = ((lambda<value(const list<value>&)>)cadr(props))(list<value>());
-
-    // Create an XMPP client session
-    XMPPClient xc(jid, pass, false);
-    const failable<bool> r = connect(xc);
-    if (!hasContent(r))
-        return mkfailure<value>(r);
-
-    // Listen and relay messages in a worker thread
-    worker w(3);
-    submit<failable<bool> >(w, lambda<failable<bool>()>(subscribe(xc)));
-
-    // Return the chat sender component lambda function
-    return value(lambda<value(const list<value>&)>(chatSender(xc, w)));
+        return failable<value>(value(lvvlambda()));
+    };
+    return value(chatSender);
 }
 
 }

Modified: tuscany/sca-cpp/trunk/components/chat/chat-sender2.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/chat/chat-sender2.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/chat/chat-sender2.cpp (original)
+++ tuscany/sca-cpp/trunk/components/chat/chat-sender2.cpp Tue Dec 11 06:13:02 2012
@@ -41,7 +41,7 @@ namespace sender {
 /**
  * Post an item to an XMPP JID.
  */
-const failable<value> post(const lambda<value(const list<value>&)>& jid, const lambda<value(const list<value>&)>& pass, const lambda<value(const list<value>&)>& to, const lambda<value(const list<value>&)>& msg, const list<value>& params) {
+const failable<value> post(const lvvlambda& jid, const lvvlambda& pass, const lvvlambda& to, const lvvlambda& msg, const list<value>& params) {
 
     const value vjid = jid(mklist<value>("get", params));
     const value vpass = pass(mklist<value>("get", params));
@@ -65,14 +65,16 @@ const failable<value> post(const lambda<
 }
 
 /**
- * Chat sender component lambda function
+ * Start the component.
  */
-class chatSender {
-public:
-    chatSender(const lambda<value(const list<value>&)>& jid, const lambda<value(const list<value>&)>& pass, const lambda<value(const list<value>&)>& to, const lambda<value(const list<value>&)>& msg) : jid(jid), pass(pass), to(to), msg(msg) {
-    }
+const failable<value> start(const list<value>& params) {
 
-    const value operator()(const list<value>& params) const {
+    // Return the chat sender component lambda function
+    const lvvlambda jid = car(params);
+    const lvvlambda pass = cadr(params);
+    const lvvlambda to = caddr(params);
+    const lvvlambda msg = cadddr(params);
+    const lvvlambda sender = [jid, pass, to, msg](const list<value>& params) -> const value {
         const tuscany::value func(car(params));
         if (func == "get")
             return post(jid, pass, to, msg, cdr(params));
@@ -81,23 +83,9 @@ public:
         if (func != "stop")
             return mkfailure<value>();
         debug("chat::sender::stop");
-        return failable<value>(value(lambda<value(const list<value>&)>()));
-    }
-
-private:
-    const lambda<value(const list<value>&)> jid;
-    const lambda<value(const list<value>&)> pass;
-    const lambda<value(const list<value>&)> to;
-    const lambda<value(const list<value>&)> msg;
-};
-
-/**
- * Start the component.
- */
-const failable<value> start(const list<value>& params) {
-
-    // Return the chat sender component lambda function
-    return value(lambda<value(const list<value>&)>(chatSender(car(params), cadr(params), caddr(params), cadddr(params))));
+        return failable<value>(value(lvvlambda()));
+    };
+    return value(sender);
 }
 
 }

Modified: tuscany/sca-cpp/trunk/components/chat/chat-sendreceiver.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/chat/chat-sendreceiver.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/chat/chat-sendreceiver.cpp (original)
+++ tuscany/sca-cpp/trunk/components/chat/chat-sendreceiver.cpp Tue Dec 11 06:13:02 2012
@@ -51,56 +51,46 @@ const failable<value> post(const list<va
 }
 
 /**
- * A relay function that posts the XMPP messages it receives to a relay component reference.
+ * Start the component.
  */
-class relay {
-public:
-    relay(const lambda<value(const list<value>&)>& rel) : rel(rel) {
-    }
+const failable<value> start(const list<value>& params) {
+    // Extract the relay reference and the XMPP JID and password
+    const bool hasRelay = !isNil(cddr(params));
+    const lvvlambda rel = hasRelay? (lvvlambda)car(params) : lvvlambda();
+    const list<value> props = hasRelay? cdr(params) : params;
+    const value jid = ((lvvlambda)car(props))(nilListValue);
+    const value pass = ((lvvlambda)cadr(props))(nilListValue);
+
+    // Create an XMPP client session
+    XMPPClient xc(jid, pass, false);
+    const failable<bool> r = connect(xc);
+    if (!hasContent(r))
+        return mkfailure<value>(r);
 
-    const failable<bool> operator()(const value& jid, const value& val, unused XMPPClient& xc) const {
+    // Listen and relay messages in a worker thread
+    worker w(3);
+    const lambda<const failable<bool>(const value&, const value&, XMPPClient&)> rl = [rel](const value& jid, const value& val, unused XMPPClient& xc) -> const failable<bool> {
+        // A relay function that posts the XMPP messages it receives to a relay component reference.
         if (isNil(rel))
             return true;
         debug(jid, "chat::relay::jid");
         debug(val, "chat::relay::value");
         const value res = rel(mklist<value>("post", mklist<value>(jid), val));
         return true;
-    }
-
-private:
-    const lambda<value(const list<value>&)> rel;
-};
-
-/**
- * Subscribe and listen to an XMPP session.
- */
-class subscribe {
-public:
-    subscribe(const lambda<failable<bool>(const value&, const value&, XMPPClient&)>& l, XMPPClient& xc) : l(l), xc(xc) {
-    }
+    };
 
-    const failable<bool> operator()() const {
-        gc_pool pool;
+    // Subscribe and listen to the XMPP session.
+    const lambda<const failable<bool>()> subscribe = [rl, xc]() -> const failable<bool> {
+        const gc_pool pool;
         debug("chat::subscribe::listen");
-        const failable<bool> r = listen(l, const_cast<XMPPClient&>(xc));
+        const failable<bool> r = listen(rl, const_cast<XMPPClient&>(xc));
         debug("chat::subscribe::stopped");
         return r;
-    }
-
-private:
-    const lambda<failable<bool>(const value&, const value&, XMPPClient&)> l;
-    XMPPClient xc;
-};
-
-/**
- * Chat sender/receiver component lambda function
- */
-class chatSenderReceiver {
-public:
-    chatSenderReceiver(XMPPClient& xc, worker& w) : xc(xc), w(w) {
-    }
+    };
+    submit<failable<bool> >(w, subscribe);
 
-    const value operator()(const list<value>& params) const {
+    // Return the chat sender/receiver component lambda function
+    const lvvlambda senderReceiver = [xc, w](const list<value>& params) -> const value {
         const tuscany::value func(car(params));
         if (func == "post")
             return post(cdr(params), const_cast<XMPPClient&>(xc));
@@ -115,38 +105,9 @@ public:
         cancel(const_cast<worker&>(w));
         debug("chat::sendreceiver::stopped");
 
-        return failable<value>(value(lambda<value(const list<value>&)>()));
-    }
-
-private:
-    const XMPPClient xc;
-    worker w;
-};
-
-/**
- * Start the component.
- */
-const failable<value> start(const list<value>& params) {
-    // Extract the relay reference and the XMPP JID and password
-    const bool hasRelay = !isNil(cddr(params));
-    const value rel = hasRelay? car(params) : value(lambda<value(const list<value>&)>());
-    const list<value> props = hasRelay? cdr(params) : params;
-    const value jid = ((lambda<value(const list<value>&)>)car(props))(list<value>());
-    const value pass = ((lambda<value(const list<value>&)>)cadr(props))(list<value>());
-
-    // Create an XMPP client session
-    XMPPClient xc(jid, pass, false);
-    const failable<bool> r = connect(xc);
-    if (!hasContent(r))
-        return mkfailure<value>(r);
-
-    // Listen and relay messages in a worker thread
-    worker w(3);
-    const lambda<failable<bool>(const value&, const value&, XMPPClient&)> rl = relay(rel);
-    submit<failable<bool> >(w, lambda<failable<bool>()>(subscribe(rl, xc)));
-
-    // Return the chat sender/receiver component lambda function
-    return value(lambda<value(const list<value>&)>(chatSenderReceiver(xc, w)));
+        return failable<value>(value(lvvlambda()));
+    };
+    return value(senderReceiver);
 }
 
 }

Modified: tuscany/sca-cpp/trunk/components/chat/client-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/chat/client-test.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/chat/client-test.cpp (original)
+++ tuscany/sca-cpp/trunk/components/chat/client-test.cpp Tue Dec 11 06:13:02 2012
@@ -45,12 +45,12 @@ const value pass2("sca2");
 const value jid3("sca3@localhost");
 const value pass3("sca3");
 
-const list<value> item = list<value>() + "content" + (list<value>() + "item" 
-    + (list<value>() + "name" + string("Apple"))
-    + (list<value>() + "price" + string("$2.99")));
-const list<value> entry = list<value>() + (list<value>() + "entry" 
-    + (list<value>() + "title" + string("item"))
-    + (list<value>() + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
+const list<value> item = nilListValue + "content" + (nilListValue + "item" 
+    + (nilListValue + "name" + string("Apple"))
+    + (nilListValue + "price" + string("$2.99")));
+const list<value> entry = nilListValue + (nilListValue + "entry" 
+    + (nilListValue + "title" + string("item"))
+    + (nilListValue + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
     + item);
 
 worker w(2);
@@ -63,36 +63,29 @@ const failable<bool> listener(const valu
     return false;
 }
 
-struct subscribe {
-    XMPPClient& xc;
-    subscribe(XMPPClient& xc) : xc(xc) {
-    }
-    const failable<bool> operator()() const {
-        const lambda<failable<bool>(const value&, const value&, XMPPClient&)> l(listener);
-        listen(l, xc);
-        return true;
-    }
-};
-
-bool testListen() {
+const bool testListen() {
     received = false;
     XMPPClient& xc = *(new (gc_new<XMPPClient>()) XMPPClient(jid3, pass3));
     const failable<bool> c = connect(xc);
     assert(hasContent(c));
-    const lambda<failable<bool>()> subs = subscribe(xc);
+    const lambda<const failable<bool>()> subs = [&xc]() -> const failable<bool> {
+        const lambda<const failable<bool>(const value&, const value&, XMPPClient&)> l(listener);
+        listen(l, xc);
+        return true;
+    };
     submit(w, subs);
     return true;
 }
 
-bool testPost() {
-    gc_scoped_pool pool;
-    http::CURLSession ch("", "", "", "", 0);
+const bool testPost() {
+    const gc_scoped_pool pool;
+    const http::CURLSession ch("", "", "", "", 0);
     const failable<value> id = http::post(entry, "http://localhost:8090/print-sender/sca2@localhost", ch);
     assert(hasContent(id));
     return true;
 }
 
-bool testReceived() {
+const bool testReceived() {
     shutdown(w);
     assert(received == true);
     return true;

Modified: tuscany/sca-cpp/trunk/components/chat/xmpp-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/chat/xmpp-test.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/chat/xmpp-test.cpp (original)
+++ tuscany/sca-cpp/trunk/components/chat/xmpp-test.cpp Tue Dec 11 06:13:02 2012
@@ -52,28 +52,21 @@ const failable<bool> listener(const valu
     return false;
 }
 
-struct subscribe {
-    XMPPClient& xc;
-    subscribe(XMPPClient& xc) : xc(xc) {
-    }
-    const failable<bool> operator()() const {
-        const lambda<failable<bool>(const value&, const value&, XMPPClient&)> l(listener);
-        listen(l, xc);
-        return true;
-    }
-};
-
-bool testListen() {
+const bool testListen() {
     received = false;
     XMPPClient& xc = *(new (gc_new<XMPPClient>()) XMPPClient(jid2, pass2));
     const failable<bool> c = connect(xc);
     assert(hasContent(c));
-    const lambda<failable<bool>()> subs = subscribe(xc);
+    const lambda<const failable<bool>()> subs = [&xc]() -> const failable<bool> {
+        const lambda<const failable<bool>(const value&, const value&, XMPPClient&)> l(listener);
+        listen(l, xc);
+        return true;
+    };
     submit(w, subs);
     return true;
 }
 
-bool testPost() {
+const bool testPost() {
     XMPPClient xc(jid1, pass1);
     const failable<bool> c = connect(xc);
     assert(hasContent(c));
@@ -82,7 +75,7 @@ bool testPost() {
     return true;
 }
 
-bool testReceived() {
+const bool testReceived() {
     shutdown(w);
     assert(received == true);
     return true;

Modified: tuscany/sca-cpp/trunk/components/chat/xmpp.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/chat/xmpp.hpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/chat/xmpp.hpp (original)
+++ tuscany/sca-cpp/trunk/components/chat/xmpp.hpp Tue Dec 11 06:13:02 2012
@@ -66,8 +66,8 @@ private:
  */
 class XMPPClient {
 public:
-    XMPPClient(const string& jid, const string& pass, bool owner = true) : owner(owner), ctx(xmpp_ctx_new(NULL, xmppRuntime.log)), conn(xmpp_conn_new(ctx)), connecting(false), connected(false), disconnecting(false) {
-        xmpp_conn_set_jid(conn, c_str(jid + "/" + mkuuid()));
+    XMPPClient(const string& jid, const string& pass, const bool owner = true) : owner(owner), ctx(xmpp_ctx_new(NULL, xmppRuntime.log)), conn(xmpp_conn_new(ctx)), connecting(false), connected(false), disconnecting(false) {
+        xmpp_conn_set_jid(conn, c_str(jid + "/" + (string)mkuuid()));
         xmpp_conn_set_pass(conn, c_str(pass));
         debug(jid, "chat::xmppclient::jid");
     }
@@ -76,19 +76,7 @@ public:
         debug("chat::xmppclient::copy");
     }
 
-    const XMPPClient& operator=(const XMPPClient& xc) {
-        debug("chat::xmppclient::operator=");
-        if(this == &xc)
-            return *this;
-        owner = false;
-        ctx = xc.ctx;
-        conn = xc.conn;
-        listener = xc.listener;
-        connecting = xc.connecting;
-        connected = xc.connected;
-        disconnecting = xc.disconnecting;
-        return *this;
-    }
+    XMPPClient& operator=(const XMPPClient& xc) = delete;
 
     ~XMPPClient() {
         debug("chat::~xmppclient");
@@ -110,12 +98,12 @@ private:
     friend const failable<size_t> send(xmpp_stanza_t* const stanza, XMPPClient& xc);
     friend const failable<bool> post(const value& to, const value& val, XMPPClient& xc);
     friend const failable<bool> disconnect(XMPPClient& xc);
-    friend const failable<bool> listen(const lambda<failable<bool>(const value&, const value&, XMPPClient&)>& listener, XMPPClient& xc);
+    friend const failable<bool> listen(const lambda<const failable<bool>(const value&, const value&, XMPPClient&)>& listener, XMPPClient& xc);
 
-    bool owner;
+    const bool owner;
     xmpp_ctx_t* ctx;
     xmpp_conn_t* conn;
-    lambda<failable<bool>(const value&, const value&, XMPPClient&)> listener;
+    gc_mutable_ref<lambda<const failable<bool>(const value&, const value&, XMPPClient&)> > listener;
     bool connecting;
     bool connected;
     bool disconnecting;
@@ -124,8 +112,8 @@ private:
 /**
  * Make a text stanza.
  */
-xmpp_stanza_t* textStanza(const char* text, xmpp_ctx_t* ctx) {
-    xmpp_stanza_t* stanza = xmpp_stanza_new(ctx);
+xmpp_stanza_t* const textStanza(const char* const text, xmpp_ctx_t* const ctx) {
+    xmpp_stanza_t* const stanza = xmpp_stanza_new(ctx);
     xmpp_stanza_set_text(stanza, text);
     return stanza;
 }
@@ -133,8 +121,8 @@ xmpp_stanza_t* textStanza(const char* te
 /**
  * Make a named stanza.
  */
-xmpp_stanza_t* namedStanza(const char* ns, const char* name, xmpp_ctx_t* ctx) {
-    xmpp_stanza_t* stanza = xmpp_stanza_new(ctx);
+xmpp_stanza_t* const namedStanza(const char* const ns, const char* const name, xmpp_ctx_t* const ctx) {
+    xmpp_stanza_t* const stanza = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(stanza, name);
     if (ns != NULL)
         xmpp_stanza_set_ns(stanza, ns);
@@ -144,8 +132,8 @@ xmpp_stanza_t* namedStanza(const char* n
 /**
  * Make a named stanza using a qualified name.
  */
-xmpp_stanza_t* namedStanza(const char* name, xmpp_ctx_t* ctx) {
-    xmpp_stanza_t* stanza = xmpp_stanza_new(ctx);
+xmpp_stanza_t* const namedStanza(const char* const name, xmpp_ctx_t* const ctx) {
+    xmpp_stanza_t* const stanza = xmpp_stanza_new(ctx);
     xmpp_stanza_set_name(stanza, name);
     return stanza;
 }
@@ -157,16 +145,16 @@ int versionHandler(xmpp_conn_t* const co
     XMPPClient& xc = *(XMPPClient*)udata;
 
     // Build version reply stanza
-    xmpp_stanza_t* reply = namedStanza("iq", xc.ctx);
+    xmpp_stanza_t* const reply = namedStanza("iq", xc.ctx);
     xmpp_stanza_set_type(reply, "result");
     xmpp_stanza_set_id(reply, xmpp_stanza_get_id(stanza));
     xmpp_stanza_set_attribute(reply, "to", xmpp_stanza_get_attribute(stanza, "from"));
-    xmpp_stanza_t* query = namedStanza(xmpp_stanza_get_ns(xmpp_stanza_get_children(stanza)), "query", xc.ctx);
+    xmpp_stanza_t* const query = namedStanza(xmpp_stanza_get_ns(xmpp_stanza_get_children(stanza)), "query", xc.ctx);
     xmpp_stanza_add_child(reply, query);
-    xmpp_stanza_t* name = namedStanza("name", xc.ctx);
+    xmpp_stanza_t* const name = namedStanza("name", xc.ctx);
     xmpp_stanza_add_child(query, name);
     xmpp_stanza_add_child(name, textStanza("Apache Tuscany", xc.ctx));
-    xmpp_stanza_t* version = namedStanza("version", xc.ctx);
+    xmpp_stanza_t* const version = namedStanza("version", xc.ctx);
     xmpp_stanza_add_child(query, version);
     xmpp_stanza_add_child(version, textStanza("1.0", xc.ctx));
 
@@ -188,17 +176,18 @@ int messageHandler(unused xmpp_conn_t* c
 
     // Call the client listener function
     XMPPClient& xc = *(XMPPClient*)udata;
-    const char* from = xmpp_stanza_get_attribute(stanza, "from");
-    const char* text = xmpp_stanza_get_text(xmpp_stanza_get_child_by_name(stanza, "body"));
-    if (isNil(xc.listener))
+    const char* const from = xmpp_stanza_get_attribute(stanza, "from");
+    const char* const text = xmpp_stanza_get_text(xmpp_stanza_get_child_by_name(stanza, "body"));
+    if (isNil((lambda<const failable<bool>(const value&, const value&, XMPPClient&)>)xc.listener))
         return 1;
-    const value val(scheme::readValue(text));
+    const value val(content(scheme::readValue(text)));
     debug(from, "chat::messageHandler::from");
     debug(val, "chat::messageHandler::body");
-    const failable<bool> r = xc.listener(value(string(from)), val, xc);
+    const lambda<const failable<bool>(const value&, const value&, XMPPClient&)> listener = xc.listener;
+    const failable<bool> r = listener(value(string(from)), val, xc);
     if (!hasContent(r) || !content(r)) {
         // Stop listening
-        xc.listener = lambda<failable<bool>(const value&, const value&, XMPPClient&)>();
+        xc.listener = lambda<const failable<bool>(const value&, const value&, XMPPClient&)>();
         return 0;
     }
     return 1;
@@ -216,7 +205,7 @@ void connHandler(xmpp_conn_t * const con
         xmpp_handler_add(conn, versionHandler, "jabber:iq:version", "iq", NULL, &xc);
 
         // Send a <presence/> stanza so that we appear online to contacts
-        xmpp_stanza_t* pres = xmpp_stanza_new(xc.ctx);
+        xmpp_stanza_t* const pres = xmpp_stanza_new(xc.ctx);
         xmpp_stanza_set_name(pres, "presence");
         xmpp_send(conn, pres);
         xmpp_stanza_release(pres);
@@ -246,7 +235,7 @@ const failable<bool> connect(XMPPClient&
 /**
  * Send a buffer on an XMPP session.
  */
-const failable<size_t> send(const char* data, const size_t len, XMPPClient& xc) {
+const failable<size_t> send(const char* const data, const size_t len, XMPPClient& xc) {
     if (len == 0)
         return 0;
     const size_t written = xc.conn->tls? tls_write(xc.conn->tls, data, len) : sock_write(xc.conn->sock, data, len);
@@ -268,7 +257,7 @@ const failable<size_t> send(const string
  * Send a stanza on an XMPP session.
  */
 const failable<size_t> send(xmpp_stanza_t* const stanza, XMPPClient& xc) {
-    char *buf;
+    char* buf;
     size_t len;
     const int rc = xmpp_stanza_to_text(stanza, &buf, &len);
      if (rc != 0)
@@ -291,13 +280,13 @@ const failable<bool> post(const value& t
     debug(val, "chat::post::body");
 
     // Convert the value to a string
-    const string vs(scheme::writeValue(val));
+    const string vs(write(content(scheme::writeValue(val))));
 
     // Build message stanza
-    xmpp_stanza_t* stanza = namedStanza("message", xc.ctx);
+    xmpp_stanza_t* const stanza = namedStanza("message", xc.ctx);
     xmpp_stanza_set_type(stanza, "chat");
     xmpp_stanza_set_attribute(stanza, "to", c_str(string(to)));
-    xmpp_stanza_t* body = namedStanza("body", xc.ctx);
+    xmpp_stanza_t* const body = namedStanza("body", xc.ctx);
     xmpp_stanza_add_child(stanza, body);
     xmpp_stanza_add_child(body, textStanza(c_str(vs), xc.ctx));
 
@@ -323,12 +312,12 @@ const failable<bool> disconnect(XMPPClie
 /**
  * Listen to messages received by an XMPP client.
  */
-const failable<bool> listen(const lambda<failable<bool>(const value&, const value&, XMPPClient&)>& listener, XMPPClient& xc) {
+const failable<bool> listen(const lambda<const failable<bool>(const value&, const value&, XMPPClient&)>& listener, XMPPClient& xc) {
     debug("chat::listen");
     xc.listener = listener;
     xmpp_handler_add(xc.conn, messageHandler, NULL, "message", NULL, &xc);
     xc.ctx->loop_status = XMPP_LOOP_RUNNING;
-    while(xc.connected && !isNil(xc.listener) && xc.ctx->loop_status == XMPP_LOOP_RUNNING)
+    while(xc.connected && !isNil((lambda<const failable<bool>(const value&, const value&, XMPPClient&)>)xc.listener) && xc.ctx->loop_status == XMPP_LOOP_RUNNING)
         xmpp_run_once(xc.ctx, 1000L);
     return true;
 }

Modified: tuscany/sca-cpp/trunk/components/constdb/Makefile.am
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/constdb/Makefile.am?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/constdb/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/components/constdb/Makefile.am Tue Dec 11 06:13:02 2012
@@ -41,7 +41,7 @@ tinycdb_test_SOURCES = tinycdb-test.cpp
 tinycdb_test_LDFLAGS = -L${TINYCDB_LIB} -R${TINYCDB_LIB} -lcdb
 
 client_test_SOURCES = client-test.cpp
-client_test_LDFLAGS = -lxml2 -lcurl -lmozjs
+client_test_LDFLAGS = -lxml2 -lcurl -ljansson
 
 dist_noinst_SCRIPTS = constdb-test server-test
 noinst_PROGRAMS = tinycdb-test client-test

Modified: tuscany/sca-cpp/trunk/components/constdb/client-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/constdb/client-test.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/constdb/client-test.cpp (original)
+++ tuscany/sca-cpp/trunk/components/constdb/client-test.cpp Tue Dec 11 06:13:02 2012
@@ -38,15 +38,15 @@ namespace constdb {
 
 const string uri("http://localhost:8090/constdb");
 
-bool testConstDb() {
-    http::CURLSession cs("", "", "", "", 0);
+const bool testConstDb() {
+    const http::CURLSession cs("", "", "", "", 0);
 
-    const list<value> i = list<value>() + "content" + (list<value>() + "item" 
-            + (list<value>() + "name" + string("Apple"))
-            + (list<value>() + "price" + string("$2.99")));
-    const list<value> a = list<value>() + (list<value>() + "entry" 
-            + (list<value>() + "title" + string("item"))
-            + (list<value>() + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
+    const list<value> i = nilListValue + "content" + (nilListValue + "item" 
+            + (nilListValue + "name" + string("Apple"))
+            + (nilListValue + "price" + string("$2.99")));
+    const list<value> a = nilListValue + (nilListValue + "entry" 
+            + (nilListValue + "title" + string("item"))
+            + (nilListValue + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
             + i);
 
     const failable<value> id = http::post(a, uri, cs);
@@ -59,18 +59,18 @@ bool testConstDb() {
         assert(content(val) == a);
     }
 
-    const list<value> j = list<value>() + "content" + (list<value>() + "item" 
-            + (list<value>() + "name" + string("Apple"))
-            + (list<value>() + "price" + string("$3.55")));
-    const list<value> b = list<value>() + (list<value>() + "entry" 
-            + (list<value>() + "title" + string("item"))
-            + (list<value>() + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
+    const list<value> j = nilListValue + "content" + (nilListValue + "item" 
+            + (nilListValue + "name" + string("Apple"))
+            + (nilListValue + "price" + string("$3.55")));
+    const list<value> b = nilListValue + (nilListValue + "entry" 
+            + (nilListValue + "title" + string("item"))
+            + (nilListValue + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
             + j);
 
     {
         const failable<value> r = http::put(b, uri + p, cs);
         assert(hasContent(r));
-        assert(content(r) == value(true));
+        assert(content(r) == trueValue);
     }
     {
         const failable<value> val = http::get(uri + p, cs);
@@ -80,7 +80,7 @@ bool testConstDb() {
     {
         const failable<value> r = http::del(uri + p, cs);
         assert(hasContent(r));
-        assert(content(r) == value(true));
+        assert(content(r) == trueValue);
     }
     {
         const failable<value> val = http::get(uri + p, cs);
@@ -90,35 +90,26 @@ bool testConstDb() {
     return true;
 }
 
-struct getLoop {
-    const string path;
-    const value entry;
-    http::CURLSession& cs;
-    getLoop(const string& path, const value& entry, http::CURLSession& cs) : path(path), entry(entry), cs(cs) {
-    }
-    const bool operator()() const {
-        const failable<value> val = http::get(uri + path, cs);
-        assert(hasContent(val));
-        assert(content(val) == entry);
-        return true;
-    }
-};
-
-bool testGetPerf() {
-    const list<value> i = list<value>() + "content" + (list<value>() + "item" 
-            + (list<value>() + "name" + string("Apple"))
-            + (list<value>() + "price" + string("$4.55")));
-    const list<value> a = list<value>() + (list<value>() + "entry" 
-            + (list<value>() + "title" + string("item"))
-            + (list<value>() + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
+const bool testGetPerf() {
+    const list<value> i = nilListValue + "content" + (nilListValue + "item" 
+            + (nilListValue + "name" + string("Apple"))
+            + (nilListValue + "price" + string("$4.55")));
+    const list<value> a = nilListValue + (nilListValue + "entry" 
+            + (nilListValue + "title" + string("item"))
+            + (nilListValue + "id" + string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"))
             + i);
 
-    http::CURLSession cs("", "", "", "", 0);
+    const http::CURLSession cs("", "", "", "", 0);
     const failable<value> id = http::post(a, uri, cs);
     assert(hasContent(id));
     const string p = path(content(id));
 
-    const lambda<bool()> gl = getLoop(p, a, cs);
+    const blambda gl = [p, a, cs]() -> const bool {
+        const failable<value> val = http::get(uri + p, cs);
+        assert(hasContent(val));
+        assert(content(val) == a);
+        return true;
+    };
     cout << "ConstDb get test " << time(gl, 5, 200) << " ms" << endl;
 
     return true;

Modified: tuscany/sca-cpp/trunk/components/constdb/constdb.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/constdb/constdb.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/constdb/constdb.cpp (original)
+++ tuscany/sca-cpp/trunk/components/constdb/constdb.cpp Tue Dec 11 06:13:02 2012
@@ -37,14 +37,14 @@ namespace constdb {
 /**
  * Get an item from the database.
  */
-const failable<value> get(const list<value>& params, tinycdb::TinyCDB& cdb) {
+const failable<value> get(const list<value>& params, const tinycdb::TinyCDB& cdb) {
     return tinycdb::get(car(params), cdb);
 }
 
 /**
  * Post an item to the database.
  */
-const failable<value> post(const list<value>& params, tinycdb::TinyCDB& cdb) {
+const failable<value> post(const list<value>& params, const tinycdb::TinyCDB& cdb) {
     const value id = append<value>(car(params), mklist(mkuuid()));
     const failable<bool> val = tinycdb::post(id, cadr(params), cdb);
     if (!hasContent(val))
@@ -55,7 +55,7 @@ const failable<value> post(const list<va
 /**
  * Put an item into the database.
  */
-const failable<value> put(const list<value>& params, tinycdb::TinyCDB& cdb) {
+const failable<value> put(const list<value>& params, const tinycdb::TinyCDB& cdb) {
     const failable<bool> val = tinycdb::put(car(params), cadr(params), cdb);
     if (!hasContent(val))
         return mkfailure<value>(val);
@@ -65,7 +65,7 @@ const failable<value> put(const list<val
 /**
  * Delete an item from the database.
  */
-const failable<value> del(const list<value>& params, tinycdb::TinyCDB& cdb) {
+const failable<value> del(const list<value>& params, const tinycdb::TinyCDB& cdb) {
     const failable<bool> val = tinycdb::del(car(params), cdb);
     if (!hasContent(val))
         return mkfailure<value>(val);
@@ -73,14 +73,15 @@ const failable<value> del(const list<val
 }
 
 /**
- * Component implementation lambda function.
+ * Start the component.
  */
-class applyConstDb {
-public:
-    applyConstDb(tinycdb::TinyCDB& cdb) : cdb(cdb) {
-    }
+const failable<value> start(unused const list<value>& params) {
+    // Connect to the configured database and table
+    const value dbname = ((lvvlambda)car(params))(nilListValue);
+    const tinycdb::TinyCDB& cdb = *(new (gc_new<tinycdb::TinyCDB>()) tinycdb::TinyCDB(dbname));
 
-    const value operator()(const list<value>& params) const {
+    // Return the component implementation lambda function
+    const lvvlambda applyConstDb = [cdb](const list<value>& params) -> const value {
         const value func(car(params));
         if (func == "get")
             return get(cdr(params), cdb);
@@ -91,22 +92,8 @@ public:
         if (func == "delete")
             return del(cdr(params), cdb);
         return mkfailure<value>();
-    }
-
-private:
-    tinycdb::TinyCDB& cdb;
-};
-
-/**
- * Start the component.
- */
-const failable<value> start(unused const list<value>& params) {
-    // Connect to the configured database and table
-    const value dbname = ((lambda<value(const list<value>&)>)car(params))(list<value>());
-    tinycdb::TinyCDB& cdb = *(new (gc_new<tinycdb::TinyCDB>()) tinycdb::TinyCDB(dbname));
-
-    // Return the component implementation lambda function
-    return value(lambda<value(const list<value>&)>(applyConstDb(cdb)));
+    };
+    return value(applyConstDb);
 }
 
 }

Modified: tuscany/sca-cpp/trunk/components/constdb/tinycdb-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/constdb/tinycdb-test.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/constdb/tinycdb-test.cpp (original)
+++ tuscany/sca-cpp/trunk/components/constdb/tinycdb-test.cpp Tue Dec 11 06:13:02 2012
@@ -32,8 +32,8 @@
 namespace tuscany {
 namespace tinycdb {
 
-bool testTinyCDB() {
-    TinyCDB cdb("tmp/test.cdb");
+const bool testTinyCDB() {
+    const TinyCDB cdb("tmp/test.cdb");
     const value k = mklist<value>("a");
 
     assert(hasContent(post(k, string("AAA"), cdb)));
@@ -46,23 +46,15 @@ bool testTinyCDB() {
     return true;
 }
 
-struct getLoop {
-    const value k;
-    TinyCDB& cdb;
-    getLoop(const value& k, TinyCDB& cdb) : k(k), cdb(cdb) {
-    }
-    const bool operator()() const {
-        assert((get(k, cdb)) == value(string("CCC")));
-        return true;
-    }
-};
-
-bool testGetPerf() {
+const bool testGetPerf() {
     const value k = mklist<value>("c");
-    TinyCDB cdb("tmp/test.cdb");
+    const TinyCDB cdb("tmp/test.cdb");
     assert(hasContent(post(k, string("CCC"), cdb)));
 
-    const lambda<bool()> gl = getLoop(k, cdb);
+    const blambda gl = [k, cdb]() -> const bool {
+        assert((get(k, cdb)) == value(string("CCC")));
+        return true;
+    };
     cout << "TinyCDB get test " << time(gl, 5, 100000) << " ms" << endl;
     return true;
 }



Mime
View raw message