tuscany-commits mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From jsdelf...@apache.org
Subject svn commit: r1420007 [2/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
Modified: tuscany/sca-cpp/trunk/components/constdb/tinycdb.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/constdb/tinycdb.hpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/constdb/tinycdb.hpp (original)
+++ tuscany/sca-cpp/trunk/components/constdb/tinycdb.hpp Tue Dec 11 06:13:02 2012
@@ -41,20 +41,20 @@ namespace tinycdb {
  */
 class buffer {
 public:
-    operator void*() const throw() {
+    operator void* const () const throw() {
         return buf;
     }
 
-    operator unsigned char*() const throw() {
-        return (unsigned char*)buf;
+    operator unsigned char* const () const throw() {
+        return (unsigned char* const)buf;
     }
 
-    operator char*() const throw() {
-        return (char*)buf;
+    operator char* const () const throw() {
+        return (char* const)buf;
     }
 
 private:
-    buffer(const unsigned int size, void* buf) : size(size), buf(buf) {
+    buffer(const unsigned int size, void* const buf) : size(size), buf(buf) {
     }
 
     unsigned int size;
@@ -106,48 +106,53 @@ const string absdbname(const string& nam
  */
 class TinyCDB {
 public:
-    TinyCDB() : owner(false), fd(-1) {
-        st.st_ino = 0;
+    TinyCDB() : owner(false), h(*(new (gc_new<handles>()) handles())) {
     }
 
-    TinyCDB(const string& name) : owner(true), name(absdbname(name)), fd(-1) {
+    TinyCDB(const string& name) : owner(true), name(absdbname(name)), h(*(new (gc_new<handles>()) handles())) {
         debug(name, "tinycdb::tinycdb::name");
-        st.st_ino = 0;
     }
 
-    TinyCDB(const TinyCDB& c) : owner(false), name(c.name), fd(c.fd) {
+    TinyCDB(const TinyCDB& c) : owner(false), name(c.name), h(c.h) {
         debug("tinycdb::tinycdb::copy");
-        st.st_ino = c.st.st_ino;
     }
 
-    const TinyCDB& operator=(const TinyCDB& c) {
-        debug("tinycdb::tinycdb::operator=");
-        if(this == &c)
-            return *this;
-        owner = false;
-        name = c.name;
-        fd = c.fd;
-        st.st_ino = c.st.st_ino;
-        return *this;
-    }
+    TinyCDB& operator=(const TinyCDB& c) = delete;
 
     ~TinyCDB() {
         if (!owner)
             return;
-        if (fd == -1)
+        if (h.fd == -1)
             return;
-        close(fd);
+        close(h.fd);
     }
 
 private:
+    class handles {
+    public:
+        handles() : fd(-1) {
+            st.st_ino = 0;
+        }
+
+        handles(const handles& c) : fd(c.fd), st(c.st) {
+        }
+
+    private:
+        int fd;
+        struct stat st;
+
+        friend class TinyCDB;
+        friend const failable<int> cdbopen(const TinyCDB& cdb);
+        friend const failable<bool> cdbclose(const TinyCDB& cdb);
+    };
+
     bool owner;
     string name;
-    int fd;
-    struct stat st;
+    handles& h;
 
     friend const string dbname(const TinyCDB& cdb);
-    friend const failable<int> cdbopen(TinyCDB& cdb);
-    friend const failable<bool> cdbclose(TinyCDB& cdb);
+    friend const failable<int> cdbopen(const TinyCDB& cdb);
+    friend const failable<bool> cdbclose(const TinyCDB& cdb);
 };
 
 /**
@@ -160,7 +165,7 @@ const string dbname(const TinyCDB& cdb) 
 /**
  * Open a database.
  */
-const failable<int> cdbopen(TinyCDB& cdb) {
+const failable<int> cdbopen(const TinyCDB& cdb) {
 
     // Get database file serial number
     struct stat st;
@@ -169,51 +174,51 @@ const failable<int> cdbopen(TinyCDB& cdb
         return mkfailure<int>(string("Couldn't tinycdb read database stat: ") + cdb.name);
 
     // Open database for the first time
-    if (cdb.fd == -1) {
-        cdb.fd = open(c_str(cdb.name), O_RDONLY);
-        if (cdb.fd == -1)
+    if (cdb.h.fd == -1) {
+        cdb.h.fd = open(c_str(cdb.name), O_RDONLY);
+        if (cdb.h.fd == -1)
             return mkfailure<int>(string("Couldn't open tinycdb database file: ") + cdb.name);
-        debug(cdb.fd, "tinycdb::open::fd");
-        cdb.st = st;
-        return cdb.fd;
+        debug(cdb.h.fd, "tinycdb::open::fd");
+        cdb.h.st = st;
+        return cdb.h.fd;
     }
 
     // Close and reopen database after a change
-    if (st.st_ino != cdb.st.st_ino) {
+    if (st.st_ino != cdb.h.st.st_ino) {
 
         // Close current fd
-        close(cdb.fd);
+        close(cdb.h.fd);
 
         // Reopen database
         const int newfd = open(c_str(cdb.name), O_RDONLY);
         if (newfd == -1)
             return mkfailure<int>(string("Couldn't open tinycdb database file: ") + cdb.name);
-        if (newfd == cdb.fd) {
-            debug(cdb.fd, "tinycdb::open::fd");
-            cdb.st = st;
-            return cdb.fd;
+        if (newfd == cdb.h.fd) {
+            debug(cdb.h.fd, "tinycdb::open::fd");
+            cdb.h.st = st;
+            return cdb.h.fd;
         }
 
         // We got a different fd, dup it to the current fd then close it
-        if (fcntl(newfd, F_DUPFD, cdb.fd) == -1)
+        if (fcntl(newfd, F_DUPFD, cdb.h.fd) == -1)
             return mkfailure<int>(string("Couldn't dup tinycdb database file handle: ") + cdb.name);
         close(newfd);
 
-        debug(cdb.fd, "tinycdb::open::fd");
-        cdb.st = st;
-        return cdb.fd;
+        debug(cdb.h.fd, "tinycdb::open::fd");
+        cdb.h.st = st;
+        return cdb.h.fd;
     }
 
     // No change, just return the current fd
-    return cdb.fd;
+    return cdb.h.fd;
 }
 
 /**
  * Close a database.
  */
-const failable<bool> cdbclose(TinyCDB& cdb) {
-    close(cdb.fd);
-    cdb.fd = -1;
+const failable<bool> cdbclose(const TinyCDB& cdb) {
+    close(cdb.h.fd);
+    cdb.h.fd = -1;
     return true;
 }
 
@@ -222,7 +227,7 @@ const failable<bool> cdbclose(TinyCDB& c
  * can return true to let the entry added to the new db, false to skip the
  * entry, or a failure.
  */
-const failable<bool> rewrite(const lambda<failable<bool>(buffer& buf, const unsigned int klen, const unsigned int vlen)>& update, const lambda<failable<bool>(struct cdb_make&)>& finish, buffer& buf, const int tmpfd, TinyCDB& cdb) {
+const failable<bool> rewrite(const lambda<const failable<bool>(buffer& buf, const unsigned int klen, const unsigned int vlen)>& update, const lambda<const failable<bool>(struct cdb_make&)>& finish, buffer& buf, const int tmpfd, const TinyCDB& cdb) {
 
     // Initialize new db structure
     struct cdb_make cdbm;
@@ -241,7 +246,7 @@ const failable<bool> rewrite(const lambd
     if (::read(fd, buf, 2048) != 2048)
         return mkfailure<bool>("Couldn't read tinycdb database header");
     pos += 2048;
-    unsigned int eod = cdb_unpack(buf);
+    const unsigned int eod = cdb_unpack(buf);
     debug(pos, "tinycdb::rewrite::eod");
 
     // Read and add the existing entries
@@ -251,9 +256,9 @@ const failable<bool> rewrite(const lambd
         if (::read(fd, buf, 8) != 8)
             return mkfailure<bool>("Couldn't read tinycdb entry header");
         pos += 8;
-        unsigned int klen = cdb_unpack(buf);
-        unsigned int vlen = cdb_unpack(((unsigned char*)buf) + 4);
-        unsigned int elen = klen + vlen;
+        const unsigned int klen = cdb_unpack(buf);
+        const unsigned int vlen = cdb_unpack(((unsigned char*)buf) + 4);
+        const unsigned int elen = klen + vlen;
 
         // Read existing entry
         buf = mkbuffer(buf, elen);
@@ -264,8 +269,8 @@ const failable<bool> rewrite(const lambd
         pos += elen;
 
         // Apply the update function to the entry
-        debug(string((char*)buf, klen), "tinycdb::rewrite::existing key");
-        debug(string(((char*)buf) + klen, vlen), "tinycdb::rewrite::existing value");
+        debug(string((const char* const)buf, klen), "tinycdb::rewrite::existing key");
+        debug(string(((const char* const)buf) + klen, vlen), "tinycdb::rewrite::existing value");
         const failable<bool> u = update(buf, klen, vlen);
         if (!hasContent(u))
             return u;
@@ -293,11 +298,11 @@ const failable<bool> rewrite(const lambd
     return true;
 }
 
-const failable<bool> rewrite(const lambda<failable<bool>(buffer& buf, const unsigned int klen, const unsigned int vlen)>& update, const lambda<failable<bool>(struct cdb_make&)>& finish, TinyCDB& cdb) {
+const failable<bool> rewrite(const lambda<const failable<bool>(buffer& buf, const unsigned int klen, const unsigned int vlen)>& update, const lambda<const failable<bool>(struct cdb_make&)>& finish, const TinyCDB& cdb) {
 
     // Create a new temporary db file
-    string tmpname = dbname(cdb) + ".XXXXXX";
-    int tmpfd = mkstemp(const_cast<char*>(c_str(tmpname)));
+    const string tmpname = dbname(cdb) + ".XXXXXX";
+    const int tmpfd = mkstemp(const_cast<char*>(c_str(tmpname)));
     if (tmpfd == -1)
         return mkfailure<bool>("Couldn't create temporary tinycdb database");
 
@@ -314,7 +319,7 @@ const failable<bool> rewrite(const lambd
     if (rename(c_str(tmpname), c_str(dbname(cdb))) == -1)
         return mkfailure<bool>("Couldn't rename temporary tinycdb database");
     cdbclose(cdb);
-    failable<int> ffd = cdbopen(cdb);
+    const failable<int> ffd = cdbopen(cdb);
     if (!hasContent(ffd))
         return mkfailure<bool>(ffd);
 
@@ -324,42 +329,27 @@ const failable<bool> rewrite(const lambd
 /**
  * Post a new item to the database.
  */
-struct postUpdate {
-    const string ks;
-    postUpdate(const string& ks) : ks(ks) {
-    }
-    const failable<bool> operator()(buffer& buf, const unsigned int klen, unused const unsigned int vlen) const {
-        if (ks == string((char*)buf, klen))
-            return mkfailure<bool>("Key already exists in tinycdb database");
-        return true;
-    }
-};
-
-struct postFinish {
-    const string ks;
-    const string vs;
-    postFinish(const string& ks, const string& vs) : ks(ks), vs(vs) {
-    }
-    const failable<bool> operator()(struct cdb_make& cdbm) const {
-        if (cdb_make_add(&cdbm, c_str(ks), (unsigned int)length(ks), c_str(vs), (unsigned int)length(vs)) == -1)
-            return mkfailure<bool>(string("Couldn't add tinycdb entry: ") + ks);
-        return true;
-    }
-};
-
-const failable<bool> post(const value& key, const value& val, TinyCDB& cdb) {
+const failable<bool> post(const value& key, const value& val, const TinyCDB& cdb) {
     debug(key, "tinycdb::post::key");
     debug(val, "tinycdb::post::value");
     debug(dbname(cdb), "tinycdb::post::dbname");
 
-    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))));
 
     // Process each entry and detect existing key
-    const lambda<failable<bool>(buffer& buf, const unsigned int klen, const unsigned int vlen)> update = postUpdate(ks);
+    const lambda<const failable<bool>(buffer&, const unsigned int, const unsigned int)> update = [ks](buffer& buf, const unsigned int klen, unused const unsigned int vlen) -> const failable<bool> {
+        if (ks == string((char*)buf, klen))
+            return mkfailure<bool>("Key already exists in tinycdb database");
+        return true;
+    };
 
     // Add the new entry to the db
-    const lambda<failable<bool>(struct cdb_make& cdbm)> finish = postFinish(ks, vs);
+    const lambda<const failable<bool>(struct cdb_make&)> finish = [ks, vs](struct cdb_make& cdbm) -> const failable<bool> {
+        if (cdb_make_add(&cdbm, c_str(ks), (unsigned int)length(ks), c_str(vs), (unsigned int)length(vs)) == -1)
+            return mkfailure<bool>(string("Couldn't add tinycdb entry: ") + ks);
+        return true;
+    };
 
     // Rewrite the db
     const failable<bool> r = rewrite(update, finish, cdb);
@@ -370,42 +360,27 @@ const failable<bool> post(const value& k
 /**
  * Update an item in the database. If the item doesn't exist it is added.
  */
-struct putUpdate {
-    const string ks;
-    putUpdate(const string& ks) : ks(ks) {
-    }
-    const failable<bool> operator()(buffer& buf, const unsigned int klen, unused const unsigned int vlen) const {
-        if (ks == string((char*)buf, klen))
-            return false;
-        return true;
-    }
-};
-
-struct putFinish {
-    const string ks;
-    const string vs;
-    putFinish(const string& ks, const string& vs) : ks(ks), vs(vs) {
-    }
-    const failable<bool> operator()(struct cdb_make& cdbm) const {
-        if (cdb_make_add(&cdbm, c_str(ks), (unsigned int)length(ks), c_str(vs), (unsigned int)length(vs)) == -1)
-            return mkfailure<bool>(string("Couldn't add tinycdb entry: ") + ks);
-        return true;
-    }
-};
-
-const failable<bool> put(const value& key, const value& val, TinyCDB& cdb) {
+const failable<bool> put(const value& key, const value& val, const TinyCDB& cdb) {
     debug(key, "tinycdb::put::key");
     debug(val, "tinycdb::put::value");
     debug(dbname(cdb), "tinycdb::put::dbname");
 
-    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))));
 
     // Process each entry and skip existing key
-    const lambda<failable<bool>(buffer& buf, const unsigned int klen, const unsigned int vlen)> update = putUpdate(ks);
+    const lambda<const failable<bool>(buffer&, const unsigned int, const unsigned int)> update = [ks](buffer& buf, const unsigned int klen, unused const unsigned int vlen) -> const failable<bool> {
+        if (ks == string((char*)buf, klen))
+            return false;
+        return true;
+    };
 
     // Add the new entry to the db
-    const lambda<failable<bool>(struct cdb_make& cdbm)> finish = putFinish(ks, vs);
+    const lambda<const failable<bool>(struct cdb_make&)> finish = [ks, vs](struct cdb_make& cdbm) -> const failable<bool> {
+        if (cdb_make_add(&cdbm, c_str(ks), (unsigned int)length(ks), c_str(vs), (unsigned int)length(vs)) == -1)
+            return mkfailure<bool>(string("Couldn't add tinycdb entry: ") + ks);
+        return true;
+    };
 
     // Rewrite the db
     const failable<bool> r = rewrite(update, finish, cdb);
@@ -416,7 +391,7 @@ const failable<bool> put(const value& ke
 /**
  * Get an item from the database.
  */
-const failable<value> get(const value& key, TinyCDB& cdb) {
+const failable<value> get(const value& key, const TinyCDB& cdb) {
     debug(key, "tinycdb::get::key");
     debug(dbname(cdb), "tinycdb::get::dbname");
 
@@ -425,7 +400,7 @@ const failable<value> get(const value& k
         return mkfailure<value>(ffd);
     const int fd = content(ffd);
 
-    const string ks(scheme::writeValue(key));
+    const string ks(write(content(scheme::writeValue(key))));
 
     cdbi_t vlen;
     if (cdb_seek(fd, c_str(ks), (unsigned int)length(ks), &vlen) <= 0) {
@@ -433,10 +408,10 @@ const failable<value> get(const value& k
         os << "Couldn't get tinycdb entry: " << key;
         return mkfailure<value>(str(os), 404, false);
     }
-    char* data = gc_cnew(vlen + 1);
+    char* const data = gc_cnew(vlen + 1);
     cdb_bread(fd, data, vlen);
     data[vlen] = '\0';
-    const value val(scheme::readValue(string(data)));
+    const value val(content(scheme::readValue(string(data))));
 
     debug(val, "tinycdb::get::result");
     return val;
@@ -445,36 +420,23 @@ const failable<value> get(const value& k
 /**
  * Delete an item from the database
  */
-struct delUpdate {
-    const string ks;
-    delUpdate(const string& ks) : ks(ks) {
-    }
-    const failable<bool> operator()(buffer& buf, const unsigned int klen, unused const unsigned int vlen) const {
-        if (ks == string((char*)buf, klen))
-            return false;
-        return true;
-    }
-};
-
-struct delFinish {
-    delFinish() {
-    }
-    const failable<bool> operator()(unused struct cdb_make& cdbm) const {
-        return true;
-    }
-};
-
-const failable<bool> del(const value& key, TinyCDB& cdb) {
+const failable<bool> del(const value& key, const TinyCDB& cdb) {
     debug(key, "tinycdb::delete::key");
     debug(dbname(cdb), "tinycdb::delete::dbname");
 
-    const string ks(scheme::writeValue(key));
+    const string ks(write(content(scheme::writeValue(key))));
 
     // Process each entry and skip existing key
-    const lambda<failable<bool>(buffer& buf, const unsigned int klen, const unsigned int vlen)> update = delUpdate(ks);
+    const lambda<const failable<bool>(buffer&, const unsigned int, const unsigned int)> update = [ks](buffer& buf, const unsigned int klen, unused const unsigned int vlen) -> const failable<bool> {
+        if (ks == string((char*)buf, klen))
+            return false;
+        return true;
+    };
 
     // Nothing to do to finish
-    const lambda<failable<bool>(struct cdb_make& cdbm)> finish = delFinish();
+    const lambda<const failable<bool>(struct cdb_make&)> finish = [](unused struct cdb_make& cdbm) -> const failable<bool> {
+        return true;
+    };
 
     // Rewrite the db
     const failable<bool> r = rewrite(update, finish, cdb);

Modified: tuscany/sca-cpp/trunk/components/filedb/Makefile.am
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/filedb/Makefile.am?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/filedb/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/components/filedb/Makefile.am Tue Dec 11 06:13:02 2012
@@ -26,15 +26,15 @@ comp_LTLIBRARIES = libfiledb.la
 noinst_DATA = libfiledb${libsuffix}
 
 libfiledb_la_SOURCES = filedb.cpp
-libfiledb_la_LDFLAGS = -lxml2 -lmozjs
+libfiledb_la_LDFLAGS = -lxml2 -ljansson
 libfiledb${libsuffix}:
 	ln -s .libs/libfiledb${libsuffix}
 
 file_test_SOURCES = file-test.cpp
-file_test_LDFLAGS = -lxml2 -lmozjs
+file_test_LDFLAGS = -lxml2 -ljansson
 
 client_test_SOURCES = client-test.cpp
-client_test_LDFLAGS = -lxml2 -lcurl -lmozjs
+client_test_LDFLAGS = -lxml2 -lcurl -ljansson
 
 dist_noinst_SCRIPTS = filedb-test server-test
 noinst_PROGRAMS = file-test client-test

Modified: tuscany/sca-cpp/trunk/components/filedb/client-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/filedb/client-test.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/filedb/client-test.cpp (original)
+++ tuscany/sca-cpp/trunk/components/filedb/client-test.cpp Tue Dec 11 06:13:02 2012
@@ -38,15 +38,15 @@ namespace filedb {
 
 const string uri("http://localhost:8090/filedb");
 
-bool testFileDB() {
-    http::CURLSession cs("", "", "", "", 0);
+const bool testFileDB() {
+    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 testFileDB() {
         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 testFileDB() {
     {
         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 testFileDB() {
     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 << "FileDB get test " << time(gl, 5, 200) << " ms" << endl;
 
     return true;

Modified: tuscany/sca-cpp/trunk/components/filedb/file-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/filedb/file-test.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/filedb/file-test.cpp (original)
+++ tuscany/sca-cpp/trunk/components/filedb/file-test.cpp Tue Dec 11 06:13:02 2012
@@ -32,12 +32,12 @@
 namespace tuscany {
 namespace filedb {
 
-bool testFileDB(const string& dbname, const string& format) {
-    FileDB db(dbname, format);
+const bool testFileDB(const string& dbname, const string& format) {
+    const FileDB db(dbname, format);
     const value k = mklist<value>("a", "b");
 
-    const list<value> a = mklist<value>(list<value>() + "ns1:a" + (list<value>() + "@xmlns:ns1" + string("http://aaa")) + (list<value>() + "text" + string("Hey!")));
-    const list<value> b = mklist<value>(list<value>() + "ns1:b" + (list<value>() + "@xmlns:ns1" + string("http://bbb")) + (list<value>() + "text" + string("Hey!")));
+    const list<value> a = mklist<value>(nilListValue + "ns1:a" + (nilListValue + "@xmlns:ns1" + string("http://aaa")) + (nilListValue + "text" + string("Hey!")));
+    const list<value> b = mklist<value>(nilListValue + "ns1:b" + (nilListValue + "@xmlns:ns1" + string("http://bbb")) + (nilListValue + "text" + string("Hey!")));
 
     assert(hasContent(post(k, a, db)));
     assert((get(k, db)) == value(a));
@@ -50,27 +50,17 @@ bool testFileDB(const string& dbname, co
     return true;
 }
 
-struct getLoop {
-    const value k;
-    FileDB& db;
-    const list<value> c;
-    getLoop(const value& k, FileDB& db) : k(k), db(db),
-        c(mklist<value>(list<value>() + "ns1:c" + (list<value>() + "@xmlns:ns1" + string("http://ccc")) + (list<value>() + "text" + string("Hey!")))) {
-    }
-    const bool operator()() const {
-        assert((get(k, db)) == value(c));
-        return true;
-    }
-};
-
-bool testGetPerf(const string& dbname, const string& format) {
-    FileDB db(dbname, format);
+const bool testGetPerf(const string& dbname, const string& format) {
+    const FileDB db(dbname, format);
 
     const value k = mklist<value>("c");
-    const list<value> c = mklist<value>(list<value>() + "ns1:c" + (list<value>() + "@xmlns:ns1" + string("http://ccc")) + (list<value>() + "text" + string("Hey!")));
+    const list<value> c = mklist<value>(nilListValue + "ns1:c" + (nilListValue + "@xmlns:ns1" + string("http://ccc")) + (nilListValue + "text" + string("Hey!")));
     assert(hasContent(post(k, c, db)));
 
-    const lambda<bool()> gl = getLoop(k, db);
+    const blambda gl = [k, c, db]() -> const bool {
+        assert((get(k, db)) == value(c));
+        return true;
+    };
     cout << "FileDB get test " << time(gl, 5, 5000) << " ms" << endl;
     return true;
 }

Modified: tuscany/sca-cpp/trunk/components/filedb/filedb.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/filedb/filedb.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/filedb/filedb.cpp (original)
+++ tuscany/sca-cpp/trunk/components/filedb/filedb.cpp Tue Dec 11 06:13:02 2012
@@ -37,14 +37,14 @@ namespace filedb {
 /**
  * Get an item from the database.
  */
-const failable<value> get(const list<value>& params, filedb::FileDB& db) {
+const failable<value> get(const list<value>& params, const filedb::FileDB& db) {
     return filedb::get(car(params), db);
 }
 
 /**
  * Post an item to the database.
  */
-const failable<value> post(const list<value>& params, filedb::FileDB& db) {
+const failable<value> post(const list<value>& params, const filedb::FileDB& db) {
     const value id = append<value>(car(params), mklist(mkuuid()));
     const failable<bool> val = filedb::post(id, cadr(params), db);
     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, filedb::FileDB& db) {
+const failable<value> put(const list<value>& params, const filedb::FileDB& db) {
     const failable<bool> val = filedb::put(car(params), cadr(params), db);
     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, filedb::FileDB& db) {
+const failable<value> del(const list<value>& params, const filedb::FileDB& db) {
     const failable<bool> val = filedb::del(car(params), db);
     if (!hasContent(val))
         return mkfailure<value>(val);
@@ -73,14 +73,17 @@ const failable<value> del(const list<val
 }
 
 /**
- * Component implementation lambda function.
+ * Start the component.
  */
-class applyfiledb {
-public:
-    applyfiledb(filedb::FileDB& db) : db(db) {
-    }
+const failable<value> start(const list<value>& params) {
+    // Connect to the configured database and table
+    const value dbname = ((lvvlambda)car(params))(nilListValue);
+    const value format = ((lvvlambda)cadr(params))(nilListValue);
+
+    const filedb::FileDB& db = *(new (gc_new<filedb::FileDB>()) filedb::FileDB(absdbname(dbname), format));
 
-    const value operator()(const list<value>& params) const {
+    // Return the component implementation lambda function
+    const lvvlambda applyfiledb = [db](const list<value>& params) -> const value {
         const value func(car(params));
         if (func == "get")
             return get(cdr(params), db);
@@ -91,24 +94,8 @@ public:
         if (func == "delete")
             return del(cdr(params), db);
         return mkfailure<value>();
-    }
-
-private:
-    filedb::FileDB& db;
-};
-
-/**
- * Start the component.
- */
-const failable<value> start(const list<value>& params) {
-    // Connect to the configured database and table
-    const value dbname = ((lambda<value(const list<value>&)>)car(params))(list<value>());
-    const value format = ((lambda<value(const list<value>&)>)cadr(params))(list<value>());
-
-    filedb::FileDB& db = *(new (gc_new<filedb::FileDB>()) filedb::FileDB(absdbname(dbname), format));
-
-    // Return the component implementation lambda function
-    return value(lambda<value(const list<value>&)>(applyfiledb(db)));
+    };
+    return value(applyfiledb);
 }
 
 }

Modified: tuscany/sca-cpp/trunk/components/filedb/filedb.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/filedb/filedb.hpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/filedb/filedb.hpp (original)
+++ tuscany/sca-cpp/trunk/components/filedb/filedb.hpp Tue Dec 11 06:13:02 2012
@@ -32,8 +32,8 @@
 #include "monad.hpp"
 #include "fstream.hpp"
 #include "element.hpp"
-#include "xml.hpp"
 #include "../../modules/scheme/eval.hpp"
+#include "../../modules/xml/xml.hpp"
 #include "../../modules/json/json.hpp"
 
 namespace tuscany {
@@ -68,30 +68,22 @@ public:
         debug("filedb::filedb::copy");
     }
 
-    const FileDB& operator=(const FileDB& c) {
-        debug("filedb::filedb::operator=");
-        if(this == &c)
-            return *this;
-        owner = false;
-        name = c.name;
-        format = c.format;
-        return *this;
-    }
+    FileDB& operator=(const FileDB& c) = delete;
 
     ~FileDB() {
     }
 
 private:
-    bool owner;
-    string name;
-    string format;
+    const bool owner;
+    const string name;
+    const string format;
 
     friend const failable<bool> write(const value& v, ostream& os, const string& format);
     friend const failable<value> read(istream& is, const string& format);
-    friend const failable<bool> post(const value& key, const value& val, FileDB& db);
-    friend const failable<bool> put(const value& key, const value& val, FileDB& db);
-    friend const failable<value> get(const value& key, FileDB& db);
-    friend const failable<bool> del(const value& key, FileDB& db);
+    friend const failable<bool> post(const value& key, const value& val, const FileDB& db);
+    friend const failable<bool> put(const value& key, const value& val, const FileDB& db);
+    friend const failable<value> get(const value& key, const FileDB& db);
+    friend const failable<bool> del(const value& key, const FileDB& db);
 };
 
 /**
@@ -100,7 +92,7 @@ private:
 const string filename(const list<value>& path, const string& root) {
     if (isNil(path))
         return root;
-    const string name = root + "/" + (isString(car(path))? (string)car(path) : scheme::writeValue(car(path)));
+    const string name = root + "/" + (isString(car(path))? (string)car(path) : write(content(scheme::writeValue(car(path)))));
     return filename(cdr(path), name);
 }
 
@@ -116,7 +108,7 @@ const string filename(const value& key, 
 const failable<bool> mkdirs(const list<value>& path, const string& root) {
     if (isNil(cdr(path)))
         return true;
-    const string dir = root + "/" + (isString(car(path))? (string)car(path) : scheme::writeValue(car(path)));
+    const string dir = root + "/" + (isString(car(path))? (string)car(path) : write(content(scheme::writeValue(car(path)))));
     mkdir(c_str(dir), S_IRWXU);
     return mkdirs(cdr(path), dir);
 }
@@ -126,20 +118,19 @@ const failable<bool> mkdirs(const list<v
  */
 const failable<bool> write(const value& v, ostream& os, const string& format) {
     if (format == "scheme") {
-        const string vs(scheme::writeValue(v));
+        const string vs(write(content(scheme::writeValue(v))));
         os << vs;
         return true;
     }
     if (format == "xml") {
-        failable<list<string> > s = writeXML(valuesToElements(v));
+        failable<list<string> > s = xml::writeElements(valuesToElements(v));
         if (!hasContent(s))
             return mkfailure<bool>(s);
         write(content(s), os);
         return true;
     }
     if (format == "json") {
-        js::JSContext jscx;
-        failable<list<string> > s = json::writeJSON(valuesToElements(v), jscx);
+        failable<list<string> > s = json::writeValue(v);
         if (!hasContent(s))
             return mkfailure<bool>(s);
         write(content(s), os);
@@ -153,27 +144,25 @@ const failable<bool> write(const value& 
  */
 const failable<value> read(istream& is, const string& format) {
     if (format == "scheme") {
-        return scheme::readValue(is);
+        return scheme::readValue(streamList(is));
     }
     if (format == "xml") {
-        const value v = elementsToValues(readXML(streamList(is)));
-        return v;
-    }
-    if (format == "json") {
-        js::JSContext jscx;
-        const failable<list<value> > fv = json::readJSON(streamList(is), jscx);
+        const failable<list<value> > fv = xml::readElements(streamList(is));
         if (!hasContent(fv))
             return mkfailure<value>(fv);
         const value v = elementsToValues(content(fv));
         return v;
     }
+    if (format == "json") {
+        return json::readValue(streamList(is));
+    }
     return mkfailure<value>(string("Unsupported database format: ") + format);
 }
 
 /**
  * Post a new item to the database.
  */
-const failable<bool> post(const value& key, const value& val, FileDB& db) {
+const failable<bool> post(const value& key, const value& val, const FileDB& db) {
     debug(key, "filedb::post::key");
     debug(val, "filedb::post::value");
     debug(db.name, "filedb::post::dbname");
@@ -197,7 +186,7 @@ const failable<bool> post(const value& k
 /**
  * Update an item in the database. If the item doesn't exist it is added.
  */
-const failable<bool> put(const value& key, const value& val, FileDB& db) {
+const failable<bool> put(const value& key, const value& val, const FileDB& db) {
     debug(key, "filedb::put::key");
     debug(val, "filedb::put::value");
     debug(db.name, "filedb::put::dbname");
@@ -221,7 +210,7 @@ const failable<bool> put(const value& ke
 /**
  * Get an item from the database.
  */
-const failable<value> get(const value& key, FileDB& db) {
+const failable<value> get(const value& key, const FileDB& db) {
     debug(key, "filedb::get::key");
     debug(db.name, "filedb::get::dbname");
 
@@ -242,7 +231,7 @@ const failable<value> get(const value& k
 /**
  * Delete an item from the database
  */
-const failable<bool> del(const value& key, FileDB& db) {
+const failable<bool> del(const value& key, const FileDB& db) {
     debug(key, "filedb::delete::key");
     debug(db.name, "filedb::delete::dbname");
 

Modified: tuscany/sca-cpp/trunk/components/http/Makefile.am
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/http/Makefile.am?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/http/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/components/http/Makefile.am Tue Dec 11 06:13:02 2012
@@ -23,32 +23,32 @@ comp_LTLIBRARIES = libhttpget.la libhttp
 noinst_DATA = libhttpget${libsuffix} libhttpdelete${libsuffix} libhttppost${libsuffix} libhttpput${libsuffix} libhttppatch${libsuffix}
 
 libhttpget_la_SOURCES = httpget.cpp
-libhttpget_la_LDFLAGS = -lxml2 -lmozjs -curl
+libhttpget_la_LDFLAGS = -lxml2 -ljansson -curl
 libhttpget${libsuffix}:
 	ln -s .libs/libhttpget${libsuffix}
 
 libhttpdelete_la_SOURCES = httpdelete.cpp
-libhttpdelete_la_LDFLAGS = -lxml2 -lmozjs -curl
+libhttpdelete_la_LDFLAGS = -lxml2 -ljansson -curl
 libhttpdelete${libsuffix}:
 	ln -s .libs/libhttpdelete${libsuffix}
 
 libhttppost_la_SOURCES = httppost.cpp
-libhttppost_la_LDFLAGS = -lxml2 -lmozjs -curl
+libhttppost_la_LDFLAGS = -lxml2 -ljansson -curl
 libhttppost${libsuffix}:
 	ln -s .libs/libhttppost${libsuffix}
 
 libhttpput_la_SOURCES = httpput.cpp
-libhttpput_la_LDFLAGS = -lxml2 -lmozjs -curl
+libhttpput_la_LDFLAGS = -lxml2 -ljansson -curl
 libhttpput${libsuffix}:
 	ln -s .libs/libhttpput${libsuffix}
 
 libhttppatch_la_SOURCES = httppatch.cpp
-libhttppatch_la_LDFLAGS = -lxml2 -lmozjs -curl
+libhttppatch_la_LDFLAGS = -lxml2 -ljansson -curl
 libhttppatch${libsuffix}:
 	ln -s .libs/libhttppatch${libsuffix}
 
 client_test_SOURCES = client-test.cpp
-client_test_LDFLAGS = -lxml2 -lcurl -lmozjs
+client_test_LDFLAGS = -lxml2 -lcurl -ljansson
 
 dist_noinst_SCRIPTS = server-test
 noinst_PROGRAMS = client-test

Modified: tuscany/sca-cpp/trunk/components/http/client-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/http/client-test.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/http/client-test.cpp (original)
+++ tuscany/sca-cpp/trunk/components/http/client-test.cpp Tue Dec 11 06:13:02 2012
@@ -41,52 +41,45 @@ const string postURI("http://localhost:8
 const string putURI("http://localhost:8090/httpput");
 const string deleteURI("http://localhost:8090/httpdelete");
 
-bool testGet() {
-    http::CURLSession cs("", "", "", "", 0);
+const bool testGet() {
+    const http::CURLSession cs("", "", "", "", 0);
 
     const failable<value> val = http::get(getURI, cs);
     assert(hasContent(val));
     return true;
 }
 
-struct getLoop {
-    http::CURLSession& cs;
-    getLoop(http::CURLSession& cs) : cs(cs) {
-    }
-    const bool operator()() const {
+const bool testGetPerf() {
+    const http::CURLSession cs("", "", "", "", 0);
+
+    const blambda gl = [cs]() -> const bool {
         const failable<value> val = http::get(getURI, cs);
         assert(hasContent(val));
         return true;
-    }
-};
-
-bool testGetPerf() {
-    http::CURLSession cs("", "", "", "", 0);
-
-    const lambda<bool()> gl = getLoop(cs);
+    };
     cout << "HTTP get test " << time(gl, 5, 200) << " ms" << endl;
 
     return true;
 }
 
-bool testPost() {
-    http::CURLSession cs("", "", "", "", 0);
+const bool testPost() {
+    const http::CURLSession cs("", "", "", "", 0);
 
     const failable<value> val = http::get(postURI, cs);
     assert(hasContent(val));
     return true;
 }
 
-bool testPut() {
-    http::CURLSession cs("", "", "", "", 0);
+const bool testPut() {
+    const http::CURLSession cs("", "", "", "", 0);
 
     const failable<value> val = http::get(putURI, cs);
     assert(hasContent(val));
     return true;
 }
 
-bool testDelete() {
-    http::CURLSession cs("", "", "", "", 0);
+const bool testDelete() {
+    const http::CURLSession cs("", "", "", "", 0);
 
     const failable<value> val = http::get(deleteURI, cs);
     assert(hasContent(val));

Modified: tuscany/sca-cpp/trunk/components/http/httpdelete.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/http/httpdelete.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/http/httpdelete.cpp (original)
+++ tuscany/sca-cpp/trunk/components/http/httpdelete.cpp Tue Dec 11 06:13:02 2012
@@ -37,58 +37,37 @@ namespace httpdelete {
 /**
  * Evaluate an HTTP delete.
  */
-const failable<value> get(const lambda<value(const list<value>&)>& url, http::CURLSession& ch) {
+const failable<value> get(const lvvlambda& url, const http::CURLSession& ch) {
     debug("httpdelete::get");
-    const value u = url(mklist<value>("get", list<value>()));
+    const value u = url(mklist<value>("get", nilListValue));
     debug(u, "httpdelete::get::url");
     return http::del(u, ch);
 }
 
 /**
- * Component implementation lambda function.
+ * Start the component.
  */
-class applyhttp {
-public:
-    applyhttp(const lambda<value(const list<value>&)>& url, const perthread_ptr<http::CURLSession>& ch) : url(url), ch(ch) {
-    }
+const failable<value> start(const list<value>& params) {
+    // Create a CURL session
+    const lvvlambda timeout = cadr(params);
+    const gc_pool cp(gc_current_pool());
+    const lambda<const gc_ptr<http::CURLSession>()> newsession = [timeout, cp]() -> const gc_ptr<http::CURLSession> {
+        const gc_scoped_pool sp(pool(cp));
+        const int t = atoi(c_str((string)timeout(nilListValue)));
+        return new (gc_new<http::CURLSession>()) http::CURLSession(emptyString, emptyString, emptyString, emptyString, t);
+    };
+    const perthread_ptr<http::CURLSession> ch = *(new (gc_new<perthread_ptr<http::CURLSession> >()) perthread_ptr<http::CURLSession>(newsession));
 
-    const value operator()(const list<value>& params) const {
+    // Return the component implementation lambda function
+    const lvvlambda url = car(params);
+    const lvvlambda applyhttp = [url, ch](const list<value>& params) -> const value {
         debug(params, "httpdelete::applyhttp::params");
         const value func(car(params));
         if (func == "get")
             return get(url, *ch);
         return mkfailure<value>();
-    }
-
-private:
-    const lambda<value(const list<value>&)> url;
-    perthread_ptr<http::CURLSession> ch;
-};
-
-/**
- * Create a new CURL session.
- */
-class newsession {
-public:
-    newsession(const lambda<value(const list<value>&)>& timeout) : timeout(timeout) {
-    }
-    const gc_ptr<http::CURLSession> operator()() const {
-        const int t = atoi(c_str((string)timeout(list<value>())));
-        return new (gc_new<http::CURLSession>()) http::CURLSession("", "", "", "", t);
-    }
-private:
-    const lambda<value(const list<value>&)> timeout;
-};
-
-/**
- * Start the component.
- */
-const failable<value> start(const list<value>& params) {
-    // Create a CURL session
-    const perthread_ptr<http::CURLSession> ch = perthread_ptr<http::CURLSession>(lambda<gc_ptr<http::CURLSession>()>(newsession(cadr(params))));
-
-    // Return the component implementation lambda function
-    return value(lambda<value(const list<value>&)>(applyhttp(car(params), ch)));
+    };
+    return value(applyhttp);
 }
 
 }

Modified: tuscany/sca-cpp/trunk/components/http/httpget.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/http/httpget.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/http/httpget.cpp (original)
+++ tuscany/sca-cpp/trunk/components/http/httpget.cpp Tue Dec 11 06:13:02 2012
@@ -38,59 +38,37 @@ namespace httpget {
 /**
  * Evaluate an HTTP get.
  */
-const failable<value> get(const lambda<value(const list<value>&)>& url, http::CURLSession& ch) {
+const failable<value> get(const lvvlambda& url, const http::CURLSession& ch) {
     debug("httpget::get");
-    const value u = url(mklist<value>("get", list<value>()));
+    const value u = url(mklist<value>("get", nilListValue));
     debug(u, "httpget::get::url");
     return http::get(u, ch);
 }
 
 /**
- * Component implementation lambda function.
+ * Start the component.
  */
-class applyhttp {
-public:
-    applyhttp(const lambda<value(const list<value>&)>& url, const perthread_ptr<http::CURLSession>& ch) : url(url), ch(ch) {
-    }
+const failable<value> start(const list<value>& params) {
+    // Create a CURL session
+    const lvvlambda timeout = cadr(params);
+    const gc_pool cp(gc_current_pool());
+    const lambda<const gc_ptr<http::CURLSession>()> newsession = [timeout, cp]() -> const gc_ptr<http::CURLSession> {
+        const gc_scoped_pool sp(pool(cp));
+        const int t = atoi(c_str((string)timeout(nilListValue)));
+        return new (gc_new<http::CURLSession>()) http::CURLSession(emptyString, emptyString, emptyString, emptyString, t);
+    };
+    const perthread_ptr<http::CURLSession> ch = *(new (gc_new<perthread_ptr<http::CURLSession> >()) perthread_ptr<http::CURLSession>(newsession));
 
-    const value operator()(const list<value>& params) const {
+    // Return the component implementation lambda function
+    const lvvlambda url = car(params);
+    const lvvlambda applyhttp = [url, ch](const list<value>& params) -> const value {
         debug(params, "httpget::applyhttp::params");
         const value func(car(params));
         if (func == "get")
             return get(url, *ch);
         return mkfailure<value>();
-    }
-
-private:
-    const lambda<value(const list<value>&)> url;
-    perthread_ptr<http::CURLSession> ch;
-};
-
-
-/**
- * Create a new CURL session.
- */
-class newsession {
-public:
-    newsession(const lambda<value(const list<value>&)>& timeout) : timeout(timeout) {
-    }
-    const gc_ptr<http::CURLSession> operator()() const {
-        const int t = atoi(c_str((string)timeout(list<value>())));
-        return new (gc_new<http::CURLSession>()) http::CURLSession("", "", "", "", t);
-    }
-private:
-    const lambda<value(const list<value>&)> timeout;
-};
-
-/**
- * Start the component.
- */
-const failable<value> start(const list<value>& params) {
-    // Create a CURL session
-    const perthread_ptr<http::CURLSession> ch = perthread_ptr<http::CURLSession>(lambda<gc_ptr<http::CURLSession>()>(newsession(cadr(params))));
-
-    // Return the component implementation lambda function
-    return value(lambda<value(const list<value>&)>(applyhttp(car(params), ch)));
+    };
+    return value(applyhttp);
 }
 
 }

Modified: tuscany/sca-cpp/trunk/components/http/httppatch.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/http/httppatch.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/http/httppatch.cpp (original)
+++ tuscany/sca-cpp/trunk/components/http/httppatch.cpp Tue Dec 11 06:13:02 2012
@@ -38,61 +38,40 @@ namespace httppatch {
 /**
  * Evaluate an HTTP patch.
  */
-const failable<value> get(const lambda<value(const list<value>&)>& url, const lambda<value(const list<value>&)>& val, http::CURLSession& ch) {
+const failable<value> get(const lvvlambda& url, const lvvlambda& val, const http::CURLSession& ch) {
     debug("httppatch::get");
-    const value u = url(mklist<value>("get", list<value>()));
-    const value v = val(mklist<value>("get", list<value>()));
+    const value u = url(mklist<value>("get", nilListValue));
+    const value v = val(mklist<value>("get", nilListValue));
     debug(u, "httppatch::get::url");
     debug(v, "httppatch::get::val");
     return http::patch(v, u, ch);
 }
 
 /**
- * Component implementation lambda function.
+ * Start the component.
  */
-class applyhttp {
-public:
-    applyhttp(const lambda<value(const list<value>&)>& url, const lambda<value(const list<value>&)>& val, const perthread_ptr<http::CURLSession>& ch) : url(url), val(val), ch(ch) {
-    }
+const failable<value> start(const list<value>& params) {
+    // Create a CURL session
+    const lvvlambda timeout = caddr(params);
+    const gc_pool cp(gc_current_pool());
+    const lambda<const gc_ptr<http::CURLSession>()> newsession = [timeout, cp]() -> const gc_ptr<http::CURLSession> {
+        const gc_scoped_pool sp(pool(cp));
+        const int t = atoi(c_str((string)timeout(nilListValue)));
+        return new (gc_new<http::CURLSession>()) http::CURLSession(emptyString, emptyString, emptyString, emptyString, t);
+    };
+    const perthread_ptr<http::CURLSession> ch = *(new (gc_new<perthread_ptr<http::CURLSession> >()) perthread_ptr<http::CURLSession>(newsession));
 
-    const value operator()(const list<value>& params) const {
+    // Return the component implementation lambda function
+    const lvvlambda url = car(params);
+    const lvvlambda val = cadr(params);
+    const lvvlambda applyhttp = [url, val, ch](const list<value>& params) -> const value {
         debug(params, "httppatch::applyhttp::params");
         const value func(car(params));
         if (func == "get")
             return get(url, val, *ch);
         return mkfailure<value>();
-    }
-
-private:
-    const lambda<value(const list<value>&)> url;
-    const lambda<value(const list<value>&)> val;
-    perthread_ptr<http::CURLSession> ch;
-};
-
-/**
- * Create a new CURL session.
- */
-class newsession {
-public:
-    newsession(const lambda<value(const list<value>&)>& timeout) : timeout(timeout) {
-    }
-    const gc_ptr<http::CURLSession> operator()() const {
-        const int t = atoi(c_str((string)timeout(list<value>())));
-        return new (gc_new<http::CURLSession>()) http::CURLSession("", "", "", "", t);
-    }
-private:
-    const lambda<value(const list<value>&)> timeout;
-};
-
-/**
- * Start the component.
- */
-const failable<value> start(const list<value>& params) {
-    // Create a CURL session
-    const perthread_ptr<http::CURLSession> ch = perthread_ptr<http::CURLSession>(lambda<gc_ptr<http::CURLSession>()>(newsession(caddr(params))));
-
-    // Return the component implementation lambda function
-    return value(lambda<value(const list<value>&)>(applyhttp(car(params), cadr(params), ch)));
+    };
+    return value(applyhttp);
 }
 
 }

Modified: tuscany/sca-cpp/trunk/components/http/httppost.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/http/httppost.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/http/httppost.cpp (original)
+++ tuscany/sca-cpp/trunk/components/http/httppost.cpp Tue Dec 11 06:13:02 2012
@@ -38,61 +38,40 @@ namespace httppost {
 /**
  * Evaluate an HTTP post.
  */
-const failable<value> get(const lambda<value(const list<value>&)>& url, const lambda<value(const list<value>&)>& val, http::CURLSession& ch) {
+const failable<value> get(const lvvlambda& url, const lvvlambda& val, const http::CURLSession& ch) {
     debug("httppost::get");
-    const value u = url(mklist<value>("get", list<value>()));
-    const value v = val(mklist<value>("get", list<value>()));
+    const value u = url(mklist<value>("get", nilListValue));
+    const value v = val(mklist<value>("get", nilListValue));
     debug(u, "httppost::get::url");
     debug(v, "httppost::get::val");
     return http::post(v, u, ch);
 }
 
 /**
- * Component implementation lambda function.
+ * Start the component.
  */
-class applyhttp {
-public:
-    applyhttp(const lambda<value(const list<value>&)>& url, const lambda<value(const list<value>&)>& val, const perthread_ptr<http::CURLSession>& ch) : url(url), val(val), ch(ch) {
-    }
+const failable<value> start(const list<value>& params) {
+    // Create a CURL session
+    const lvvlambda timeout = caddr(params);
+    const gc_pool cp(gc_current_pool());
+    const lambda<const gc_ptr<http::CURLSession>()> newsession = [timeout, cp]() -> const gc_ptr<http::CURLSession> {
+        const gc_scoped_pool sp(pool(cp));
+        const int t = atoi(c_str((string)timeout(nilListValue)));
+        return new (gc_new<http::CURLSession>()) http::CURLSession(emptyString, emptyString, emptyString, emptyString, t);
+    };
+    const perthread_ptr<http::CURLSession> ch = *(new (gc_new<perthread_ptr<http::CURLSession> >()) perthread_ptr<http::CURLSession>(newsession));
 
-    const value operator()(const list<value>& params) const {
+    // Return the component implementation lambda function
+    const lvvlambda url = car(params);
+    const lvvlambda val = cadr(params);
+    const lvvlambda applyhttp = [url, val, ch](const list<value>& params) -> const value {
         debug(params, "httppost::applyhttp::params");
         const value func(car(params));
         if (func == "get")
             return get(url, val, *ch);
         return mkfailure<value>();
-    }
-
-private:
-    const lambda<value(const list<value>&)> url;
-    const lambda<value(const list<value>&)> val;
-    perthread_ptr<http::CURLSession> ch;
-};
-
-/**
- * Create a new CURL session.
- */
-class newsession {
-public:
-    newsession(const lambda<value(const list<value>&)>& timeout) : timeout(timeout) {
-    }
-    const gc_ptr<http::CURLSession> operator()() const {
-        const int t = atoi(c_str((string)timeout(list<value>())));
-        return new (gc_new<http::CURLSession>()) http::CURLSession("", "", "", "", t);
-    }
-private:
-    const lambda<const value(const list<value>&)> timeout;
-};
-
-/**
- * Start the component.
- */
-const failable<value> start(const list<value>& params) {
-    // Create a CURL session
-    const perthread_ptr<http::CURLSession> ch = perthread_ptr<http::CURLSession>(lambda<gc_ptr<http::CURLSession>()>(newsession(caddr(params))));
-
-    // Return the component implementation lambda function
-    return value(lambda<value(const list<value>&)>(applyhttp(car(params), cadr(params), ch)));
+    };
+    return value(applyhttp);
 }
 
 }

Modified: tuscany/sca-cpp/trunk/components/http/httpput.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/http/httpput.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/http/httpput.cpp (original)
+++ tuscany/sca-cpp/trunk/components/http/httpput.cpp Tue Dec 11 06:13:02 2012
@@ -38,61 +38,40 @@ namespace httpput {
 /**
  * Evaluate an HTTP put.
  */
-const failable<value> get(const lambda<value(const list<value>&)>& url, const lambda<value(const list<value>&)>& val, http::CURLSession& ch) {
+const failable<value> get(const lvvlambda& url, const lvvlambda& val, const http::CURLSession& ch) {
     debug("httpput::get");
-    const value u = url(mklist<value>("get", list<value>()));
-    const value v = val(mklist<value>("get", list<value>()));
+    const value u = url(mklist<value>("get", nilListValue));
+    const value v = val(mklist<value>("get", nilListValue));
     debug(u, "httpput::get::url");
     debug(v, "httpput::get::val");
     return http::put(v, u, ch);
 }
 
 /**
- * Component implementation lambda function.
+ * Start the component.
  */
-class applyhttp {
-public:
-    applyhttp(const lambda<value(const list<value>&)>& url, const lambda<value(const list<value>&)>& val, const perthread_ptr<http::CURLSession>& ch) : url(url), val(val), ch(ch) {
-    }
+const failable<value> start(const list<value>& params) {
+    // Create a CURL session
+    const lvvlambda timeout = caddr(params);
+    const gc_pool cp(gc_current_pool());
+    const lambda<const gc_ptr<http::CURLSession>()> newsession = [timeout, cp]() -> const gc_ptr<http::CURLSession> {
+        const gc_scoped_pool sp(pool(cp));
+        const int t = atoi(c_str((string)timeout(nilListValue)));
+        return new (gc_new<http::CURLSession>()) http::CURLSession(emptyString, emptyString, emptyString, emptyString, t);
+    };
+    const perthread_ptr<http::CURLSession> ch = *(new (gc_new<perthread_ptr<http::CURLSession> >()) perthread_ptr<http::CURLSession>(newsession));
 
-    const value operator()(const list<value>& params) const {
+    // Return the component implementation lambda function
+    const lvvlambda url = car(params);
+    const lvvlambda val = cadr(params);
+    const lvvlambda applyhttp = [url, val, ch](const list<value>& params) -> const value {
         debug(params, "httpput::applyhttp::params");
         const value func(car(params));
         if (func == "get")
             return get(url, val, *ch);
         return mkfailure<value>();
-    }
-
-private:
-    const lambda<value(const list<value>&)> url;
-    const lambda<value(const list<value>&)> val;
-    perthread_ptr<http::CURLSession> ch;
-};
-
-/**
- * Create a new CURL session.
- */
-class newsession {
-public:
-    newsession(const lambda<value(const list<value>&)>& timeout) : timeout(timeout) {
-    }
-    const gc_ptr<http::CURLSession> operator()() const {
-        const int t = atoi(c_str((string)timeout(list<value>())));
-        return new (gc_new<http::CURLSession>()) http::CURLSession("", "", "", "", t);
-    }
-private:
-    const lambda<value(const list<value>&)> timeout;
-};
-
-/**
- * Start the component.
- */
-const failable<value> start(const list<value>& params) {
-    // Create a CURL session
-    const perthread_ptr<http::CURLSession> ch = perthread_ptr<http::CURLSession>(lambda<gc_ptr<http::CURLSession>()>(newsession(caddr(params))));
-
-    // Return the component implementation lambda function
-    return value(lambda<value(const list<value>&)>(applyhttp(car(params), cadr(params), ch)));
+    };
+    return value(applyhttp);
 }
 
 }

Modified: tuscany/sca-cpp/trunk/components/log/Makefile.am
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/log/Makefile.am?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/log/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/components/log/Makefile.am Tue Dec 11 06:13:02 2012
@@ -70,7 +70,7 @@ scribe_status_SOURCES = scribe-status.cp
 scribe_status_LDFLAGS = -L${THRIFT_LIB} -R${THRIFT_LIB} -lthrift -L${FB303_LIB} -R${FB303_LIB} -lfb303 -L${SCRIBE_LIB} -R${SCRIBE_LIB} -lscribe
 
 client_test_SOURCES = client-test.cpp
-client_test_LDFLAGS = -lxml2 -lcurl -lmozjs
+client_test_LDFLAGS = -lxml2 -lcurl -ljansson
 
 dist_noinst_SCRIPTS = scribe-test server-test
 noinst_PROGRAMS = client-test

Modified: tuscany/sca-cpp/trunk/components/log/client-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/log/client-test.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/log/client-test.cpp (original)
+++ tuscany/sca-cpp/trunk/components/log/client-test.cpp Tue Dec 11 06:13:02 2012
@@ -38,15 +38,15 @@ namespace log {
 
 const string uri("http://localhost:8090/log");
 
-bool testLog() {
-    http::CURLSession cs("", "", "", "", 0);
+const bool testLog() {
+    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);
@@ -55,40 +55,31 @@ bool testLog() {
     return true;
 }
 
-struct logLoop {
-    const value a;
-    const string uri;
-    http::CURLSession& cs;
-    logLoop(const value& a, const string& uri, http::CURLSession& cs) : a(a), uri(uri), cs(cs) {
-    }
-    const bool operator()() const {
-        const failable<value> id = http::post(a, uri, cs);
-        assert(hasContent(id));
-        return true;
-    }
-};
-
-bool testLogPerf() {
-    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 bool testLogPerf() {
+    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);
 
-    http::CURLSession cs("", "", "", "", 0);
+    const http::CURLSession cs("", "", "", "", 0);
     const failable<value> id = http::post(a, uri, cs);
     assert(hasContent(id));
 
-    const lambda<bool()> ll = logLoop(a, uri, cs);
+    const blambda ll = [a, uri, cs]() -> const bool {
+        const failable<value> id = http::post(a, uri, cs);
+        assert(hasContent(id));
+        return true;
+    };
     cout << "Log test " << time(ll, 5, 200) << " ms" << endl;
 
     return true;
 }
 
-bool testLogger() {
-    http::CURLSession cs("", "", "", "", 0);
+const bool testLogger() {
+    const http::CURLSession cs("", "", "", "", 0);
 
     const failable<value> res = http::evalExpr(mklist<value>(string("sum"), 33, 22), string("http://localhost:8090/client"), cs);
     assert(hasContent(res));

Modified: tuscany/sca-cpp/trunk/components/log/log.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/log/log.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/log/log.cpp (original)
+++ tuscany/sca-cpp/trunk/components/log/log.cpp Tue Dec 11 06:13:02 2012
@@ -38,7 +38,7 @@ namespace log {
 /**
  * Post an item to the Scribe log.
  */
-const failable<value> post(const list<value>& params, const value& host, const value& category, scribe::Scribe& sc) {
+const failable<value> post(const list<value>& params, const value& host, const value& category, const scribe::Scribe& sc) {
     debug(cadr(params), "log::post::value");
     const failable<bool> val = scribe::log(cadr(params), host, category, sc);
     if (!hasContent(val))
@@ -47,41 +47,26 @@ const failable<value> post(const list<va
 }
 
 /**
- * Component implementation lambda function.
- */
-class applyLog {
-public:
-    applyLog(const value& host, const value& category, scribe::Scribe& sc) : host(host), category(category), sc(sc) {
-    }
-
-    const value operator()(const list<value>& params) const {
-        const value func(car(params));
-        if (func == "post")
-            return post(cdr(params), host, category, sc);
-        return mkfailure<value>();
-    }
-
-private:
-    const value host;
-    const value category;
-    scribe::Scribe& sc;
-};
-
-/**
  * Start the component.
  */
 const failable<value> start(const list<value>& params) {
     // Connect to Scribe
-    scribe::Scribe& sc = *(new (gc_new<scribe::Scribe>()) scribe::Scribe("localhost", 1464));
+    const scribe::Scribe& sc = *(new (gc_new<scribe::Scribe>()) scribe::Scribe("localhost", 1464));
 
     // Extract the configured category
-    const value host = ((lambda<value(const list<value>&)>)car(params))(list<value>());
-    const value category = ((lambda<value(const list<value>&)>)cadr(params))(list<value>());
+    const value host = ((lvvlambda)car(params))(nilListValue);
+    const value category = ((lvvlambda)cadr(params))(nilListValue);
     debug(host, "log::start::host");
     debug(category, "log::start::category");
 
     // Return the component implementation lambda function
-    return value(lambda<value(const list<value>&)>(applyLog(host, category, sc)));
+    const lvvlambda applyLog = [host, category, sc](const list<value>& params) -> const value {
+        const value func(car(params));
+        if (func == "post")
+            return post(cdr(params), host, category, sc);
+        return mkfailure<value>();
+    };
+    return value(applyLog);
 }
 
 }

Modified: tuscany/sca-cpp/trunk/components/log/logger.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/log/logger.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/log/logger.cpp (original)
+++ tuscany/sca-cpp/trunk/components/log/logger.cpp Tue Dec 11 06:13:02 2012
@@ -37,14 +37,21 @@ namespace tuscany {
 namespace logger {
 
 /**
- * Component implementation lambda function.
+ * Start the component.
  */
-class applyLog {
-public:
-    applyLog(const lambda<value(const list<value>&)>& relay, const value& host, const value& category, scribe::Scribe& sc) : relay(relay), host(host), category(category), sc(sc) {
-    }
+const failable<value> start(const list<value>& params) {
+    // Connect to Scribe
+    const scribe::Scribe& sc = *(new (gc_new<scribe::Scribe>()) scribe::Scribe("localhost", 1464));
 
-    const value operator()(const list<value>& params) const {
+    // Extract the configured relay service and category
+    const value relay = car(params);
+    const value host = ((lvvlambda)cadr(params))(nilListValue);
+    const value category = ((lvvlambda)caddr(params))(nilListValue);
+    debug(host, "logger::start::host");
+    debug(category, "logger::start::category");
+
+    // Return the component implementation lambda function
+    const lvvlambda applyLog = [relay, host, category, sc](const list<value>& params) -> const value {
         // Log the function params
         debug(params, "logger::apply::params");
         scribe::log(params, host, category, sc);
@@ -55,31 +62,8 @@ public:
         // Log the result
         scribe::log(res, host, category, sc);
         return res;
-    }
-
-private:
-    const lambda<value(const list<value>&)> relay;
-    const value host;
-    const value category;
-    scribe::Scribe& sc;
-};
-
-/**
- * Start the component.
- */
-const failable<value> start(const list<value>& params) {
-    // Connect to Scribe
-    scribe::Scribe& sc = *(new (gc_new<scribe::Scribe>()) scribe::Scribe("localhost", 1464));
-
-    // Extract the configured relay service and category
-    const value rel = car(params);
-    const value host = ((lambda<value(const list<value>&)>)cadr(params))(list<value>());
-    const value category = ((lambda<value(const list<value>&)>)caddr(params))(list<value>());
-    debug(host, "logger::start::host");
-    debug(category, "logger::start::category");
-
-    // Return the component implementation lambda function
-    return value(lambda<value(const list<value>&)>(applyLog(rel, host, category, sc)));
+    };
+    return value(applyLog);
 }
 
 }

Modified: tuscany/sca-cpp/trunk/components/log/scribe-cat.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/log/scribe-cat.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/log/scribe-cat.cpp (original)
+++ tuscany/sca-cpp/trunk/components/log/scribe-cat.cpp Tue Dec 11 06:13:02 2012
@@ -36,14 +36,14 @@
 namespace tuscany {
 namespace scribecat {
 
-int cat(const string& host, const string& category, const string& type) {
+const int cat(const string& host, const string& category, const string& type) {
     // Connect to Scribe
     scribe::Scribe& sc = *(new (gc_new<scribe::Scribe>()) scribe::Scribe(host, 1464));
 
     // Read lines from stdin and log them
     char buf[8193];
     for (;;) {
-        gc_scoped_pool p;
+        const gc_scoped_pool p;
 
         // Write line prefix
         ostringstream os;
@@ -54,7 +54,7 @@ int cat(const string& host, const string
         strcpy(buf, c_str(prefix));
 
         // Read log line
-        const char* s = fgets(buf + pl, 8192 - pl, stdin);
+        const char* const s = fgets(buf + pl, 8192 - pl, stdin);
         if (s == NULL)
             return 0;
 
@@ -73,7 +73,7 @@ int cat(const string& host, const string
 }
 }
 
-int main(const int argc, const char** argv) {
+int main(const int argc, const char** const argv) {
     return tuscany::scribecat::cat(argc < 2? "localhost" : argv[1], argc < 3? "default" : argv[2], argc < 4? "" : argv[3]);
 }
 

Modified: tuscany/sca-cpp/trunk/components/log/scribe-status.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/log/scribe-status.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/log/scribe-status.cpp (original)
+++ tuscany/sca-cpp/trunk/components/log/scribe-status.cpp Tue Dec 11 06:13:02 2012
@@ -60,7 +60,7 @@ const int status(const string& host, con
 }
 }
 
-int main(const int argc, const char** argv) {
+int main(const int argc, const char** const argv) {
     return tuscany::scribestatus::status(argc < 2? "localhost" : argv[1], argc < 3? 1463 : atoi(argv[2]));
 }
 

Modified: tuscany/sca-cpp/trunk/components/log/scribe.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/log/scribe.hpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/log/scribe.hpp (original)
+++ tuscany/sca-cpp/trunk/components/log/scribe.hpp Tue Dec 11 06:13:02 2012
@@ -74,21 +74,11 @@ public:
         init(host, port);
     }
 
-    Scribe(const Scribe& c) : owner(false) {
+    Scribe(const Scribe& c) : owner(false), client(c.client), transport(c.transport) {
         debug("scribe::scribe::copy");
-        client = c.client;
-        transport = c.transport;
     }
     
-    const Scribe& operator=(const Scribe& c) {
-        debug("scribe::scribe::operator=");
-        if(this == &c)
-            return *this;
-        owner = false;
-        client = c.client;
-        transport = c.transport;
-        return *this;
-    }
+    Scribe& operator=(const Scribe& c) = delete;
 
     ~Scribe() {
         if (!owner)
@@ -102,7 +92,7 @@ public:
     }
 
 private:
-    bool owner;
+    const bool owner;
     ::scribe::thrift::scribeClient* client;
     boost::shared_ptr<apache::thrift::transport::TTransport> transport;
 
@@ -135,8 +125,8 @@ const failable<bool> log(const value& va
     debug(category, "scribe::log::category");
 
     const value cat = isString(category)? value(c_str(category)):category;
-    const string cs(scheme::writeValue(cat));
-    const string vs(scheme::writeValue(val));
+    const string cs(write(content(scheme::writeValue(cat))));
+    const string vs(write(content(scheme::writeValue(val))));
     ostringstream os;
     os << "[" << host << "] " << vs;
 
@@ -147,8 +137,8 @@ const failable<bool> log(const value& va
         std::vector< ::scribe::thrift::LogEntry> msgs;
         msgs.push_back(entry);
 
-        int result = sc.client->Log(msgs);
-        if (result != ::scribe::thrift::OK)
+        const int result = sc.client->Log(msgs);
+        if (result != ::scribe::thrift::ResultCode::OK)
             return mkfailure<bool>("Could not log value, retry later");
     } catch (const std::exception& e) {
         return mkfailure<bool>(e.what());
@@ -165,24 +155,24 @@ const failable<string> status(const Scri
     debug("scribe::status");
 
     try {
-        ::facebook::fb303::fb_status s = sc.client->getStatus();
+        ::facebook::fb303::fb_status::type s = sc.client->getStatus();
         switch(s) {
-        case ::facebook::fb303::DEAD:
+        case ::facebook::fb303::fb_status::DEAD:
             debug("DEAD", "scribe::status::result");
             return string("DEAD");
-        case ::facebook::fb303::STARTING:
+        case ::facebook::fb303::fb_status::STARTING:
             debug("STARTING", "scribe::status::result");
             return string("STARTING");
-        case ::facebook::fb303::ALIVE:
+        case ::facebook::fb303::fb_status::ALIVE:
             debug("ALIVE", "scribe::status::result");
             return string("ALIVE");
-        case ::facebook::fb303::STOPPING:
+        case ::facebook::fb303::fb_status::STOPPING:
             debug("STOPPING", "scribe::status::result");
             return string("STOPPING");
-        case ::facebook::fb303::STOPPED:
+        case ::facebook::fb303::fb_status::STOPPED:
             debug("STOPPED", "scribe::status::result");
             return string("STOPPED");
-        case ::facebook::fb303::WARNING:
+        case ::facebook::fb303::fb_status::WARNING:
             debug("WARNING", "scribe::status::result");
             return string("WARNING");
         }

Modified: tuscany/sca-cpp/trunk/components/queue/Makefile.am
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/queue/Makefile.am?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/queue/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/components/queue/Makefile.am Tue Dec 11 06:13:02 2012
@@ -48,7 +48,7 @@ qpid_test_SOURCES = qpid-test.cpp
 qpid_test_LDFLAGS = -L${QPIDC_LIB} -R${QPIDC_LIB} -lqpidclient -lqpidcommon
 
 client_test_SOURCES = client-test.cpp
-client_test_LDFLAGS = -lxml2 -lcurl -lmozjs -L${QPIDC_LIB} -R${QPIDC_LIB} -lqpidclient -lqpidcommon
+client_test_LDFLAGS = -lxml2 -lcurl -ljansson -L${QPIDC_LIB} -R${QPIDC_LIB} -lqpidclient -lqpidcommon
 
 dist_noinst_SCRIPTS = send-test server-test
 noinst_PROGRAMS = qpid-test client-test

Modified: tuscany/sca-cpp/trunk/components/queue/client-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/queue/client-test.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/queue/client-test.cpp (original)
+++ tuscany/sca-cpp/trunk/components/queue/client-test.cpp Tue Dec 11 06:13:02 2012
@@ -46,15 +46,15 @@ namespace queue {
 const value key(mklist<value>(string("report")));
 const string qname("reportq");
 
-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);
 
-bool testDeclareQueue() {
+const bool testDeclareQueue() {
     QpidConnection qc;
     QpidSession qs(qc);
     const failable<bool> r = declareQueue(key, qname, qs);
@@ -69,18 +69,18 @@ const bool listener(const value& k, cons
     return false;
 }
 
-bool testListen() {
+const bool testListen() {
     QpidConnection qc;
     QpidSession qs(qc);
     QpidSubscription qsub(qs);
-    const lambda<bool(const value&, const value&)> l(listener);
+    const lambda<const bool(const value&, const value&)> l(listener);
     listen(qname, l, qsub);
     return true;
 }
 
-bool testPost() {
-    gc_scoped_pool pool;
-    http::CURLSession ch("", "", "", "");
+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", ch);
     assert(hasContent(id));
     return true;

Modified: tuscany/sca-cpp/trunk/components/queue/qpid-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/queue/qpid-test.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/queue/qpid-test.cpp (original)
+++ tuscany/sca-cpp/trunk/components/queue/qpid-test.cpp Tue Dec 11 06:13:02 2012
@@ -45,7 +45,7 @@ namespace queue {
 const value key(mklist<value>("test"));
 const string qname("testq");
 
-bool testDeclareQueue() {
+const bool testDeclareQueue() {
     QpidConnection qc;
     QpidSession qs(qc);
     const failable<bool> r = declareQueue(key, qname, qs);
@@ -53,12 +53,12 @@ bool testDeclareQueue() {
     return true;
 }
 
-const list<value> item = list<value>()
-        + (list<value>() + "name" + string("Apple"))
-        + (list<value>() + "price" + string("$2.99"));
+const list<value> item = nilListValue
+        + (nilListValue + "name" + string("Apple"))
+        + (nilListValue + "price" + string("$2.99"));
 const list<value> entry = mklist<value>(string("item"), string("cart-53d67a61-aa5e-4e5e-8401-39edeba8b83b"), item);
 
-bool testPost() {
+const bool testPost() {
     QpidConnection qc;
     QpidSession qs(qc);
     const failable<bool> r = post(key, entry, qs);
@@ -72,11 +72,11 @@ const bool listener(const value& k, cons
     return false;
 }
 
-bool testListen() {
+const bool testListen() {
     QpidConnection qc;
     QpidSession qs(qc);
     QpidSubscription qsub(qs);
-    const lambda<bool(const value&, const value&)> l(listener);
+    const lambda<const bool(const value&, const value&)> l(listener);
     listen(qname, l, qsub);
     return true;
 }

Modified: tuscany/sca-cpp/trunk/components/queue/qpid.hpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/queue/qpid.hpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/queue/qpid.hpp (original)
+++ tuscany/sca-cpp/trunk/components/queue/qpid.hpp Tue Dec 11 06:13:02 2012
@@ -65,14 +65,7 @@ public:
         debug("queue::qpidonnection::copy");
     }
 
-    const QpidConnection& operator=(const QpidConnection& qc) {
-        debug("queue::qpidonnection::operator=");
-        if(this == &c)
-            return *this;
-        owner = false;
-        c = qc.c;
-        return *this;
-    }
+    QpidConnection& operator=(const QpidConnection& qc) = delete;
 
     ~QpidConnection() {
         debug("queue::~qpidonnection");
@@ -148,7 +141,7 @@ const failable<bool> close(QpidSession& 
  * Declare a key / AMQP queue pair.
  */
 const failable<bool> declareQueue(const value& key, const string& name, QpidSession& qs) {
-    const string ks(scheme::writeValue(key));
+    const string ks(write(content(scheme::writeValue(key))));
     try {
         qs.s.queueDeclare(qpid::client::arg::queue=c_str(name));
         qs.s.exchangeBind(qpid::client::arg::exchange="amq.direct", qpid::client::arg::queue=c_str(name), qpid::client::arg::bindingKey=c_str(ks));
@@ -164,8 +157,8 @@ const failable<bool> declareQueue(const 
 const failable<bool> post(const value& key, const value& val, QpidSession& qs) {
 
     // Send in a message with the given key.
-    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))));
     try {
         qpid::client::Message message;
         message.getDeliveryProperties().setRoutingKey(c_str(ks));
@@ -202,7 +195,7 @@ public:
     }
 
 private:
-    friend const failable<bool> listen(const string& name, const lambda<bool(const value&, const value&)>& l, QpidSubscription& qsub);
+    friend const failable<bool> listen(const string& name, const lambda<const bool(const value&, const value&)>& l, QpidSubscription& qsub);
     friend const failable<bool> stop(QpidSubscription& qsub);
 
     const bool owner;
@@ -214,14 +207,14 @@ private:
  */
 class Listener : public qpid::client::MessageListener {
 public:
-    Listener(const lambda<bool(const value&, const value&)> l, qpid::client::SubscriptionManager& subs) : l(l), subs(subs) {
+    Listener(const lambda<const bool(const value&, const value&)> l, qpid::client::SubscriptionManager& subs) : l(l), subs(subs) {
     }
 
     virtual void received(qpid::client::Message& msg) {
 
         // Call the listener function
-        const value k(scheme::readValue(msg.getDeliveryProperties().getRoutingKey().c_str()));
-        const value v(scheme::readValue(msg.getData().c_str()));
+        const value k(content(scheme::readValue(msg.getDeliveryProperties().getRoutingKey().c_str())));
+        const value v(content(scheme::readValue(msg.getData().c_str())));
         const bool r = l(k, v);
         if (!r) {
             try {
@@ -233,12 +226,12 @@ public:
     }
 
 private:
-    const lambda<bool(const value&, const value&)> l;
+    const lambda<const bool(const value&, const value&)> l;
     qpid::client::SubscriptionManager& subs;
 };
 
 
-const failable<bool> listen(const string& name, const lambda<bool(const value&, const value&)>& l, QpidSubscription& qsub) {
+const failable<bool> listen(const string& name, const lambda<const bool(const value&, const value&)>& l, QpidSubscription& qsub) {
     debug("queue::listen");
     Listener listener(l, qsub.subs);
     try {

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=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/queue/queue-listener.cpp (original)
+++ tuscany/sca-cpp/trunk/components/queue/queue-listener.cpp Tue Dec 11 06:13:02 2012
@@ -42,57 +42,45 @@ namespace tuscany {
 namespace queue {
 
 /**
- * A relay function that posts the AMQP 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 AMQP key and queue name
+    const value rel = car(params);
+    const value pk = ((lvvlambda)cadr(params))(nilListValue);
+    const value key = isList(pk)? (list<value>)pk : mklist<value>(pk);
+    const value qname = ((lvvlambda)caddr(params))(nilListValue);
+
+    // Create an AMQP session
+    QpidConnection qc(false);
+    QpidSession qs(qc, false);
+
+    // Declare the configured AMQP key / queue pair
+    declareQueue(key, qname, qs);
 
-    const bool operator()(const value& k, const value& v) const {
+    // Listen and relay messages in a worker thread
+    QpidSubscription qsub(qs, false);
+    const worker w(3);
+    const lambda<const bool(const value&, const value&)> rl = [rel](const value& k, const value& v) -> const bool {
+        // A relay function that posts the AMQP messages it receives to a relay component reference.
         debug(k, "queue::relay::key");
         debug(v, "queue::relay::value");
         const value res = rel(mklist<value>("post", isList(k)? (list<value>)k : mklist<value>(k), v));
         return true;
-    }
+    };
 
-private:
-    const lambda<value(const list<value>&)> rel;
-};
-
-/**
- * Subscribe and listen to an AMQP queue.
- */
-class subscribe {
-public:
-    subscribe(const string& qname, const lambda<bool(const value&, const value&)>& l, const QpidSubscription& qsub) : qname(qname), l(l), qsub(qsub) {
-    }
-
-    const failable<bool> operator()() const {
-        gc_pool pool;
+    // Subscribe and listen to the AMQP queue.
+    const lambda<const failable<bool>()> subscribe = [qname, rl, qsub]() -> const failable<bool> {
+        const gc_pool pool;
         debug(qname, "queue::subscribe::listen");
-        const failable<bool> r =  listen(qname, l, const_cast<QpidSubscription&>(qsub));
+        const failable<bool> r =  listen(qname, rl, const_cast<QpidSubscription&>(qsub));
         debug(qname, "queue::subscribe::stopped");
         return r;
-    }
-
-private:
-    const string qname;
-    const lambda<bool(const value&, const value&)> l;
-    const QpidSubscription qsub;
-};
-
-/**
- * Listener lambda function, responsible for starting an AMQP subscription in a worker thread, and
- * apply any function calls to the listener component. The only supported function is stop(),
- * called to stop the listener component and shutdown the worker thread.
- */
-class listener {
-public:
-    listener(QpidConnection& qc, QpidSession& qs, QpidSubscription& qsub, worker& w) : qc(qc), qs(qs), qsub(qsub), w(w) {
-    }
+    };
+    submit<failable<bool> >(w, subscribe);
 
-    const value operator()(const list<value>& params) const {
+    // Return the listener component lambda function
+    const lvvlambda listener = [qc, qs, qsub, w](const list<value>& params) -> const value {
         const tuscany::value func(car(params));
 
         // Stop the component
@@ -107,41 +95,9 @@ public:
         cancel(const_cast<worker&>(w));
 
         debug("queue::listener::stopped");
-        return failable<value>(value(lambda<value(const list<value>&)>()));
-    }
-
-private:
-    QpidConnection qc;
-    QpidSession qs;
-    QpidSubscription qsub;
-    worker w;
-};
-
-/**
- * Start the component.
- */
-const failable<value> start(const list<value>& params) {
-    // Extract the relay reference and the AMQP key and queue name
-    const value rel = car(params);
-    const value pk = ((lambda<value(const list<value>&)>)cadr(params))(list<value>());
-    const value key = isList(pk)? (list<value>)pk : mklist<value>(pk);
-    const value qname = ((lambda<value(const list<value>&)>)caddr(params))(list<value>());
-
-    // Create an AMQP session
-    QpidConnection qc(false);
-    QpidSession qs(qc, false);
-
-    // Declare the configured AMQP key / queue pair
-    declareQueue(key, qname, qs);
-
-    // Listen and relay messages in a worker thread
-    QpidSubscription qsub(qs, false);
-    worker w(3);
-    const lambda<bool(const value&, const value&)> rl = relay(rel);
-    submit<failable<bool> >(w, lambda<failable<bool>()>(subscribe(qname, rl, qsub)));
-
-    // Return the listener component lambda function
-    return value(lambda<value(const list<value>&)>(listener(qc, qs, qsub, w)));
+        return failable<value>(value(lvvlambda()));
+    };
+    return value(listener);
 }
 
 }

Modified: tuscany/sca-cpp/trunk/components/queue/queue-sender.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/queue/queue-sender.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/queue/queue-sender.cpp (original)
+++ tuscany/sca-cpp/trunk/components/queue/queue-sender.cpp Tue Dec 11 06:13:02 2012
@@ -48,7 +48,7 @@ const failable<value> post(const list<va
     QpidSession qs(qc);
 
     // Post the item
-    const value pk = ((lambda<value(const list<value>&)>)caddr(params))(list<value>());
+    const value pk = ((lvvlambda)caddr(params))(nilListValue);
     const value key = isList(pk)? append<value>(pk, (list<value>)car(params)) : cons<value>(pk, (list<value>)car(params));
     debug(key, "queue::post::key");
     debug(cadr(params), "queue::post::value");

Modified: tuscany/sca-cpp/trunk/components/smtp/Makefile.am
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/smtp/Makefile.am?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/smtp/Makefile.am (original)
+++ tuscany/sca-cpp/trunk/components/smtp/Makefile.am Tue Dec 11 06:13:02 2012
@@ -23,12 +23,12 @@ comp_LTLIBRARIES = libsmtppost.la
 noinst_DATA = libsmtppost${libsuffix}
 
 libsmtppost_la_SOURCES = smtppost.cpp
-libsmtppost_la_LDFLAGS = -lxml2 -lmozjs -curl
+libsmtppost_la_LDFLAGS = -lxml2 -ljansson -curl
 libsmtppost${libsuffix}:
 	ln -s .libs/libsmtppost${libsuffix}
 
 client_test_SOURCES = client-test.cpp
-client_test_LDFLAGS = -lxml2 -lcurl -lmozjs
+client_test_LDFLAGS = -lxml2 -lcurl -ljansson
 
 dist_noinst_SCRIPTS = server-test
 noinst_PROGRAMS = client-test

Modified: tuscany/sca-cpp/trunk/components/smtp/client-test.cpp
URL: http://svn.apache.org/viewvc/tuscany/sca-cpp/trunk/components/smtp/client-test.cpp?rev=1420007&r1=1420006&r2=1420007&view=diff
==============================================================================
--- tuscany/sca-cpp/trunk/components/smtp/client-test.cpp (original)
+++ tuscany/sca-cpp/trunk/components/smtp/client-test.cpp Tue Dec 11 06:13:02 2012
@@ -38,8 +38,8 @@ namespace smtp {
 
 const string postURI("http://localhost:8090/smtppost");
 
-bool testPost() {
-    http::CURLSession cs("", "", "", "", 0);
+const bool testPost() {
+    const http::CURLSession cs("", "", "", "", 0);
 
     const failable<value> val = http::get(postURI, cs);
     assert(hasContent(val));



Mime
View raw message