From c9bfccc35345ce58fb5774d4b0b6a9868b262c0a Mon Sep 17 00:00:00 2001 From: giorgio Date: Wed, 5 Sep 2012 08:31:30 +0000 Subject: git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@1381061 13f79535-47bb-0310-9956-ffa450edef68 --- .../branches/lightweight-sca/samples/Makefile.am | 22 +++ sca-cpp/branches/lightweight-sca/samples/README | 3 + .../lightweight-sca/samples/relay-gae/Makefile.am | 40 ++++ .../lightweight-sca/samples/relay-gae/app.yaml | 50 +++++ .../samples/relay-gae/domain.composite | 74 +++++++ .../samples/relay-gae/htdocs/index.html | 36 ++++ .../lightweight-sca/samples/relay-gae/relay.py | 21 ++ .../lightweight-sca/samples/relay-gae/start | 20 ++ .../lightweight-sca/samples/relay-gae/stop | 20 ++ .../samples/relay-python/Makefile.am | 25 +++ .../samples/relay-python/htdocs/index.html | 35 ++++ .../samples/relay-python/relay.composite | 74 +++++++ .../lightweight-sca/samples/relay-python/relay.py | 21 ++ .../lightweight-sca/samples/relay-python/start | 31 +++ .../lightweight-sca/samples/relay-python/stop | 20 ++ .../samples/store-cluster/Makefile.am | 36 ++++ .../domains/jane/currency-converter.py | 29 +++ .../store-cluster/domains/jane/fruits-catalog.py | 30 +++ .../store-cluster/domains/jane/htdocs/index.html | 156 +++++++++++++++ .../domains/jane/htdocs/login/index.html | 212 +++++++++++++++++++++ .../domains/jane/htdocs/logout/index.html | 44 +++++ .../store-cluster/domains/jane/shopping-cart.py | 76 ++++++++ .../store-cluster/domains/jane/store.composite | 63 ++++++ .../samples/store-cluster/domains/jane/store.py | 40 ++++ .../domains/joe/currency-converter.py | 29 +++ .../store-cluster/domains/joe/fruits-catalog.py | 30 +++ .../store-cluster/domains/joe/htdocs/index.html | 156 +++++++++++++++ .../domains/joe/htdocs/login/index.html | 212 +++++++++++++++++++++ .../domains/joe/htdocs/logout/index.html | 44 +++++ .../store-cluster/domains/joe/shopping-cart.py | 76 ++++++++ .../store-cluster/domains/joe/store.composite | 63 ++++++ .../samples/store-cluster/domains/joe/store.py | 40 ++++ .../samples/store-cluster/htdocs/index.html | 39 ++++ .../samples/store-cluster/htdocs/login/index.html | 212 +++++++++++++++++++++ .../samples/store-cluster/htdocs/logout/index.html | 44 +++++ .../samples/store-cluster/proxy-conf | 35 ++++ .../samples/store-cluster/proxy-ssl-conf | 41 ++++ .../samples/store-cluster/server-conf | 47 +++++ .../samples/store-cluster/server-ssl-conf | 66 +++++++ .../samples/store-cluster/server-test | 61 ++++++ .../samples/store-cluster/shared/shared.composite | 63 ++++++ .../samples/store-cluster/sqldb-master-conf | 47 +++++ .../samples/store-cluster/sqldb-standby-conf | 40 ++++ .../samples/store-cluster/ssl-start | 121 ++++++++++++ .../lightweight-sca/samples/store-cluster/ssl-stop | 44 +++++ .../lightweight-sca/samples/store-cluster/start | 80 ++++++++ .../lightweight-sca/samples/store-cluster/stop | 42 ++++ .../samples/store-cluster/tunnel-ssl-conf | 33 ++++ .../samples/store-constdb/Makefile.am | 25 +++ .../samples/store-constdb/currency-converter.scm | 27 +++ .../samples/store-constdb/fruits-catalog.scm | 30 +++ .../samples/store-constdb/htdocs/index.html | 156 +++++++++++++++ .../samples/store-constdb/server-test | 58 ++++++ .../samples/store-constdb/shopping-cart.scm | 82 ++++++++ .../samples/store-constdb/ssl-start | 36 ++++ .../lightweight-sca/samples/store-constdb/start | 33 ++++ .../lightweight-sca/samples/store-constdb/stop | 20 ++ .../samples/store-constdb/store.composite | 69 +++++++ .../samples/store-constdb/store.scm | 47 +++++ .../lightweight-sca/samples/store-cpp/Makefile.am | 40 ++++ .../samples/store-cpp/currency-converter.cpp | 67 +++++++ .../samples/store-cpp/fruits-catalog.cpp | 76 ++++++++ .../samples/store-cpp/htdocs/index.html | 156 +++++++++++++++ .../store-cpp/htdocs/test/items-request.txt | 6 + .../samples/store-cpp/htdocs/test/items-result.txt | 23 +++ .../store-cpp/htdocs/test/shopping-cart-entry.xml | 2 + .../lightweight-sca/samples/store-cpp/server-test | 58 ++++++ .../samples/store-cpp/shopping-cart.cpp | 135 +++++++++++++ .../lightweight-sca/samples/store-cpp/ssl-start | 36 ++++ .../lightweight-sca/samples/store-cpp/start | 33 ++++ .../lightweight-sca/samples/store-cpp/stop | 21 ++ .../samples/store-cpp/store.composite | 69 +++++++ .../lightweight-sca/samples/store-gae/Makefile.am | 44 +++++ .../lightweight-sca/samples/store-gae/app.yaml | 54 ++++++ .../samples/store-gae/currency-converter.py | 29 +++ .../samples/store-gae/domain-backend.composite | 31 +++ .../samples/store-gae/domain-frontend.composite | 65 +++++++ .../samples/store-gae/domain-single.composite | 70 +++++++ .../samples/store-gae/domain.composite | 70 +++++++ .../samples/store-gae/fruits-catalog.py | 30 +++ .../lightweight-sca/samples/store-gae/gmemcache.py | 45 +++++ .../samples/store-gae/htdocs/index.html | 175 +++++++++++++++++ .../samples/store-gae/htdocs/test/items-result.txt | 1 + .../lightweight-sca/samples/store-gae/htpasswd.py | 21 ++ .../lightweight-sca/samples/store-gae/server-test | 60 ++++++ .../samples/store-gae/shopping-cart.py | 82 ++++++++ .../lightweight-sca/samples/store-gae/start | 21 ++ .../lightweight-sca/samples/store-gae/stop | 21 ++ .../lightweight-sca/samples/store-gae/store.py | 40 ++++ .../lightweight-sca/samples/store-java/Makefile.am | 34 ++++ .../samples/store-java/htdocs/index.html | 156 +++++++++++++++ .../lightweight-sca/samples/store-java/server-test | 58 ++++++ .../lightweight-sca/samples/store-java/ssl-start | 38 ++++ .../lightweight-sca/samples/store-java/start | 34 ++++ .../lightweight-sca/samples/store-java/stop | 23 +++ .../samples/store-java/store.composite | 69 +++++++ .../store-java/store/CurrencyConverter.java | 28 +++ .../store-java/store/CurrencyConverterImpl.java | 45 +++++ .../store-java/store/FruitsCatalogImpl.java | 51 +++++ .../samples/store-java/store/ShoppingCartImpl.java | 113 +++++++++++ .../samples/store-python/Makefile.am | 28 +++ .../samples/store-python/currency-converter.py | 29 +++ .../samples/store-python/fruits-catalog.py | 30 +++ .../samples/store-python/htdocs/index.html | 156 +++++++++++++++ .../samples/store-python/htdocs/login/index.html | 51 +++++ .../samples/store-python/htdocs/logout/index.html | 43 +++++ .../store-python/htdocs/test/items-result.txt | 23 +++ .../samples/store-python/server-test | 58 ++++++ .../samples/store-python/shopping-cart.py | 75 ++++++++ .../lightweight-sca/samples/store-python/ssl-start | 37 ++++ .../lightweight-sca/samples/store-python/start | 33 ++++ .../lightweight-sca/samples/store-python/stop | 21 ++ .../samples/store-python/store.composite | 69 +++++++ .../lightweight-sca/samples/store-python/store.py | 40 ++++ .../samples/store-python/uec2-start | 47 +++++ .../samples/store-scheme/Makefile.am | 30 +++ .../samples/store-scheme/currency-converter.scm | 27 +++ .../samples/store-scheme/fruits-catalog.scm | 30 +++ .../samples/store-scheme/htdocs/index.html | 156 +++++++++++++++ .../samples/store-scheme/script-test.cpp | 96 ++++++++++ .../samples/store-scheme/script-test.scm | 140 ++++++++++++++ .../samples/store-scheme/server-test | 58 ++++++ .../samples/store-scheme/shopping-cart.scm | 82 ++++++++ .../lightweight-sca/samples/store-scheme/ssl-start | 36 ++++ .../lightweight-sca/samples/store-scheme/start | 33 ++++ .../lightweight-sca/samples/store-scheme/stop | 21 ++ .../samples/store-scheme/store.composite | 69 +++++++ .../lightweight-sca/samples/store-scheme/store.scm | 47 +++++ .../lightweight-sca/samples/store-sql/Makefile.am | 28 +++ .../samples/store-sql/currency-converter.scm | 27 +++ .../samples/store-sql/fruits-catalog.scm | 30 +++ .../samples/store-sql/htdocs/index.html | 156 +++++++++++++++ .../lightweight-sca/samples/store-sql/server-test | 58 ++++++ .../samples/store-sql/shopping-cart.scm | 82 ++++++++ .../lightweight-sca/samples/store-sql/ssl-start | 39 ++++ .../lightweight-sca/samples/store-sql/start | 36 ++++ .../lightweight-sca/samples/store-sql/stop | 22 +++ .../samples/store-sql/store.composite | 89 +++++++++ .../lightweight-sca/samples/store-sql/store.scm | 47 +++++ .../samples/store-vhost/Makefile.am | 28 +++ .../store-vhost/domains/jane/currency-converter.py | 29 +++ .../store-vhost/domains/jane/fruits-catalog.py | 30 +++ .../store-vhost/domains/jane/htdocs/index.html | 156 +++++++++++++++ .../store-vhost/domains/jane/shopping-cart.py | 75 ++++++++ .../store-vhost/domains/jane/store.composite | 61 ++++++ .../samples/store-vhost/domains/jane/store.py | 40 ++++ .../store-vhost/domains/joe/currency-converter.py | 29 +++ .../store-vhost/domains/joe/fruits-catalog.py | 30 +++ .../store-vhost/domains/joe/htdocs/index.html | 156 +++++++++++++++ .../store-vhost/domains/joe/shopping-cart.py | 75 ++++++++ .../store-vhost/domains/joe/store.composite | 61 ++++++ .../samples/store-vhost/domains/joe/store.py | 40 ++++ .../samples/store-vhost/htdocs/index.html | 39 ++++ .../samples/store-vhost/server-test | 61 ++++++ .../samples/store-vhost/shared/shared.composite | 32 ++++ .../lightweight-sca/samples/store-vhost/ssl-start | 48 +++++ .../lightweight-sca/samples/store-vhost/start | 39 ++++ .../lightweight-sca/samples/store-vhost/stop | 21 ++ .../lightweight-sca/samples/store-vhost/uec2-start | 52 +++++ 159 files changed, 8937 insertions(+) create mode 100644 sca-cpp/branches/lightweight-sca/samples/Makefile.am create mode 100644 sca-cpp/branches/lightweight-sca/samples/README create mode 100644 sca-cpp/branches/lightweight-sca/samples/relay-gae/Makefile.am create mode 100644 sca-cpp/branches/lightweight-sca/samples/relay-gae/app.yaml create mode 100644 sca-cpp/branches/lightweight-sca/samples/relay-gae/domain.composite create mode 100644 sca-cpp/branches/lightweight-sca/samples/relay-gae/htdocs/index.html create mode 100644 sca-cpp/branches/lightweight-sca/samples/relay-gae/relay.py create mode 100755 sca-cpp/branches/lightweight-sca/samples/relay-gae/start create mode 100755 sca-cpp/branches/lightweight-sca/samples/relay-gae/stop create mode 100644 sca-cpp/branches/lightweight-sca/samples/relay-python/Makefile.am create mode 100644 sca-cpp/branches/lightweight-sca/samples/relay-python/htdocs/index.html create mode 100644 sca-cpp/branches/lightweight-sca/samples/relay-python/relay.composite create mode 100644 sca-cpp/branches/lightweight-sca/samples/relay-python/relay.py create mode 100755 sca-cpp/branches/lightweight-sca/samples/relay-python/start create mode 100755 sca-cpp/branches/lightweight-sca/samples/relay-python/stop create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cluster/Makefile.am create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/currency-converter.py create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/fruits-catalog.py create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/htdocs/index.html create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/htdocs/login/index.html create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/htdocs/logout/index.html create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/shopping-cart.py create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/store.composite create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/store.py create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/currency-converter.py create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/fruits-catalog.py create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/htdocs/index.html create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/htdocs/login/index.html create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/htdocs/logout/index.html create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/shopping-cart.py create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/store.composite create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/store.py create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cluster/htdocs/index.html create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cluster/htdocs/login/index.html create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cluster/htdocs/logout/index.html create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-cluster/proxy-conf create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-cluster/proxy-ssl-conf create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-cluster/server-conf create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-cluster/server-ssl-conf create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-cluster/server-test create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cluster/shared/shared.composite create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-cluster/sqldb-master-conf create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-cluster/sqldb-standby-conf create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-cluster/ssl-start create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-cluster/ssl-stop create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-cluster/start create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-cluster/stop create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-cluster/tunnel-ssl-conf create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-constdb/Makefile.am create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-constdb/currency-converter.scm create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-constdb/fruits-catalog.scm create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-constdb/htdocs/index.html create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-constdb/server-test create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-constdb/shopping-cart.scm create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-constdb/ssl-start create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-constdb/start create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-constdb/stop create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-constdb/store.composite create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-constdb/store.scm create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cpp/Makefile.am create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cpp/currency-converter.cpp create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cpp/fruits-catalog.cpp create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cpp/htdocs/index.html create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cpp/htdocs/test/items-request.txt create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cpp/htdocs/test/items-result.txt create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cpp/htdocs/test/shopping-cart-entry.xml create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-cpp/server-test create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cpp/shopping-cart.cpp create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-cpp/ssl-start create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-cpp/start create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-cpp/stop create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-cpp/store.composite create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-gae/Makefile.am create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-gae/app.yaml create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-gae/currency-converter.py create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-gae/domain-backend.composite create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-gae/domain-frontend.composite create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-gae/domain-single.composite create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-gae/domain.composite create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-gae/fruits-catalog.py create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-gae/gmemcache.py create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-gae/htdocs/index.html create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-gae/htdocs/test/items-result.txt create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-gae/htpasswd.py create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-gae/server-test create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-gae/shopping-cart.py create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-gae/start create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-gae/stop create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-gae/store.py create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-java/Makefile.am create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-java/htdocs/index.html create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-java/server-test create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-java/ssl-start create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-java/start create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-java/stop create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-java/store.composite create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-java/store/CurrencyConverter.java create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-java/store/CurrencyConverterImpl.java create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-java/store/FruitsCatalogImpl.java create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-java/store/ShoppingCartImpl.java create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-python/Makefile.am create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-python/currency-converter.py create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-python/fruits-catalog.py create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-python/htdocs/index.html create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-python/htdocs/login/index.html create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-python/htdocs/logout/index.html create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-python/htdocs/test/items-result.txt create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-python/server-test create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-python/shopping-cart.py create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-python/ssl-start create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-python/start create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-python/stop create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-python/store.composite create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-python/store.py create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-python/uec2-start create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-scheme/Makefile.am create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-scheme/currency-converter.scm create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-scheme/fruits-catalog.scm create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-scheme/htdocs/index.html create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-scheme/script-test.cpp create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-scheme/script-test.scm create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-scheme/server-test create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-scheme/shopping-cart.scm create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-scheme/ssl-start create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-scheme/start create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-scheme/stop create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-scheme/store.composite create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-scheme/store.scm create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-sql/Makefile.am create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-sql/currency-converter.scm create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-sql/fruits-catalog.scm create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-sql/htdocs/index.html create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-sql/server-test create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-sql/shopping-cart.scm create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-sql/ssl-start create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-sql/start create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-sql/stop create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-sql/store.composite create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-sql/store.scm create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-vhost/Makefile.am create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/currency-converter.py create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/fruits-catalog.py create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/htdocs/index.html create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/shopping-cart.py create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/store.composite create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/store.py create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/currency-converter.py create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/fruits-catalog.py create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/htdocs/index.html create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/shopping-cart.py create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/store.composite create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/store.py create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-vhost/htdocs/index.html create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-vhost/server-test create mode 100644 sca-cpp/branches/lightweight-sca/samples/store-vhost/shared/shared.composite create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-vhost/ssl-start create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-vhost/start create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-vhost/stop create mode 100755 sca-cpp/branches/lightweight-sca/samples/store-vhost/uec2-start (limited to 'sca-cpp/branches/lightweight-sca/samples') diff --git a/sca-cpp/branches/lightweight-sca/samples/Makefile.am b/sca-cpp/branches/lightweight-sca/samples/Makefile.am new file mode 100644 index 0000000000..604a963d5d --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/Makefile.am @@ -0,0 +1,22 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +SUBDIRS = store-scheme store-cpp store-python store-java store-gae store-sql store-constdb store-vhost store-cluster relay-python relay-gae + +sample_DATA = README +sampledir=$(prefix)/samples + diff --git a/sca-cpp/branches/lightweight-sca/samples/README b/sca-cpp/branches/lightweight-sca/samples/README new file mode 100644 index 0000000000..818a2faaf8 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/README @@ -0,0 +1,3 @@ +Apache Tuscany SCA Samples +========================== + diff --git a/sca-cpp/branches/lightweight-sca/samples/relay-gae/Makefile.am b/sca-cpp/branches/lightweight-sca/samples/relay-gae/Makefile.am new file mode 100644 index 0000000000..7b24ddde27 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/relay-gae/Makefile.am @@ -0,0 +1,40 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +if WANT_PYTHON +if WANT_GAE + +dist_sample_SCRIPTS = start stop +sampledir = $(prefix)/samples/relay-gae + +BUILT_SOURCES = target.stamp +target.stamp: app.yaml *.py *.composite $(top_builddir)/modules/wsgi/*.py htdocs/*.html + mkdir -p target + cp app.yaml *.py *.composite `ls $(top_builddir)/modules/wsgi/*.py | grep -v "\-test"` target + mkdir -p target/htdocs + cp -R htdocs/* target/htdocs + touch target.stamp + +clean-local: + rm -rf target.stamp target + +nobase_sample_DATA = target/app.yaml target/*.py target/*.composite target/htdocs/*.html + +EXTRA_DIST = app.yaml *.composite *.py htdocs/*.html + +endif +endif diff --git a/sca-cpp/branches/lightweight-sca/samples/relay-gae/app.yaml b/sca-cpp/branches/lightweight-sca/samples/relay-gae/app.yaml new file mode 100644 index 0000000000..d4e78701bc --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/relay-gae/app.yaml @@ -0,0 +1,50 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +application: sca-relay +version: 1 +runtime: python +api_version: 1 +skip_files: +- ^(.*/)?app\.yaml +- ^(.*/)?app\.yml +- ^(.*/)?index\.yaml +- ^(.*/)?index\.yml +- ^(.*/)?#.*# +- ^(.*/)?.*~ +- ^(.*/)?.*\.py[co] +- ^(.*/)?.*/RCS/.* +- ^(.*/)?\..* +- ^(.*/)?.*-test$ +- ^(.*/)?.*\.cpp$ +- ^(.*/)?.*\.o$ +- ^(.*/)?core$ +- ^(.*/)?.*\.out$ +- ^(.*/)?.*\.log$ +- ^(.*/)?Makefile.* +- ^(.*/)?tmp/.* +- ^(.*/)?wsgi-start +- ^(.*/)?wsgi-stop + +handlers: +- url: /(.*\.(html|png)) + static_files: htdocs/\1 + upload: htdocs/(.*\.(html|png)) + +- url: /.* + script: composite.py + diff --git a/sca-cpp/branches/lightweight-sca/samples/relay-gae/domain.composite b/sca-cpp/branches/lightweight-sca/samples/relay-gae/domain.composite new file mode 100644 index 0000000000..470ac88da1 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/relay-gae/domain.composite @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-cpp/branches/lightweight-sca/samples/relay-gae/htdocs/index.html b/sca-cpp/branches/lightweight-sca/samples/relay-gae/htdocs/index.html new file mode 100644 index 0000000000..b8b606d3d9 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/relay-gae/htdocs/index.html @@ -0,0 +1,36 @@ + + + + + + + +Relay + + + +

Sample HTML request

+

Sample Twitter JSON request

+

Sample Twitter XML request

+

Sample Twitter RSS request

+

Sample Facebook JSON request

+ + + diff --git a/sca-cpp/branches/lightweight-sca/samples/relay-gae/relay.py b/sca-cpp/branches/lightweight-sca/samples/relay-gae/relay.py new file mode 100644 index 0000000000..5fe99803c1 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/relay-gae/relay.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Relay implementation +def get(id, target): + return target.get(id) + diff --git a/sca-cpp/branches/lightweight-sca/samples/relay-gae/start b/sca-cpp/branches/lightweight-sca/samples/relay-gae/start new file mode 100755 index 0000000000..2e219758a8 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/relay-gae/start @@ -0,0 +1,20 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +../../modules/wsgi/gae-start target 8090 diff --git a/sca-cpp/branches/lightweight-sca/samples/relay-gae/stop b/sca-cpp/branches/lightweight-sca/samples/relay-gae/stop new file mode 100755 index 0000000000..3aff1d5a77 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/relay-gae/stop @@ -0,0 +1,20 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +../../modules/wsgi/gae-stop target 8090 diff --git a/sca-cpp/branches/lightweight-sca/samples/relay-python/Makefile.am b/sca-cpp/branches/lightweight-sca/samples/relay-python/Makefile.am new file mode 100644 index 0000000000..57938aff69 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/relay-python/Makefile.am @@ -0,0 +1,25 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +if WANT_PYTHON + +dist_sample_SCRIPTS = start stop +sampledir = $(prefix)/samples/relay-python + +nobase_dist_sample_DATA = relay.py relay.composite htdocs/*.html + +endif diff --git a/sca-cpp/branches/lightweight-sca/samples/relay-python/htdocs/index.html b/sca-cpp/branches/lightweight-sca/samples/relay-python/htdocs/index.html new file mode 100644 index 0000000000..ad5f86aa02 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/relay-python/htdocs/index.html @@ -0,0 +1,35 @@ + + + + + + + +Relay + + +

Sample HTML request

+

Sample Twitter JSON request

+

Sample Twitter XML request

+

Sample Twitter RSS request

+

Sample Facebook JSON request

+ + + diff --git a/sca-cpp/branches/lightweight-sca/samples/relay-python/relay.composite b/sca-cpp/branches/lightweight-sca/samples/relay-python/relay.composite new file mode 100644 index 0000000000..470ac88da1 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/relay-python/relay.composite @@ -0,0 +1,74 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-cpp/branches/lightweight-sca/samples/relay-python/relay.py b/sca-cpp/branches/lightweight-sca/samples/relay-python/relay.py new file mode 100644 index 0000000000..5fe99803c1 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/relay-python/relay.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Relay implementation +def get(id, target): + return target.get(id) + diff --git a/sca-cpp/branches/lightweight-sca/samples/relay-python/start b/sca-cpp/branches/lightweight-sca/samples/relay-python/start new file mode 100755 index 0000000000..e9d9d2d51f --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/relay-python/start @@ -0,0 +1,31 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +../../modules/http/httpd-conf tmp localhost 8090 htdocs +../../modules/http/httpd-event-conf tmp +../../modules/server/server-conf tmp +../../modules/python/python-conf tmp +cat >>tmp/conf/httpd.conf < + + + + + + +Jane's Store + + + + + + + +

Jane's Store

+
+
+

Catalog

+
+
+
+ +
+
+ +

Your Shopping Cart

+
+
+
+
+
+ + +(feed) +
+
+ + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/htdocs/login/index.html b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/htdocs/login/index.html new file mode 100644 index 0000000000..2a7be01ff1 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/htdocs/login/index.html @@ -0,0 +1,212 @@ + + + + + + + + + +Sign in + + +

Sign in with an OpenID or OAuth provider

+
+ + + +
+

Sign in with your Google account

+

Sign in with your Yahoo account

+

Sign in with your MyOpenID account

+

Sign in with your Verisign account

+

Sign in with your MySpace account

+ +

Sign in with a Google apps domain
+
+

+ +

Sign in with your Livejournal account
+
+

+ +

Sign in with your Blogspot account
+
+

+ +

Sign in with your Blogger account
+
+

+ +

Sign in with an OpenID endpoint
+
+

+ +

Sign in with your Facebook account

+

Sign in with your Github account

+ +

Sign in with your Linkedin account

+

Sign in with your Twitter account

+
+ +
+ +
+ +
+ + + + + + + +
+ +
+ + + + + + +
+ + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/htdocs/logout/index.html b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/htdocs/logout/index.html new file mode 100644 index 0000000000..50a10bdd8b --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/htdocs/logout/index.html @@ -0,0 +1,44 @@ + + + + + + + + + +Sign out + + +

Sign out

+
+ +
+ + +
+ + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/shopping-cart.py b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/shopping-cart.py new file mode 100644 index 0000000000..b3818a6727 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/shopping-cart.py @@ -0,0 +1,76 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Shopping cart implementation +import uuid +import sys + +# Convert a particular host and user email to a cart id +def cartid(host, email): + return ("cart", host.eval(), email.eval()) + +# Get the shopping cart from the cache +# Return an empty cart if not found +def getcart(id, cache): + cart = cache.get(id) + if cart is None: + return () + return cart + +# Post a new item to the cart, create a new cart if necessary +def post(collection, item, cache, host, email): + id = str(uuid.uuid1()) + cart = (("'entry", item[0][1], ("'id", id), item[0][3]),) + getcart(cartid(host, email), cache) + cache.put(cartid(host, email), cart) + return (id,) + + +# Find an item in the cart +def find(id, cart): + if cart == (): + return (("'entry", ("'title", "Item"), ("'id", 0)),) + elif id == cart[0][2][1]: + return (cart[0],) + else: + return find(id, cart[1:]) + +# Get items from the cart +def get(id, cache, host, email): + if id == (): + return ((("'feed", ("'title", "Your Cart"), ("'id", email.eval())) + getcart(cartid(host,email), cache)),) + return find(id[0], getcart(cartid(host, email), cache)) + +# Delete items from the cart +def delete(id, cache, host, email): + if id == (): + return cache.delete(cartid(host, email)) + return True + +# Return the price of an item +def price(item): + return float(filter(lambda x: x[0] == "'price", item[3][1][1:])[0][1]) + +# Sum the prices of a list of items +def sum(items): + if items == (): + return 0 + return price(items[0]) + sum(items[1:]) + +# Return the total price of the items in the cart +def total(cache, host, email): + return sum(getcart(cartid(host, email), cache)) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/store.composite b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/store.composite new file mode 100644 index 0000000000..c8955af24e --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/store.composite @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + USD + + + + + + + + + localhost + anonymous@localhost + + + + + + + + + + + + + + + + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/store.py b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/store.py new file mode 100644 index 0000000000..ff82f1d327 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/jane/store.py @@ -0,0 +1,40 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Store implementation + +def post(item, catalog, shoppingCart, shoppingTotal): + return shoppingCart.post(item) + +def getall(catalog, shoppingCart, shoppingTotal): + return shoppingCart.getall() + +def get(id, catalog, shoppingCart, shoppingTotal): + return shoppingCart.get(id) + +def items(catalog, shoppingCart, shoppingTotal): + return catalog.items() + +def total(catalog, shoppingCart, shoppingTotal): + return shoppingCart.total() + +def deleteall(catalog, shoppingCart, shoppingTotal): + return shoppingCart.deleteall() + +def delete(id, catalog, shoppingCart, shoppingTotal): + return shoppingCart.delete(id) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/currency-converter.py b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/currency-converter.py new file mode 100644 index 0000000000..2fded8f616 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/currency-converter.py @@ -0,0 +1,29 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Currency converter implementation + +def convert(fr, to, amount): + if to == "EUR": + return amount * 0.70 + return amount + +def symbol(currency): + if currency == "EUR": + return "E" + return "$" + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/fruits-catalog.py b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/fruits-catalog.py new file mode 100644 index 0000000000..6644421683 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/fruits-catalog.py @@ -0,0 +1,30 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Catalog implementation + +def items(converter, currencyCode): + code = currencyCode.eval() + def convert(price): + return converter.convert("USD", code, price) + symbol = converter.symbol(code) + return ( + (("'name", "Apple"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(2.99))), + (("'name", "Orange"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(3.55))), + (("'name", "Pear"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(1.55))) + ) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/htdocs/index.html b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/htdocs/index.html new file mode 100644 index 0000000000..0caf8b3df1 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/htdocs/index.html @@ -0,0 +1,156 @@ + + + + + + + +Joe's Store + + + + + + + +

Joe's Store

+
+
+

Catalog

+
+
+
+ +
+
+ +

Your Shopping Cart

+
+
+
+
+
+ + +(feed) +
+
+ + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/htdocs/login/index.html b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/htdocs/login/index.html new file mode 100644 index 0000000000..2a7be01ff1 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/htdocs/login/index.html @@ -0,0 +1,212 @@ + + + + + + + + + +Sign in + + +

Sign in with an OpenID or OAuth provider

+
+ + + +
+

Sign in with your Google account

+

Sign in with your Yahoo account

+

Sign in with your MyOpenID account

+

Sign in with your Verisign account

+

Sign in with your MySpace account

+ +

Sign in with a Google apps domain
+
+

+ +

Sign in with your Livejournal account
+
+

+ +

Sign in with your Blogspot account
+
+

+ +

Sign in with your Blogger account
+
+

+ +

Sign in with an OpenID endpoint
+
+

+ +

Sign in with your Facebook account

+

Sign in with your Github account

+ +

Sign in with your Linkedin account

+

Sign in with your Twitter account

+
+ +
+ +
+ +
+ + + + + + + +
+ +
+ + + + + + +
+ + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/htdocs/logout/index.html b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/htdocs/logout/index.html new file mode 100644 index 0000000000..50a10bdd8b --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/htdocs/logout/index.html @@ -0,0 +1,44 @@ + + + + + + + + + +Sign out + + +

Sign out

+
+ +
+ + +
+ + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/shopping-cart.py b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/shopping-cart.py new file mode 100644 index 0000000000..b3818a6727 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/shopping-cart.py @@ -0,0 +1,76 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Shopping cart implementation +import uuid +import sys + +# Convert a particular host and user email to a cart id +def cartid(host, email): + return ("cart", host.eval(), email.eval()) + +# Get the shopping cart from the cache +# Return an empty cart if not found +def getcart(id, cache): + cart = cache.get(id) + if cart is None: + return () + return cart + +# Post a new item to the cart, create a new cart if necessary +def post(collection, item, cache, host, email): + id = str(uuid.uuid1()) + cart = (("'entry", item[0][1], ("'id", id), item[0][3]),) + getcart(cartid(host, email), cache) + cache.put(cartid(host, email), cart) + return (id,) + + +# Find an item in the cart +def find(id, cart): + if cart == (): + return (("'entry", ("'title", "Item"), ("'id", 0)),) + elif id == cart[0][2][1]: + return (cart[0],) + else: + return find(id, cart[1:]) + +# Get items from the cart +def get(id, cache, host, email): + if id == (): + return ((("'feed", ("'title", "Your Cart"), ("'id", email.eval())) + getcart(cartid(host,email), cache)),) + return find(id[0], getcart(cartid(host, email), cache)) + +# Delete items from the cart +def delete(id, cache, host, email): + if id == (): + return cache.delete(cartid(host, email)) + return True + +# Return the price of an item +def price(item): + return float(filter(lambda x: x[0] == "'price", item[3][1][1:])[0][1]) + +# Sum the prices of a list of items +def sum(items): + if items == (): + return 0 + return price(items[0]) + sum(items[1:]) + +# Return the total price of the items in the cart +def total(cache, host, email): + return sum(getcart(cartid(host, email), cache)) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/store.composite b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/store.composite new file mode 100644 index 0000000000..c8955af24e --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/store.composite @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + USD + + + + + + + + + localhost + anonymous@localhost + + + + + + + + + + + + + + + + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/store.py b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/store.py new file mode 100644 index 0000000000..811b05c580 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/domains/joe/store.py @@ -0,0 +1,40 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Store implementation + +def post(item, catalog, shoppingCart, shoppingTotal): + return shoppingCart.post(item) + +def getall(catalog, shoppingCart, shoppingTotal): + return shoppingCart.getall() + +def get(id, catalog, shoppingCart, shoppingTotal): + return shoppingCart.get(id) + +def items(catalog, shoppingCart, shoppingTotal): + return catalog.items() + +def total(catalog, shoppingCart, shoppingTotal): + return shoppingCart.total() + +def deleteall(catalog, shoppingCart, shoppingTotal): + return shoppingCart.deletall() + +def delete(id, catalog, shoppingCart, shoppingTotal): + return shoppingCart.delete(id) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/htdocs/index.html b/sca-cpp/branches/lightweight-sca/samples/store-cluster/htdocs/index.html new file mode 100644 index 0000000000..50c7e25ee6 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/htdocs/index.html @@ -0,0 +1,39 @@ + + + + + + + +Store + + + +

Store

+
+

For this sample to work, add the sample domain to your /etc/hosts as follows:
+127.0.0.1 example.com jane.example.com joe.example.com

+ +

+

Jane's store at jane.example.com +
Joe's store at joe.example.com

+ + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/htdocs/login/index.html b/sca-cpp/branches/lightweight-sca/samples/store-cluster/htdocs/login/index.html new file mode 100644 index 0000000000..2a7be01ff1 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/htdocs/login/index.html @@ -0,0 +1,212 @@ + + + + + + + + + +Sign in + + +

Sign in with an OpenID or OAuth provider

+
+ + + +
+

Sign in with your Google account

+

Sign in with your Yahoo account

+

Sign in with your MyOpenID account

+

Sign in with your Verisign account

+

Sign in with your MySpace account

+ +

Sign in with a Google apps domain
+
+

+ +

Sign in with your Livejournal account
+
+

+ +

Sign in with your Blogspot account
+
+

+ +

Sign in with your Blogger account
+
+

+ +

Sign in with an OpenID endpoint
+
+

+ +

Sign in with your Facebook account

+

Sign in with your Github account

+ +

Sign in with your Linkedin account

+

Sign in with your Twitter account

+
+ +
+ +
+ +
+ + + + + + + +
+ +
+ + + + + + +
+ + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/htdocs/logout/index.html b/sca-cpp/branches/lightweight-sca/samples/store-cluster/htdocs/logout/index.html new file mode 100644 index 0000000000..50a10bdd8b --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/htdocs/logout/index.html @@ -0,0 +1,44 @@ + + + + + + + + + +Sign out + + +

Sign out

+
+ +
+ + +
+ + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/proxy-conf b/sca-cpp/branches/lightweight-sca/samples/store-cluster/proxy-conf new file mode 100755 index 0000000000..c43feff551 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/proxy-conf @@ -0,0 +1,35 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +root=$1 +port=$2 + +set -x + +# Configure a proxy balancer +../../modules/http/httpd-conf $root sca-store.com $port/80 $root/htdocs +../../modules/http/mass-host-conf $root $root/domains htdocs +../../modules/http/proxy-conf $root +../../modules/http/httpd-event-conf $root + +# Aggregate proxy balancer logs +category=`basename $root` +../../components/log/scribe-tail-start $category $root/logs/error_log +../../components/log/scribe-tail-start $category $root/logs/access_log + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/proxy-ssl-conf b/sca-cpp/branches/lightweight-sca/samples/store-cluster/proxy-ssl-conf new file mode 100755 index 0000000000..e4ddbb0c4b --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/proxy-ssl-conf @@ -0,0 +1,41 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +root=$1 +port=$2 +sslport=$3 + +set -x + +# Configure an SSL-enabled proxy balancer +../../modules/http/httpd-conf $root sca-store.com $port $root/htdocs +../../modules/http/mass-host-conf $root $root/domains htdocs +../../modules/http/proxy-conf $root +../../modules/http/httpd-event-conf $root +tar -C tmp/ssl -c `../../modules/http/ssl-cert-find tmp/ssl` | tar -C $root -x +../../modules/http/httpd-ssl-conf $root $sslport +../../modules/http/httpd-tunnel-ssl-conf $root +../../modules/http/mass-host-ssl-conf $root +../../modules/http/proxy-ssl-conf $root + +# Aggregate proxy balancer logs +category=`basename $root` +../../components/log/scribe-tail-start $category $root/logs/error_log +../../components/log/scribe-tail-start $category $root/logs/access_log + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/server-conf b/sca-cpp/branches/lightweight-sca/samples/store-cluster/server-conf new file mode 100755 index 0000000000..089e1842db --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/server-conf @@ -0,0 +1,47 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +root=$1 +port=$2 + +set -x + +# Configure an app server +../../modules/http/httpd-conf $root sca-store.com $port/80 htdocs +../../modules/http/httpd-event-conf $root +../../modules/http/mass-host-conf $root domains htdocs +../../modules/server/server-conf $root +../../modules/python/python-conf $root +cat >>$root/conf/httpd.conf <>$root/conf/httpd.conf </dev/null >tmp/index.html +diff tmp/index.html htdocs/domains/joe/index.html +rc=$? + +# Test Catalog +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://joe.example.com/references/Store/catalog -X POST -H "Content-type: application/json-rpc" --data @../store-cpp/htdocs/test/items-request.txt >tmp/items-result.txt 2>/dev/null + diff tmp/items-result.txt ../store-cpp/htdocs/test/items-result.txt + rc=$? +fi + +# Test Shopping Cart +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://joe.example.com/references/Store/shoppingCart -X POST -H "Content-type: application/atom+xml" --data @../store-cpp/htdocs/test/shopping-cart-entry.xml 2>/dev/null + rc=$? +fi +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://joe.example.com/references/Store/shoppingCart >tmp/shopping-cart-feed.xml 2>/dev/null + grep "3.55" tmp/shopping-cart-feed.xml >/dev/null + rc=$? +fi + +# Cleanup +./stop +sleep 2 + +if [ "$rc" = "0" ]; then + echo "OK" +fi +exit $rc diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/shared/shared.composite b/sca-cpp/branches/lightweight-sca/samples/store-cluster/shared/shared.composite new file mode 100644 index 0000000000..d11d31b9ea --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/shared/shared.composite @@ -0,0 +1,63 @@ + + + + + + + + + + + + + + + + + + + + + localhost:11211 + localhost:11212 + localhost:11213 + + + + + host=localhost port=6432 dbname=db + store + + + + + + + + host=localhost port=6433 dbname=db + store + + + + + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/sqldb-master-conf b/sca-cpp/branches/lightweight-sca/samples/store-cluster/sqldb-master-conf new file mode 100755 index 0000000000..83f78be999 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/sqldb-master-conf @@ -0,0 +1,47 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +root=$1 +port=$2 +httpport=$3 + +set -x + +# Aggregate database server logs +category=`basename $root` +../../components/log/scribe-tail-start $category "sqldb" $root/logs/postgresql +../../components/log/scribe-tail-start $category $root/logs/error_log +../../components/log/scribe-tail-start $category $root/logs/access_log + +# Configure a database backup HTTP server +../../modules/http/httpd-conf $root localhost $httpport $root/htdocs + +# Configure a database server +if [ ! -f $root/sqldb/data/postgresql.conf ]; then + create="true" +else + create="false" +fi +../../components/sqldb/pgsql-conf $root $port +if [ "$create" = "true" ]; then + ../../components/sqldb/pgsql-start $root + ../../components/sqldb/pgsql localhost $port "create table store(key text, value text);" 1>>$root/logs/postgresql 2>&1 + ../../components/sqldb/pgsql-stop $root +fi + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/sqldb-standby-conf b/sca-cpp/branches/lightweight-sca/samples/store-cluster/sqldb-standby-conf new file mode 100755 index 0000000000..4998ead4b4 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/sqldb-standby-conf @@ -0,0 +1,40 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +root=$1 +port=$2 +httpport=$3 +mhost=$4 +mport=$5 +mhttpport=$6 + +set -x + +# Aggregate database server logs +category=`basename $root` +../../components/log/scribe-tail-start $category "sqldb" $root/logs/postgresql +../../components/log/scribe-tail-start $category $root/logs/error_log +../../components/log/scribe-tail-start $category $root/logs/access_log + +# Configure a database backup HTTP server +../../modules/http/httpd-conf $root localhost $httpport $root/htdocs + +# Configure a standby database server +../../components/sqldb/pgsql-standby-conf $root $port $mhost $mport $mhttpport + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/ssl-start b/sca-cpp/branches/lightweight-sca/samples/store-cluster/ssl-start new file mode 100755 index 0000000000..04aa267d5e --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/ssl-start @@ -0,0 +1,121 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +set -x + +# Redirect traffic from ports 80, 443 and 444 to proxy1 +sudo ../../ubuntu/ip-redirect-all 80 8090 +sudo ../../ubuntu/ip-redirect-all 443 8091 +sudo ../../ubuntu/ip-redirect-all 444 8092 + +# Redirect traffic from ports 80, 443 and 444 to proxy2 +#sudo ../../ubuntu/ip-redirect-all 80 8093 +#sudo ../../ubuntu/ip-redirect-all 443 8094 +#sudo ../../ubuntu/ip-redirect-all 444 8095 + +# Redirect traffic from ports 119 and 563 to tunnel +sudo ../../ubuntu/ip-redirect-all 119 8119 +sudo ../../ubuntu/ip-redirect-all 563 8563 + +# Generate SSL certificates +../../modules/http/ssl-ca-conf tmp/ssl example.com +../../modules/http/ssl-cert-conf tmp/ssl localhost server +../../modules/http/ssl-cert-conf tmp/ssl *.example.com vhost +../../modules/http/ssl-cert-conf tmp/ssl example.com proxy +../../modules/http/ssl-cert-conf tmp/ssl localhost tunnel + +# Start an SSL tunnel +./tunnel-ssl-conf tmp/tunnel 8119/119 8563/563 +../../modules/http/httpd-start tmp/tunnel +sleep 1 + +# Start scribe logging +../../modules/http/tunnel-ssl-conf tmp/tunnel 1465 localhost 563 1463 +../../modules/http/httpd-restart tmp/tunnel +../../components/log/scribed-central-conf tmp/monitor +../../components/log/scribed-client-conf tmp/monitor localhost 1465 +../../components/log/scribed-central-start tmp/monitor +../../components/log/scribed-client-start tmp/monitor +sleep 1 + +# Start three memcached servers +../../modules/http/tunnel-ssl-conf tmp/tunnel 11211 localhost 563 11411 +../../components/cache/memcached-start tmp 127.0.0.1:11411 +../../modules/http/tunnel-ssl-conf tmp/tunnel 11212 localhost 563 11412 +../../components/cache/memcached-start tmp 127.0.0.1:11412 +../../modules/http/tunnel-ssl-conf tmp/tunnel 11213 localhost 563 11413 +../../components/cache/memcached-start tmp 127.0.0.1:11413 +../../modules/http/httpd-restart tmp/tunnel +sleep 1 + +# Start a master and two hot standby databases +../../modules/http/tunnel-ssl-conf tmp/tunnel 5432 localhost 563 5532 +../../modules/http/tunnel-ssl-conf tmp/tunnel 8502 localhost 563 8602 +../../modules/http/httpd-restart tmp/tunnel +./sqldb-master-conf tmp/sqldb1 127.0.0.1:5532 127.0.0.1:8602 +../../components/sqldb/pgsql-start tmp/sqldb1 +../../modules/http/httpd-start tmp/sqldb1 +sleep 1 + +../../modules/http/tunnel-ssl-conf tmp/tunnel 5433 localhost 563 5533 +../../modules/http/tunnel-ssl-conf tmp/tunnel 8503 localhost 563 8603 +../../modules/http/httpd-restart tmp/tunnel +./sqldb-standby-conf tmp/sqldb2 127.0.0.1:5533 127.0.0.1:8603 localhost 5432 8502 +../../components/sqldb/pgsql-start tmp/sqldb2 +../../modules/http/httpd-start tmp/sqldb2 + +../../modules/http/tunnel-ssl-conf tmp/tunnel 5434 localhost 563 5534 +../../modules/http/tunnel-ssl-conf tmp/tunnel 8504 localhost 563 8604 +../../modules/http/httpd-restart tmp/tunnel +./sqldb-standby-conf tmp/sqldb3 127.0.0.1:5534 127.0.0.1:8604 localhost 5432 8502 +../../components/sqldb/pgsql-start tmp/sqldb3 +../../modules/http/httpd-start tmp/sqldb3 + +# Start three app servers +./server-ssl-conf tmp/server1 8101/80 8441/443 +../../modules/http/httpd-start tmp/server1 +sleep 1 + +./server-ssl-conf tmp/server2 8102/80 8442/443 +../../modules/http/httpd-start tmp/server2 +sleep 1 + +./server-ssl-conf tmp/server3 8103/80 8443/443 +../../modules/http/httpd-start tmp/server3 +sleep 1 + +# Start two proxy balancers +./proxy-ssl-conf tmp/proxy1 8090/80 8091/443 +../../modules/http/proxy-member-conf tmp/proxy1 localhost 8101 +../../modules/http/proxy-ssl-member-conf tmp/proxy1 localhost 8441 +../../modules/http/proxy-member-conf tmp/proxy1 localhost 8102 +../../modules/http/proxy-ssl-member-conf tmp/proxy1 localhost 8442 +../../modules/http/proxy-member-conf tmp/proxy1 localhost 8103 +../../modules/http/proxy-ssl-member-conf tmp/proxy1 localhost 8443 +../../modules/http/httpd-start tmp/proxy1 + +./proxy-ssl-conf tmp/proxy2 8093/80 8094/443 +../../modules/http/proxy-member-conf tmp/proxy2 localhost 8101 +../../modules/http/proxy-ssl-member-conf tmp/proxy2 localhost 8441 +../../modules/http/proxy-member-conf tmp/proxy2 localhost 8102 +../../modules/http/proxy-ssl-member-conf tmp/proxy2 localhost 8442 +../../modules/http/proxy-member-conf tmp/proxy2 localhost 8103 +../../modules/http/proxy-ssl-member-conf tmp/proxy2 localhost 8443 +../../modules/http/httpd-start tmp/proxy2 + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/ssl-stop b/sca-cpp/branches/lightweight-sca/samples/store-cluster/ssl-stop new file mode 100755 index 0000000000..37addf8094 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/ssl-stop @@ -0,0 +1,44 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +set -x + +../../modules/http/httpd-stop tmp/server1 +../../modules/http/httpd-stop tmp/server2 +../../modules/http/httpd-stop tmp/server3 + +../../modules/http/httpd-stop tmp/proxy1 +../../modules/http/httpd-stop tmp/proxy2 + +../../components/cache/memcached-stop tmp 127.0.0.1:11411 +../../components/cache/memcached-stop tmp 127.0.0.1:11412 +../../components/cache/memcached-stop tmp 127.0.0.1:11413 + +../../components/sqldb/pgsql-stop tmp/sqldb3 +../../modules/http/httpd-stop tmp/sqldb3 +../../components/sqldb/pgsql-stop tmp/sqldb2 +../../modules/http/httpd-stop tmp/sqldb2 +../../components/sqldb/pgsql-stop tmp/sqldb1 +../../modules/http/httpd-stop tmp/sqldb1 + +../../modules/http/httpd-stop tmp/tunnel + +../../components/log/scribed-client-stop tmp/monitor +../../components/log/scribed-central-stop tmp/monitor +../../components/log/scribe-tail-stop tmp diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/start b/sca-cpp/branches/lightweight-sca/samples/store-cluster/start new file mode 100755 index 0000000000..dcc7e1e7a7 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/start @@ -0,0 +1,80 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +set -x + +# Redirect traffic from port 80 to proxy1 +sudo ../../ubuntu/ip-redirect-all 80 8090 + +# Redirect traffic from port 80 to proxy2 +#sudo ../../ubuntu/ip-redirect-all 80 8091 + +# Start scribe logging +rm -rf tmp +../../components/log/scribed-central-conf tmp/monitor +../../components/log/scribed-client-conf tmp/monitor localhost +../../components/log/scribed-central-start tmp/monitor +../../components/log/scribed-client-start tmp/monitor +sleep 1 + +# Start three memcached servers +../../components/cache/memcached-start tmp 11211 +../../components/cache/memcached-start tmp 11212 +../../components/cache/memcached-start tmp 11213 + +# Start a master and two hot standby databases +./sqldb-master-conf tmp/sqldb1 5432 8502 +../../components/sqldb/pgsql-start tmp/sqldb1 +../../modules/http/httpd-start tmp/sqldb1 +sleep 1 + +./sqldb-standby-conf tmp/sqldb2 5433 8503 localhost 5432 8502 +../../components/sqldb/pgsql-start tmp/sqldb2 +../../modules/http/httpd-start tmp/sqldb2 + +./sqldb-standby-conf tmp/sqldb3 5434 8504 localhost 5432 8502 +../../components/sqldb/pgsql-start tmp/sqldb3 +../../modules/http/httpd-start tmp/sqldb3 + +# Start three app servers +./server-conf tmp/server1 8101 +../../modules/http/httpd-start tmp/server1 +sleep 1 + +./server-conf tmp/server2 8102 +../../modules/http/httpd-start tmp/server2 +sleep 1 + +./server-conf tmp/server3 8103 +../../modules/http/httpd-start tmp/server3 +sleep 1 + +# Start two proxy balancers +./proxy-conf tmp/proxy1 8090 +../../modules/http/proxy-member-conf tmp/proxy1 localhost 8101 +../../modules/http/proxy-member-conf tmp/proxy1 localhost 8102 +../../modules/http/proxy-member-conf tmp/proxy1 localhost 8103 +../../modules/http/httpd-start tmp/proxy1 + +./proxy-conf tmp/proxy2 8091 +../../modules/http/proxy-member-conf tmp/proxy2 localhost 8101 +../../modules/http/proxy-member-conf tmp/proxy2 localhost 8102 +../../modules/http/proxy-member-conf tmp/proxy2 localhost 8103 +../../modules/http/httpd-start tmp/proxy2 + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/stop b/sca-cpp/branches/lightweight-sca/samples/store-cluster/stop new file mode 100755 index 0000000000..fb6c6489fc --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/stop @@ -0,0 +1,42 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +set -x + +../../modules/http/httpd-stop tmp/server1 +../../modules/http/httpd-stop tmp/server2 +../../modules/http/httpd-stop tmp/server3 + +../../modules/http/httpd-stop tmp/proxy1 +../../modules/http/httpd-stop tmp/proxy2 + +../../components/cache/memcached-stop tmp 11211 +../../components/cache/memcached-stop tmp 11212 +../../components/cache/memcached-stop tmp 11213 + +../../components/sqldb/pgsql-stop tmp/sqldb3 +../../modules/http/httpd-stop tmp/sqldb3 +../../components/sqldb/pgsql-stop tmp/sqldb2 +../../modules/http/httpd-stop tmp/sqldb2 +../../components/sqldb/pgsql-stop tmp/sqldb1 +../../modules/http/httpd-stop tmp/sqldb1 + +../../components/log/scribed-client-stop tmp/monitor +../../components/log/scribed-central-stop tmp/monitor +../../components/log/scribe-tail-stop tmp diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cluster/tunnel-ssl-conf b/sca-cpp/branches/lightweight-sca/samples/store-cluster/tunnel-ssl-conf new file mode 100755 index 0000000000..f798fdab0b --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cluster/tunnel-ssl-conf @@ -0,0 +1,33 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +root=$1 +port=$2 +sslport=$3 + +set -x + +# Configure an SSL-enabled tunnel server +../../modules/http/httpd-conf $root sca-store.com $port $root/htdocs +../../modules/http/httpd-event-conf $root +tar -C tmp/ssl -c `../../modules/http/ssl-cert-find tmp/ssl` | tar -C $root -x +../../modules/http/httpd-ssl-conf $root $sslport +../../modules/http/httpd-tunnel-ssl-conf $root +../../modules/http/cert-auth-conf $root + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-constdb/Makefile.am b/sca-cpp/branches/lightweight-sca/samples/store-constdb/Makefile.am new file mode 100644 index 0000000000..d2783f3f3b --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-constdb/Makefile.am @@ -0,0 +1,25 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +dist_sample_SCRIPTS = start stop ssl-start +sampledir = $(prefix)/samples/store-constdb + +nobase_dist_sample_DATA = currency-converter.scm fruits-catalog.scm shopping-cart.scm store.scm store.composite htdocs/*.html + +dist_noinst_SCRIPTS = server-test +TESTS = server-test + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-constdb/currency-converter.scm b/sca-cpp/branches/lightweight-sca/samples/store-constdb/currency-converter.scm new file mode 100644 index 0000000000..fc506c3d73 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-constdb/currency-converter.scm @@ -0,0 +1,27 @@ +; Licensed to the Apache Software Foundation (ASF) under one +; or more contributor license agreements. See the NOTICE file +; distributed with this work for additional information +; regarding copyright ownership. The ASF licenses this file +; to you under the Apache License, Version 2.0 (the +; "License"); you may not use this file except in compliance +; with the License. You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, +; software distributed under the License is distributed on an +; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +; KIND, either express or implied. See the License for the +; specific language governing permissions and limitations +; under the License. + +; Currency converter implementation + +(define (convert from to amount) + (if (equal? to "EUR") (* amount 0.70) amount) +) + +(define (symbol currency) + (if (equal? currency "EUR") "E" "$") +) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-constdb/fruits-catalog.scm b/sca-cpp/branches/lightweight-sca/samples/store-constdb/fruits-catalog.scm new file mode 100644 index 0000000000..d55394b96a --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-constdb/fruits-catalog.scm @@ -0,0 +1,30 @@ +; Licensed to the Apache Software Foundation (ASF) under one +; or more contributor license agreements. See the NOTICE file +; distributed with this work for additional information +; regarding copyright ownership. The ASF licenses this file +; to you under the Apache License, Version 2.0 (the +; "License"); you may not use this file except in compliance +; with the License. You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, +; software distributed under the License is distributed on an +; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +; KIND, either express or implied. See the License for the +; specific language governing permissions and limitations +; under the License. + +; Catalog implementation + +(define (items converter currencyCode) + (define code (currencyCode)) + (define (convert price) (converter "convert" "USD" code price)) + (define symbol (converter "symbol" code)) + (list + (list (list 'name "Apple") (list 'currencyCode code) (list 'currencySymbol symbol) (list 'price (convert 2.99))) + (list (list 'name "Orange") (list 'currencyCode code) (list 'currencySymbol symbol) (list 'price (convert 3.55))) + (list (list 'name "Pear") (list 'currencyCode code) (list 'currencySymbol symbol) (list 'price (convert 1.55))) + ) +) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-constdb/htdocs/index.html b/sca-cpp/branches/lightweight-sca/samples/store-constdb/htdocs/index.html new file mode 100644 index 0000000000..0698a32cc5 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-constdb/htdocs/index.html @@ -0,0 +1,156 @@ + + + + + + + +Store + + + + + + + +

Store

+
+
+

Catalog

+
+
+
+ +
+
+ +

Your Shopping Cart

+
+
+
+
+
+ + +(feed) +
+
+ + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-constdb/server-test b/sca-cpp/branches/lightweight-sca/samples/store-constdb/server-test new file mode 100755 index 0000000000..fb629a6814 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-constdb/server-test @@ -0,0 +1,58 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +echo "Testing..." +here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here` +curl_prefix=`cat $here/../../modules/http/curl.prefix` + +# Setup +./start +sleep 2 + +# Test HTTP GET +$curl_prefix/bin/curl http://localhost:8090/ 2>/dev/null >tmp/index.html +diff tmp/index.html htdocs/index.html +rc=$? + +# Test Catalog +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://localhost:8090/references/Store/catalog -X POST -H "Content-type: application/json-rpc" --data @../store-cpp/htdocs/test/items-request.txt >tmp/items-result.txt 2>/dev/null + diff tmp/items-result.txt ../store-cpp/htdocs/test/items-result.txt + rc=$? +fi + +# Test Shopping Cart +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://localhost:8090/references/Store/shoppingCart -X POST -H "Content-type: application/atom+xml" --data @../store-cpp/htdocs/test/shopping-cart-entry.xml 2>/dev/null + rc=$? +fi +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://localhost:8090/references/Store/shoppingCart >tmp/shopping-cart-feed.xml 2>/dev/null + grep "3.55" tmp/shopping-cart-feed.xml >/dev/null + rc=$? +fi + +# Cleanup +./stop +sleep 2 + +if [ "$rc" = "0" ]; then + echo "OK" +fi +exit $rc diff --git a/sca-cpp/branches/lightweight-sca/samples/store-constdb/shopping-cart.scm b/sca-cpp/branches/lightweight-sca/samples/store-constdb/shopping-cart.scm new file mode 100644 index 0000000000..e653f1e33c --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-constdb/shopping-cart.scm @@ -0,0 +1,82 @@ +; Licensed to the Apache Software Foundation (ASF) under one +; or more contributor license agreements. See the NOTICE file +; distributed with this work for additional information +; regarding copyright ownership. The ASF licenses this file +; to you under the Apache License, Version 2.0 (the +; "License"); you may not use this file except in compliance +; with the License. You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, +; software distributed under the License is distributed on an +; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +; KIND, either express or implied. See the License for the +; specific language governing permissions and limitations +; under the License. + +; Shopping cart implementation + +(define cartId "1234") + +; Get the shopping cart from the cache +; Return an empty cart if not found +(define (getcart id cache) + (define cart (cache "get" (list id))) + (if (nul cart) + (list) + cart) +) + +; Post a new item to the cart, create a new cart if necessary +(define (post collection item cache) + (define id (uuid)) + (define newItem (list 'entry (cadr (car item)) (list 'id id) (cadddr (car item)))) + (define cart (cons newItem (getcart cartId cache))) + (cache "put" (list cartId) cart) + (list id) +) + +; Find an item in the cart +(define (find id cart) + (if (nul cart) + (list (list 'entry (list 'title "Item") (list 'id "0"))) + (if (= id (cadr (caddr (car cart)))) + (list (car cart)) + (find id (cdr cart)))) +) + +; Get items from the cart +(define (get id cache) + (if (nul id) + (list (append (list 'feed (list 'title "Your Cart") (list 'id cartId)) (getcart cartId cache))) + (find (car id) (getcart cartId cache)) + ) +) + +; Delete items from the cart +(define (delete id cache) + (if (nul id) + (cache "delete" (list cartId)) + true + ) +) + +; Return the price of an item +(define (price item) + (cadr (assoc 'price (cadr (cadddr item)))) +) + +; Sum the prices of a list of items +(define (sum items) + (if (nul items) + 0 + (+ (price (car items)) (sum (cdr items)))) +) + +; Return the total price of the items in the cart +(define (total cache) + (define cart (getcart cartId cache)) + (sum cart) +) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-constdb/ssl-start b/sca-cpp/branches/lightweight-sca/samples/store-constdb/ssl-start new file mode 100755 index 0000000000..047ec974cb --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-constdb/ssl-start @@ -0,0 +1,36 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +../../modules/http/ssl-ca-conf tmp localhost +../../modules/http/ssl-cert-conf tmp localhost +../../modules/http/httpd-conf tmp localhost 8090 htdocs +../../modules/http/httpd-ssl-conf tmp 8453 +../../modules/http/basic-auth-conf tmp +../../modules/http/passwd-auth-conf tmp foo foo +../../modules/server/server-conf tmp +../../modules/server/scheme-conf tmp +cat >>tmp/conf/httpd.conf <>tmp/conf/httpd.conf < + + + + + + + + + + + + + + + + USD + + + + + + + + + + + + + + + + + + + + + + + + + + + tmp/store.cdb + + + + + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-constdb/store.scm b/sca-cpp/branches/lightweight-sca/samples/store-constdb/store.scm new file mode 100644 index 0000000000..f54257343e --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-constdb/store.scm @@ -0,0 +1,47 @@ +; Licensed to the Apache Software Foundation (ASF) under one +; or more contributor license agreements. See the NOTICE file +; distributed with this work for additional information +; regarding copyright ownership. The ASF licenses this file +; to you under the Apache License, Version 2.0 (the +; "License"); you may not use this file except in compliance +; with the License. You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, +; software distributed under the License is distributed on an +; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +; KIND, either express or implied. See the License for the +; specific language governing permissions and limitations +; under the License. + +; Store implementation + +(define (post item catalog shoppingCart shoppingTotal) + (shoppingCart "post" item) +) + +(define (getall catalog shoppingCart shoppingTotal) + (shoppingCart "getall") +) + +(define (get id catalog shoppingCart shoppingTotal) + (shoppingCart "get" id) +) + +(define (items catalog shoppingCart shoppingTotal) + (catalog "items") +) + +(define (total catalog shoppingCart shoppingTotal) + (shoppingCart "total") +) + +(define (deleteall catalog shoppingCart shoppingTotal) + (shoppingCart "deleteall") +) + +(define (delete id catalog shoppingCart shoppingTotal) + (shoppingCart "delete" id) +) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cpp/Makefile.am b/sca-cpp/branches/lightweight-sca/samples/store-cpp/Makefile.am new file mode 100644 index 0000000000..3f9d8e87eb --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cpp/Makefile.am @@ -0,0 +1,40 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + + +dist_sample_SCRIPTS = start stop ssl-start +sampledir = $(prefix)/samples/store-cpp + +nobase_dist_sample_DATA = currency-converter.cpp fruits-catalog.cpp shopping-cart.cpp store.composite htdocs/*.html + +sample_LTLIBRARIES = libcurrency-converter.la libfruits-catalog.la libshopping-cart.la +noinst_DATA = libcurrency-converter${libsuffix} libfruits-catalog${libsuffix} libshopping-cart${libsuffix} + +libcurrency_converter_la_SOURCES = currency-converter.cpp +libcurrency-converter${libsuffix}: + ln -s .libs/libcurrency-converter${libsuffix} + +libfruits_catalog_la_SOURCES = fruits-catalog.cpp +libfruits-catalog${libsuffix}: + ln -s .libs/libfruits-catalog${libsuffix} + +libshopping_cart_la_SOURCES = shopping-cart.cpp +libshopping-cart${libsuffix}: + ln -s .libs/libshopping-cart${libsuffix} + +dist_noinst_SCRIPTS = server-test +TESTS = server-test diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cpp/currency-converter.cpp b/sca-cpp/branches/lightweight-sca/samples/store-cpp/currency-converter.cpp new file mode 100644 index 0000000000..5f0702490a --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cpp/currency-converter.cpp @@ -0,0 +1,67 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +/** + * Currency converter component implementation. + */ + +#include "string.hpp" +#include "function.hpp" +#include "list.hpp" +#include "value.hpp" +#include "monad.hpp" + +namespace tuscany { +namespace store { + +/** + * Convert an amount from USD to a currency. + */ +const failable convert(unused const value& from, const value& to, const value& amount) { + if (to == string("EUR")) + return value(0.70 * (double)amount); + return amount; +} + +/** + * Return a currency symbol. + */ +const failable symbol(const value& currency) { + if (currency == string("EUR")) + return value(string("E")); + return value(string("$")); +} + +} +} + +extern "C" { + +const tuscany::value apply(const tuscany::list& params) { + const tuscany::value func(car(params)); + if (func == "convert") + return tuscany::store::convert(cadr(params), caddr(params), cadddr(params)); + if (func == "symbol") + return tuscany::store::symbol(cadr(params)); + return tuscany::mkfailure(); +} + +} diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cpp/fruits-catalog.cpp b/sca-cpp/branches/lightweight-sca/samples/store-cpp/fruits-catalog.cpp new file mode 100644 index 0000000000..9907650316 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cpp/fruits-catalog.cpp @@ -0,0 +1,76 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +/** + * Catalog component implementation. + */ + +#include "string.hpp" +#include "function.hpp" +#include "list.hpp" +#include "value.hpp" +#include "monad.hpp" + +namespace tuscany { +namespace store { + +/** + * Returns the catalog. + */ +struct convert { + const lambda&)> converter; + const string currency; + convert(const lambda&)>& converter, const string& currency) : converter(converter), currency(currency) { + } + const value operator()(const value& price) const { + return converter(mklist("convert", string("USD"), currency, price)); + } +}; + +const list mkfruit(const string& name, const string& code, const string& symbol, const double price) { + return list() + + mklist("name", name) + mklist("currencyCode", code) + mklist("currencySymbol", symbol) + mklist("price", price); +} + +const failable items(const lambda&)>& converter, const lambda&)>& currencyCode) { + const string currency(currencyCode(list())); + const string symbol(converter(mklist("symbol", currency))); + const lambda conv(convert(converter, currency)); + + return value(list() + + mkfruit("Apple", currency, symbol, conv(2.99)) + + mkfruit("Orange", currency, symbol, conv(3.55)) + + mkfruit("Pear", currency, symbol, conv(1.55))); +} + +} +} + +extern "C" { + +const tuscany::value apply(const tuscany::list& params) { + const tuscany::value func(car(params)); + if (func == "items") + return tuscany::store::items(cadr(params), caddr(params)); + return tuscany::mkfailure(); +} + +} diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cpp/htdocs/index.html b/sca-cpp/branches/lightweight-sca/samples/store-cpp/htdocs/index.html new file mode 100644 index 0000000000..0698a32cc5 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cpp/htdocs/index.html @@ -0,0 +1,156 @@ + + + + + + + +Store + + + + + + + +

Store

+
+
+

Catalog

+
+
+
+ +
+
+ +

Your Shopping Cart

+
+
+
+
+
+ + +(feed) +
+
+ + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cpp/htdocs/test/items-request.txt b/sca-cpp/branches/lightweight-sca/samples/store-cpp/htdocs/test/items-request.txt new file mode 100644 index 0000000000..09a7f8377b --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cpp/htdocs/test/items-request.txt @@ -0,0 +1,6 @@ +{ + "id": 1, + "method": "items", + "params": [ + ] +} diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cpp/htdocs/test/items-result.txt b/sca-cpp/branches/lightweight-sca/samples/store-cpp/htdocs/test/items-result.txt new file mode 100644 index 0000000000..0b456ea9d0 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cpp/htdocs/test/items-result.txt @@ -0,0 +1,23 @@ +{ + "id": 1, + "result": [ + { + "name": "Apple", + "currencyCode": "USD", + "currencySymbol": "$", + "price": 2.99 + }, + { + "name": "Orange", + "currencyCode": "USD", + "currencySymbol": "$", + "price": 3.55 + }, + { + "name": "Pear", + "currencyCode": "USD", + "currencySymbol": "$", + "price": 1.55 + } + ] +} \ No newline at end of file diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cpp/htdocs/test/shopping-cart-entry.xml b/sca-cpp/branches/lightweight-sca/samples/store-cpp/htdocs/test/shopping-cart-entry.xml new file mode 100644 index 0000000000..0d6e5b520a --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cpp/htdocs/test/shopping-cart-entry.xml @@ -0,0 +1,2 @@ + +ItemOrangeUSD$3.55 diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cpp/server-test b/sca-cpp/branches/lightweight-sca/samples/store-cpp/server-test new file mode 100755 index 0000000000..e621803f8d --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cpp/server-test @@ -0,0 +1,58 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +echo "Testing..." +here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here` +curl_prefix=`cat $here/../../modules/http/curl.prefix` + +# Setup +./start +sleep 2 + +# Test HTTP GET +$curl_prefix/bin/curl http://localhost:8090/ 2>/dev/null >tmp/index.html +diff tmp/index.html htdocs/index.html +rc=$? + +# Test Catalog +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://localhost:8090/references/Store/catalog -X POST -H "Content-type: application/json-rpc" --data @htdocs/test/items-request.txt >tmp/items-result.txt 2>/dev/null + diff tmp/items-result.txt htdocs/test/items-result.txt + rc=$? +fi + +# Test Shopping Cart +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://localhost:8090/references/Store/shoppingCart -X POST -H "Content-type: application/atom+xml" --data @htdocs/test/shopping-cart-entry.xml 2>/dev/null + rc=$? +fi +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://localhost:8090/references/Store/shoppingCart >tmp/shopping-cart-feed.xml 2>/dev/null + grep "3.55" tmp/shopping-cart-feed.xml >/dev/null + rc=$? +fi + +# Cleanup +./stop +sleep 2 + +if [ "$rc" = "0" ]; then + echo "OK" +fi +exit $rc diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cpp/shopping-cart.cpp b/sca-cpp/branches/lightweight-sca/samples/store-cpp/shopping-cart.cpp new file mode 100644 index 0000000000..2771d7cd9c --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cpp/shopping-cart.cpp @@ -0,0 +1,135 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +/** + * Shopping cart component implementation. + */ + +#include "string.hpp" +#include "function.hpp" +#include "list.hpp" +#include "value.hpp" +#include "monad.hpp" + +namespace tuscany { +namespace store { + +const string cartId("1234"); + +/** + * Get the shopping cart from the cache. Return an empty + * cart if not found. + */ +const list getcart(const value& id, const lambda&)>& cache) { + const value cart = cache(mklist("get", mklist(id))); + cerr << "cart value: " << cart << "\n"; + const failable fcart = cart; + cerr << "cart fvalue: " << fcart << "\n"; + cerr << "cart content: " << content(fcart) << "\n"; + cerr << "cart reason: " << reason(fcart) << "\n"; + if (isNil(cart)) + return value(list()); + return (list)cart; +} + +/** + * Post a new item to the cart. Create a new cart if necessary. + */ +const failable post(unused const list& collection, const value& item, const lambda&)>& cache) { + const value id(mkuuid()); + const list newItem(mklist("entry", cadr(car(item)), mklist("id", id), cadddr(car(item)))); + const list cart(cons(newItem, getcart(cartId, cache))); + cache(mklist("put", mklist(cartId), cart)); + return value(mklist(id)); +} + +/** + * Find an item in the cart. + */ +const value find(const value& id, const list& cart) { + if (isNil(cart)) + return mklist(mklist("entry", mklist("title", string("Item")), mklist("id", "0"))); + if (id == cadr(caddr(car(cart)))) + return mklist(car(cart)); + return find(id, cdr(cart)); +} + +/** + * Return items from the cart. + */ +const failable get(const list& id, const lambda&)>& cache) { + if (isNil(id)) + return value(mklist(append(mklist("feed", mklist("title", string("Your Cart")), mklist("id", cartId)), getcart(cartId, cache)))); + return find(car(id), getcart(cartId, cache)); +} + +/** + * Delete items from the cart. + */ +const failable del(const list& id, unused const lambda&)>& cache) { + if (isNil(id)) + return cache(mklist("delete", mklist(cartId))); + return value(true); +} + +/** + * Return the price of an item. + */ +const double price(const list& item) { + return cadr(assoc("price", cdr(cadr(cadddr(item))))); +} + +/** + * Sum the prices of a list of items. + */ +const double sum(const list& items) { + if (isNil(items)) + return 0; + return price(car(items)) + sum(cdr(items)); +} + +/** + * Return the total price of the items in the cart. + */ +const failable total(const lambda&)>& cache) { + const list cart(getcart(cartId, cache)); + return value(sum(cart)); +} + +} +} + +extern "C" { + +const tuscany::value apply(const tuscany::list& params) { + const tuscany::value func(car(params)); + if (func == "post") + return tuscany::store::post(cadr(params), caddr(params), cadddr(params)); + if (func == "get") + return tuscany::store::get(cadr(params), caddr(params)); + if (func == "delete") + return tuscany::store::del(cadr(params), caddr(params)); + if (func == "total") + return tuscany::store::total(cadr(params)); + return tuscany::mkfailure(); +} + +} diff --git a/sca-cpp/branches/lightweight-sca/samples/store-cpp/ssl-start b/sca-cpp/branches/lightweight-sca/samples/store-cpp/ssl-start new file mode 100755 index 0000000000..3a96fe950c --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-cpp/ssl-start @@ -0,0 +1,36 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +../../modules/http/ssl-ca-conf tmp localhost +../../modules/http/ssl-cert-conf tmp localhost +../../modules/http/httpd-conf tmp localhost 8090 htdocs +../../modules/http/httpd-ssl-conf tmp 8453 +../../modules/http/basic-auth-conf tmp +../../modules/http/passwd-auth-conf tmp foo foo +../../modules/server/server-conf tmp +../../modules/server/cpp-conf tmp +cat >>tmp/conf/httpd.conf <>tmp/conf/httpd.conf < + + + + + + + + + + + + + + + + USD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost:11211 + + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-gae/Makefile.am b/sca-cpp/branches/lightweight-sca/samples/store-gae/Makefile.am new file mode 100644 index 0000000000..09d5b516cf --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-gae/Makefile.am @@ -0,0 +1,44 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +if WANT_PYTHON +if WANT_GAE + +dist_sample_SCRIPTS = start stop +sampledir = $(prefix)/samples/store-gae + +BUILT_SOURCES = target.stamp +target.stamp: app.yaml *.py *.composite $(top_builddir)/modules/wsgi/*.py htdocs/* $(top_builddir)/modules/js/htdocs/* + mkdir -p target + cp app.yaml *.py *.composite `ls $(top_builddir)/modules/wsgi/*.py | grep -v "\-test"` target + mkdir -p target/htdocs + cp -R htdocs/* target/htdocs + cp -R $(top_builddir)/modules/js/htdocs/* target/htdocs + touch target.stamp + +clean-local: + rm -rf target.stamp target + +nobase_sample_DATA = target/app.yaml target/*.py target/*.composite target/htdocs/*.html target/htdocs/*.js + +EXTRA_DIST = app.yaml *.composite *.py htdocs/*.html + +dist_noinst_SCRIPTS = server-test +TESTS = server-test + +endif +endif diff --git a/sca-cpp/branches/lightweight-sca/samples/store-gae/app.yaml b/sca-cpp/branches/lightweight-sca/samples/store-gae/app.yaml new file mode 100644 index 0000000000..6a4e6a2fab --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-gae/app.yaml @@ -0,0 +1,54 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +application: sca-store +version: 1 +runtime: python +api_version: 1 +skip_files: +- ^(.*/)?app\.yaml +- ^(.*/)?app\.yml +- ^(.*/)?index\.yaml +- ^(.*/)?index\.yml +- ^(.*/)?#.*# +- ^(.*/)?.*~ +- ^(.*/)?.*\.py[co] +- ^(.*/)?.*/RCS/.* +- ^(.*/)?\..* +- ^(.*/)?.*-test$ +- ^(.*/)?.*\.cpp$ +- ^(.*/)?.*\.o$ +- ^(.*/)?core$ +- ^(.*/)?.*\.out$ +- ^(.*/)?.*\.log$ +- ^(.*/)?Makefile.* +- ^(.*/)?tmp/.* +- ^(.*/)?wsgi-start +- ^(.*/)?wsgi-stop + +handlers: +- url: /(.*\.(html|png)) + static_files: htdocs/\1 + upload: htdocs/(.*\.(html|png)) + secure: always + login: required + +- url: /.* + script: composite.py + secure: always + login: required + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-gae/currency-converter.py b/sca-cpp/branches/lightweight-sca/samples/store-gae/currency-converter.py new file mode 100644 index 0000000000..2fded8f616 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-gae/currency-converter.py @@ -0,0 +1,29 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Currency converter implementation + +def convert(fr, to, amount): + if to == "EUR": + return amount * 0.70 + return amount + +def symbol(currency): + if currency == "EUR": + return "E" + return "$" + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-gae/domain-backend.composite b/sca-cpp/branches/lightweight-sca/samples/store-gae/domain-backend.composite new file mode 100644 index 0000000000..13fa8406e2 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-gae/domain-backend.composite @@ -0,0 +1,31 @@ + + + + + + + + + + + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-gae/domain-frontend.composite b/sca-cpp/branches/lightweight-sca/samples/store-gae/domain-frontend.composite new file mode 100644 index 0000000000..181e86c100 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-gae/domain-frontend.composite @@ -0,0 +1,65 @@ + + + + + + + + + + + + + + + + + USD + + + + + + + + + + + + + + + + + + localhost + anonymous@example.com + + + + + + + + + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-gae/domain-single.composite b/sca-cpp/branches/lightweight-sca/samples/store-gae/domain-single.composite new file mode 100644 index 0000000000..79c5aca8e1 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-gae/domain-single.composite @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + USD + + + + + + + + + + + + + + + + localhost + anonymous@example.com + + + + + + + + + + + + + + + + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-gae/domain.composite b/sca-cpp/branches/lightweight-sca/samples/store-gae/domain.composite new file mode 100644 index 0000000000..79c5aca8e1 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-gae/domain.composite @@ -0,0 +1,70 @@ + + + + + + + + + + + + + + + + + USD + + + + + + + + + + + + + + + + localhost + anonymous@example.com + + + + + + + + + + + + + + + + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-gae/fruits-catalog.py b/sca-cpp/branches/lightweight-sca/samples/store-gae/fruits-catalog.py new file mode 100644 index 0000000000..4b2baca2ff --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-gae/fruits-catalog.py @@ -0,0 +1,30 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Catalog implementation + +def items(converter, currencyCode): + code = currencyCode.eval() + def convert(price): + return converter.convert("USD", code, price) + symbol = converter.symbol(code) + return ( + (("'name", "Platano"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(2.99))), + (("'name", "Banana"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(3.55))), + (("'name", "Guanabana"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(1.55))) + ) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-gae/gmemcache.py b/sca-cpp/branches/lightweight-sca/samples/store-gae/gmemcache.py new file mode 100644 index 0000000000..61f1dc3486 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-gae/gmemcache.py @@ -0,0 +1,45 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Google AppEngine Memcached based cache implementation +import uuid +from google.appengine.api import memcache + +# Post a new item to the cache +def post(collection, item): + id = collection + (str(uuid.uuid1()),) + r = memcache.add(repr(id), item, 600) + if r == False: + return None + return id + +# Get items from the cache +def get(id): + item = memcache.get(repr(id)) + return item + +# Update an item in the cache +def put(id, item): + return memcache.set(repr(id), item, 600) + +# Delete items from the cache +def delete(id): + r = memcache.delete(repr(id)) + if r != 2: + return False + return True + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-gae/htdocs/index.html b/sca-cpp/branches/lightweight-sca/samples/store-gae/htdocs/index.html new file mode 100644 index 0000000000..7c9a9e9d6b --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-gae/htdocs/index.html @@ -0,0 +1,175 @@ + + + + + + + +Store + + + + + + + +

Store

+

Welcome to: , you're signed in as:
Sign out

+
+

Catalog

+
+
+
+ +
+
+ +

Your Shopping Cart

+
+
+
+
+
+ + +(feed) +
+
+ + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-gae/htdocs/test/items-result.txt b/sca-cpp/branches/lightweight-sca/samples/store-gae/htdocs/test/items-result.txt new file mode 100644 index 0000000000..bbc07e8917 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-gae/htdocs/test/items-result.txt @@ -0,0 +1 @@ +{"id":1,"result":[{"price":2.9900000000000002,"currencyCode":"USD","name":"Platano","currencySymbol":"$"},{"price":3.5499999999999998,"currencyCode":"USD","name":"Banana","currencySymbol":"$"},{"price":1.55,"currencyCode":"USD","name":"Guanabana","currencySymbol":"$"}]} \ No newline at end of file diff --git a/sca-cpp/branches/lightweight-sca/samples/store-gae/htpasswd.py b/sca-cpp/branches/lightweight-sca/samples/store-gae/htpasswd.py new file mode 100644 index 0000000000..75d94f58b6 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-gae/htpasswd.py @@ -0,0 +1,21 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Configure the user and password used for HTTP basic authentication +user = "foo" +passwd = "foo" + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-gae/server-test b/sca-cpp/branches/lightweight-sca/samples/store-gae/server-test new file mode 100755 index 0000000000..2235811556 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-gae/server-test @@ -0,0 +1,60 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +echo "Testing..." +here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here` +curl_prefix=`cat $here/../../modules/http/curl.prefix` + +# Setup +./start 2>/dev/null +sleep 2 + +# Test HTTP GET (with authentication) +rm -rf tmp +mkdir -p tmp +$curl_prefix/bin/curl -L -c tmp/cookies.txt -b tmp/cookies.txt "http://localhost:8090/_ah/login?email=test@example.com&action=Login&continue=http://localhost:8090/" 2>/dev/null >tmp/index.html +diff tmp/index.html htdocs/index.html +rc=$? + +# Test Catalog +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl -b tmp/cookies.txt http://localhost:8090/references/Store/catalog -X POST -H "Content-type: application/json-rpc" --data @../store-cpp/htdocs/test/items-request.txt >tmp/items-result.txt 2>/dev/null + diff tmp/items-result.txt htdocs/test/items-result.txt + rc=$? +fi + +# Test Shopping Cart +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl -b tmp/cookies.txt http://localhost:8090/references/Store/shoppingCart -X POST -H "Content-type: application/atom+xml" --data @../store-cpp/htdocs/test/shopping-cart-entry.xml 2>/dev/null + rc=$? +fi +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl -b tmp/cookies.txt http://localhost:8090/references/Store/shoppingCart >tmp/shopping-cart-feed.xml 2>/dev/null + grep "3.55" tmp/shopping-cart-feed.xml >/dev/null + rc=$? +fi + +# Cleanup +./stop +sleep 2 + +if [ "$rc" = "0" ]; then + echo "OK" +fi +exit $rc diff --git a/sca-cpp/branches/lightweight-sca/samples/store-gae/shopping-cart.py b/sca-cpp/branches/lightweight-sca/samples/store-gae/shopping-cart.py new file mode 100644 index 0000000000..11a55a552a --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-gae/shopping-cart.py @@ -0,0 +1,82 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Shopping cart implementation +import uuid +import sys + +cartId = "1234" + +# Get the shopping cart from the cache +# Return an empty cart if not found +def getcart(id, cache): + cart = cache.get((id,)) + if cart is None: + return () + return cart + +# Post a new item to the cart, create a new cart if necessary +def post(collection, item, cache, host, email): + id = str(uuid.uuid1()) + cart = (("'entry", item[0][1], ("'id", id), item[0][3]),) + getcart(cartId, cache) + cache.put((cartId,), cart) + return (id,) + +# Find an item in the cart +def find(id, cart): + if cart == (): + return (("'entry", ("'title", "Item"), ("'id", 0)),) + elif id == cart[0][2][1]: + return (cart[0],) + else: + return find(id, cart[1:]) + +# Get items from the cart +def get(id, cache, host, email): + if id == (): + return ((("'feed", ("'title", "Your Cart"), ("'id", cartId)) + getcart(cartId, cache)),) + return find(id[0], getcart(cartId, cache)) + +# Delete items from the cart +def delete(id, cache, host, email): + if id == (): + return cache.delete((cartId,)) + return True + +# Return the price of an item +def price(item): + return float(filter(lambda x: x[0] == "'price", item[3][1][1:])[0][1]) + +# Sum the prices of a list of items +def sum(items): + if items == (): + return 0 + return price(items[0]) + sum(items[1:]) + +# Return the total price of the items in the cart +def total(cache, host, email): + cart = getcart(cartId, cache) + return sum(cart) + +# Return the email of the cart owner +def email(cache, host, email_): + return email_.eval() + +# Return the host that the app is running on +def host(cache, host_, email): + return host_.eval() + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-gae/start b/sca-cpp/branches/lightweight-sca/samples/store-gae/start new file mode 100755 index 0000000000..3c9644e656 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-gae/start @@ -0,0 +1,21 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +../../modules/wsgi/gae-start target 8090 + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-gae/stop b/sca-cpp/branches/lightweight-sca/samples/store-gae/stop new file mode 100755 index 0000000000..7c8a7e5551 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-gae/stop @@ -0,0 +1,21 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +../../modules/wsgi/gae-stop target 8090 + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-gae/store.py b/sca-cpp/branches/lightweight-sca/samples/store-gae/store.py new file mode 100644 index 0000000000..ff82f1d327 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-gae/store.py @@ -0,0 +1,40 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Store implementation + +def post(item, catalog, shoppingCart, shoppingTotal): + return shoppingCart.post(item) + +def getall(catalog, shoppingCart, shoppingTotal): + return shoppingCart.getall() + +def get(id, catalog, shoppingCart, shoppingTotal): + return shoppingCart.get(id) + +def items(catalog, shoppingCart, shoppingTotal): + return catalog.items() + +def total(catalog, shoppingCart, shoppingTotal): + return shoppingCart.total() + +def deleteall(catalog, shoppingCart, shoppingTotal): + return shoppingCart.deleteall() + +def delete(id, catalog, shoppingCart, shoppingTotal): + return shoppingCart.delete(id) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-java/Makefile.am b/sca-cpp/branches/lightweight-sca/samples/store-java/Makefile.am new file mode 100644 index 0000000000..f32ae72812 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-java/Makefile.am @@ -0,0 +1,34 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +JAVAROOT = ${top_builddir}/samples/store-java + +if WANT_JAVA + +dist_sample_SCRIPTS = start stop ssl-start +sampledir=$(prefix)/samples/store-java + +AM_JAVACFLAGS = -cp ${top_builddir}/modules/java/libmod-tuscany-java-${PACKAGE_VERSION}.jar:${JAVAROOT} +dist_sample_JAVA = store/*.java +CLEANFILES = *.stamp store/*.class + +nobase_dist_sample_DATA = store.composite htdocs/*.html store/*.* + +dist_noinst_SCRIPTS = server-test +TESTS = server-test + +endif diff --git a/sca-cpp/branches/lightweight-sca/samples/store-java/htdocs/index.html b/sca-cpp/branches/lightweight-sca/samples/store-java/htdocs/index.html new file mode 100644 index 0000000000..0698a32cc5 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-java/htdocs/index.html @@ -0,0 +1,156 @@ + + + + + + + +Store + + + + + + + +

Store

+
+
+

Catalog

+
+
+
+ +
+
+ +

Your Shopping Cart

+
+
+
+
+
+ + +(feed) +
+
+ + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-java/server-test b/sca-cpp/branches/lightweight-sca/samples/store-java/server-test new file mode 100755 index 0000000000..fb629a6814 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-java/server-test @@ -0,0 +1,58 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +echo "Testing..." +here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here` +curl_prefix=`cat $here/../../modules/http/curl.prefix` + +# Setup +./start +sleep 2 + +# Test HTTP GET +$curl_prefix/bin/curl http://localhost:8090/ 2>/dev/null >tmp/index.html +diff tmp/index.html htdocs/index.html +rc=$? + +# Test Catalog +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://localhost:8090/references/Store/catalog -X POST -H "Content-type: application/json-rpc" --data @../store-cpp/htdocs/test/items-request.txt >tmp/items-result.txt 2>/dev/null + diff tmp/items-result.txt ../store-cpp/htdocs/test/items-result.txt + rc=$? +fi + +# Test Shopping Cart +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://localhost:8090/references/Store/shoppingCart -X POST -H "Content-type: application/atom+xml" --data @../store-cpp/htdocs/test/shopping-cart-entry.xml 2>/dev/null + rc=$? +fi +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://localhost:8090/references/Store/shoppingCart >tmp/shopping-cart-feed.xml 2>/dev/null + grep "3.55" tmp/shopping-cart-feed.xml >/dev/null + rc=$? +fi + +# Cleanup +./stop +sleep 2 + +if [ "$rc" = "0" ]; then + echo "OK" +fi +exit $rc diff --git a/sca-cpp/branches/lightweight-sca/samples/store-java/ssl-start b/sca-cpp/branches/lightweight-sca/samples/store-java/ssl-start new file mode 100755 index 0000000000..a585f717aa --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-java/ssl-start @@ -0,0 +1,38 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +../../modules/http/ssl-ca-conf tmp localhost +../../modules/http/ssl-cert-conf tmp localhost +../../modules/http/httpd-conf tmp localhost 8090 htdocs +../../modules/http/httpd-ssl-conf tmp 8453 +../../modules/http/basic-auth-conf tmp +../../modules/http/passwd-auth-conf tmp foo foo +../../modules/server/server-conf tmp +../../modules/java/java-conf tmp +cat >>tmp/conf/httpd.conf <>tmp/conf/httpd.conf < + + + + + + + + + + + + + + + + USD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost:11211 + + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-java/store/CurrencyConverter.java b/sca-cpp/branches/lightweight-sca/samples/store-java/store/CurrencyConverter.java new file mode 100644 index 0000000000..1ed15a670a --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-java/store/CurrencyConverter.java @@ -0,0 +1,28 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package store; + +public interface CurrencyConverter { + + Double convert(String from, String to, Double amount); + + String symbol(String currency); + +} diff --git a/sca-cpp/branches/lightweight-sca/samples/store-java/store/CurrencyConverterImpl.java b/sca-cpp/branches/lightweight-sca/samples/store-java/store/CurrencyConverterImpl.java new file mode 100644 index 0000000000..a6d0fd00b3 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-java/store/CurrencyConverterImpl.java @@ -0,0 +1,45 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package store; + +/** + * Currency converter component implementation. + */ +public class CurrencyConverterImpl { + + /** + * Convert an amount from USD to a currency. + */ + public Double convert(String from, String to, Double amount) { + if ("EUR".equals(to)) + return amount * 0.70; + return amount; + } + + /** + * Return a currency symbol. + */ + public String symbol(String currency) { + if ("EUR".equals(currency)) + return "E"; + return "$"; + } + +} diff --git a/sca-cpp/branches/lightweight-sca/samples/store-java/store/FruitsCatalogImpl.java b/sca-cpp/branches/lightweight-sca/samples/store-java/store/FruitsCatalogImpl.java new file mode 100644 index 0000000000..8881543103 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-java/store/FruitsCatalogImpl.java @@ -0,0 +1,51 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package store; + +import static org.apache.tuscany.IterableUtil.*; + +import org.apache.tuscany.Service; + +/** + * Catalog component implementation. + */ +public class FruitsCatalogImpl { + + /** + * Returns the catalog. + */ + public Iterable items(final CurrencyConverter converter, final Service currencyCode) { + final String code = currencyCode.eval(); + + class Converter { + Double convert(final Double price) { + return converter.convert(code, "USD", price); + } + } + + final Converter c = new Converter(); + final String symbol = converter.symbol(code); + + return list(list(list("'name", "Apple"), list("'currencyCode", code), list("'currencySymbol", symbol), list("'price", c.convert(2.99))), + list(list("'name", "Orange"), list("'currencyCode", code), list("'currencySymbol", symbol), list("'price", c.convert(3.55))), + list(list("'name", "Pear"), list("'currencyCode", code), list("'currencySymbol", symbol), list("'price", c.convert(1.55)))); + } + +} diff --git a/sca-cpp/branches/lightweight-sca/samples/store-java/store/ShoppingCartImpl.java b/sca-cpp/branches/lightweight-sca/samples/store-java/store/ShoppingCartImpl.java new file mode 100644 index 0000000000..bd7678cce7 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-java/store/ShoppingCartImpl.java @@ -0,0 +1,113 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +package store; + +import static org.apache.tuscany.IterableUtil.*; +import static org.apache.tuscany.UUIDUtil.*; + +import org.apache.tuscany.Service; + +/** + * Shopping cart component implementation. + */ +public class ShoppingCartImpl { + + static String cartId = "1234"; + + /** + * Get the shopping cart from the cache. Return an empty cart if not found. + */ + public Iterable getcart(final String id, final Service cache) { + final Iterable iid = list(id); + final Iterable cart = cache.get(iid); + if(cart == null) + return list(); + return cart; + } + + /** + * Post a new item to the cart. Create a new cart if necessary. + */ + public Iterable post(final Iterable collection, final Iterable item, final Service cache) { + final String id = uuid(); + final Iterable newItem = list("'entry", cadr(car(item)), list("'id", id), cadddr(car(item))); + final Iterable cart = cons(newItem, this.getcart(cartId, cache)); + final Iterable iid = list(cartId); + cache.put(iid, cart); + return list(id); + } + + /** + * Find an item in the cart. + */ + Iterable find(final String id, final Iterable cart) { + if(isNil(cart)) + return list(list("'entry", list("'title", "Item"), list("'id", "0"))); + if(id.equals(cadr(caddr(car(cart))))) + return list(car(cart)); + return this.find(id, cdr(cart)); + } + + /** + * Return items from the cart. + */ + public Iterable get(final Iterable id, final Service cache) { + if(isNil(id)) + return list(append(list("'feed", list("'title", "Your Cart"), list("'id", cartId)), this.getcart(cartId, cache))); + return this.find((String)car(id), this.getcart(cartId, cache)); + } + + /** + * Delete items from the cart. + */ + public Boolean delete(final Iterable id, final Service cache) { + if(isNil(id)) { + final Iterable iid = list(cartId); + return cache.delete(iid); + } + return true; + } + + /** + * Return the price of an item. + */ + Double price(final Iterable item) { + System.err.println("price!! " + cadr(cadddr(item))); + return Double.valueOf((String)cadr(assoc("'price", cdr(cadr(cadddr(item)))))); + } + + /** + * Sum the prices of a list of items. + */ + Double sum(final Iterable items) { + if(isNil(items)) + return 0.0; + return this.price((Iterable)car(items)) + this.sum(cdr(items)); + } + + /** + * Return the total price of the items in the cart. + */ + public Double total(final Service cache) { + final Iterable cart = this.getcart(cartId, cache); + return this.sum(cart); + } + +} diff --git a/sca-cpp/branches/lightweight-sca/samples/store-python/Makefile.am b/sca-cpp/branches/lightweight-sca/samples/store-python/Makefile.am new file mode 100644 index 0000000000..8db150cc0e --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-python/Makefile.am @@ -0,0 +1,28 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +if WANT_PYTHON + +dist_sample_SCRIPTS = start stop ssl-start uec2-start +sampledir = $(prefix)/samples/store-python + +nobase_dist_sample_DATA = currency-converter.py fruits-catalog.py shopping-cart.py store.py store.composite htdocs/*.html htdocs/login/*.html htdocs/logout/*.html + +dist_noinst_SCRIPTS = server-test +TESTS = server-test + +endif diff --git a/sca-cpp/branches/lightweight-sca/samples/store-python/currency-converter.py b/sca-cpp/branches/lightweight-sca/samples/store-python/currency-converter.py new file mode 100644 index 0000000000..2fded8f616 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-python/currency-converter.py @@ -0,0 +1,29 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Currency converter implementation + +def convert(fr, to, amount): + if to == "EUR": + return amount * 0.70 + return amount + +def symbol(currency): + if currency == "EUR": + return "E" + return "$" + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-python/fruits-catalog.py b/sca-cpp/branches/lightweight-sca/samples/store-python/fruits-catalog.py new file mode 100644 index 0000000000..8289afcac5 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-python/fruits-catalog.py @@ -0,0 +1,30 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Catalog implementation + +def items(converter, currencyCode): + code = currencyCode.eval() + def convert(price): + return converter.convert("USD", code, price) + symbol = converter.symbol(code) + return ( + (("'name", "Mango"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(2.99))), + (("'name", "Passion"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(3.55))), + (("'name", "Kiwi"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(1.55))) + ) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-python/htdocs/index.html b/sca-cpp/branches/lightweight-sca/samples/store-python/htdocs/index.html new file mode 100644 index 0000000000..0698a32cc5 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-python/htdocs/index.html @@ -0,0 +1,156 @@ + + + + + + + +Store + + + + + + + +

Store

+
+
+

Catalog

+
+
+
+ +
+
+ +

Your Shopping Cart

+
+
+
+
+
+ + +(feed) +
+
+ + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-python/htdocs/login/index.html b/sca-cpp/branches/lightweight-sca/samples/store-python/htdocs/login/index.html new file mode 100644 index 0000000000..fd3bc21889 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-python/htdocs/login/index.html @@ -0,0 +1,51 @@ + + + + + + + + + +Sign in + + +

Sign in

+
+ + + +
+ + + + +
Username:
Password:
+ +
+ + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-python/htdocs/logout/index.html b/sca-cpp/branches/lightweight-sca/samples/store-python/htdocs/logout/index.html new file mode 100644 index 0000000000..92fd2a084b --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-python/htdocs/logout/index.html @@ -0,0 +1,43 @@ + + + + + + + + + +Sign out + + +

Sign out

+
+ +
+ + +
+ diff --git a/sca-cpp/branches/lightweight-sca/samples/store-python/htdocs/test/items-result.txt b/sca-cpp/branches/lightweight-sca/samples/store-python/htdocs/test/items-result.txt new file mode 100644 index 0000000000..d6aaf4d44a --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-python/htdocs/test/items-result.txt @@ -0,0 +1,23 @@ +{ + "id": 1, + "result": [ + { + "name": "Mango", + "currencyCode": "USD", + "currencySymbol": "$", + "price": 2.99 + }, + { + "name": "Passion", + "currencyCode": "USD", + "currencySymbol": "$", + "price": 3.55 + }, + { + "name": "Kiwi", + "currencyCode": "USD", + "currencySymbol": "$", + "price": 1.55 + } + ] +} \ No newline at end of file diff --git a/sca-cpp/branches/lightweight-sca/samples/store-python/server-test b/sca-cpp/branches/lightweight-sca/samples/store-python/server-test new file mode 100755 index 0000000000..8f52543c71 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-python/server-test @@ -0,0 +1,58 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +echo "Testing..." +here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here` +curl_prefix=`cat $here/../../modules/http/curl.prefix` + +# Setup +./start +sleep 2 + +# Test HTTP GET +$curl_prefix/bin/curl http://localhost:8090/ 2>/dev/null >tmp/index.html +diff tmp/index.html htdocs/index.html +rc=$? + +# Test Catalog +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://localhost:8090/references/Store/catalog -X POST -H "Content-type: application/json-rpc" --data @../store-cpp/htdocs/test/items-request.txt >tmp/items-result.txt 2>/dev/null + diff tmp/items-result.txt htdocs/test/items-result.txt + rc=$? +fi + +# Test Shopping Cart +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://localhost:8090/references/Store/shoppingCart -X POST -H "Content-type: application/atom+xml" --data @../store-cpp/htdocs/test/shopping-cart-entry.xml 2>/dev/null + rc=$? +fi +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://localhost:8090/references/Store/shoppingCart >tmp/shopping-cart-feed.xml 2>/dev/null + grep "3.55" tmp/shopping-cart-feed.xml >/dev/null + rc=$? +fi + +# Cleanup +./stop +sleep 2 + +if [ "$rc" = "0" ]; then + echo "OK" +fi +exit $rc diff --git a/sca-cpp/branches/lightweight-sca/samples/store-python/shopping-cart.py b/sca-cpp/branches/lightweight-sca/samples/store-python/shopping-cart.py new file mode 100644 index 0000000000..1dac82522f --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-python/shopping-cart.py @@ -0,0 +1,75 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Shopping cart implementation +import uuid +import sys + +cartId = "1234" + +# Get the shopping cart from the cache +# Return an empty cart if not found +def getcart(id, cache): + cart = cache.get((id,)) + if cart is None: + return () + return cart + +# Post a new item to the cart, create a new cart if necessary +def post(collection, item, cache): + id = str(uuid.uuid1()) + cart = (("'entry", item[0][1], ("'id", id), item[0][3]),) + getcart(cartId, cache) + cache.put((cartId,), cart) + return (id,) + + +# Find an item in the cart +def find(id, cart): + if cart == (): + return (("'entry", ("'title", "Item"), ("'id", 0)),) + elif id == cart[0][2][1]: + return (cart[0],) + else: + return find(id, cart[1:]) + +# Get items from the cart +def get(id, cache): + if id == (): + return ((("'feed", ("'title", "Your Cart"), ("'id", cartId)) + getcart(cartId, cache)),) + return find(id[0], getcart(cartId, cache)) + +# Delete items from the cart +def delete(id, cache): + if id == (): + return cache.delete((cartId,)) + return True + +# Return the price of an item +def price(item): + return float(filter(lambda x: x[0] == "'price", item[3][1][1:])[0][1]) + +# Sum the prices of a list of items +def sum(items): + if items == (): + return 0 + return price(items[0]) + sum(items[1:]) + +# Return the total price of the items in the cart +def total(cache): + cart = getcart(cartId, cache) + return sum(cart) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-python/ssl-start b/sca-cpp/branches/lightweight-sca/samples/store-python/ssl-start new file mode 100755 index 0000000000..2a9df09c2e --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-python/ssl-start @@ -0,0 +1,37 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +../../modules/http/ssl-ca-conf tmp localhost +../../modules/http/ssl-cert-conf tmp localhost +../../modules/http/httpd-conf tmp localhost 8090 htdocs +../../modules/http/httpd-event-conf tmp +../../modules/http/httpd-ssl-conf tmp 8453 +../../modules/http/open-auth-conf tmp +../../modules/http/passwd-auth-conf tmp foo foo +../../modules/server/server-conf tmp +../../modules/python/python-conf tmp +cat >>tmp/conf/httpd.conf <>tmp/conf/httpd.conf < + + + + + + + + + + + + + + + + USD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost:11211 + + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-python/store.py b/sca-cpp/branches/lightweight-sca/samples/store-python/store.py new file mode 100644 index 0000000000..b71f505dd1 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-python/store.py @@ -0,0 +1,40 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Store implementation + +def post(item, catalog, shoppingCart, shoppingTotal): + return shoppingCart.post(item) + +def getall(catalog, shoppingCart, shoppingTotal): + return shoppingCart.getall() + +def get(id, catalog, shoppingCart, shoppingTotal): + return shoppingCart.get(id) + +def items(catalog, shoppingCart, shoppingTotal): + return catalog.items() + +def total(catalog, shoppingCart, shoppingTotal): + return shoppingCart.gettotal() + +def deleteall(catalog, shoppingCart, shoppingTotal): + return shoppingCart.deleteall() + +def delete(id, catalog, shoppingCart, shoppingTotal): + return shoppingCart.delete(id) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-python/uec2-start b/sca-cpp/branches/lightweight-sca/samples/store-python/uec2-start new file mode 100755 index 0000000000..feb4ae383e --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-python/uec2-start @@ -0,0 +1,47 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Pass your EC2 public host name +if [ "$1" != "" ]; then + host=$1 +else + host="localhost" +fi + +# Ports 80, 443, 444, 8090, 8453, 8454 need to be open +sudo ../../ubuntu/ip-redirect-all 80 8090 +sudo ../../ubuntu/ip-redirect-all 443 8453 + +../../modules/http/ssl-ca-conf tmp $host +../../modules/http/ssl-cert-conf tmp $host +../../modules/http/httpd-conf tmp $host 8090/80 htdocs +../../modules/http/httpd-event-conf tmp +../../modules/http/httpd-ssl-conf tmp 8453/443 +../../modules/server/server-conf tmp +../../modules/python/python-conf tmp +cat >>tmp/conf/httpd.conf < + + + + + + +Store + + + + + + + +

Store

+
+
+

Catalog

+
+
+
+ +
+
+ +

Your Shopping Cart

+
+
+
+
+
+ + +(feed) +
+
+ + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-scheme/script-test.cpp b/sca-cpp/branches/lightweight-sca/samples/store-scheme/script-test.cpp new file mode 100644 index 0000000000..0d5a9ccf9d --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-scheme/script-test.cpp @@ -0,0 +1,96 @@ +/* + * Licensed to the Apache Software Foundation (ASF) under one + * or more contributor license agreements. See the NOTICE file + * distributed with this work for additional information + * regarding copyright ownership. The ASF licenses this file + * to you under the Apache License, Version 2.0 (the + * "License"); you may not use this file except in compliance + * with the License. You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, + * software distributed under the License is distributed on an + * "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY + * KIND, either express or implied. See the License for the + * specific language governing permissions and limitations + * under the License. + */ + +/* $Rev$ $Date$ */ + +/** + * Store Test case. + */ + +#include +#include +#include "stream.hpp" +#include "string.hpp" +#include "list.hpp" +#include "xml.hpp" +#include "../../modules/scheme/driver.hpp" +#include "../../modules/json/json.hpp" + +namespace store { + +using namespace tuscany; + +bool testScript() { + gc_scoped_pool pool; + + ifstream is("script-test.scm"); + ostringstream os; + scheme::evalDriverRun(is, os); + assert(contains(str(os), "(\"Sample Feed\" \"")); + assert(contains(str(os), "\" (\"Item\" \"")); + assert(contains(str(os), "\" ((name \"Orange\") (currencyCode \"USD\") (currencySymbol \"$\") (price 3.55))) (\"Item\" \"")); + assert(contains(str(os), "\" ((name \"Apple\") (currencyCode \"USD\") (currencySymbol \"$\") (price 2.99))))")); + return true; +} + +bool testEval() { + { + gc_scoped_pool pool; + ifstream is("script-test.scm"); + ostringstream os; + scheme::setupDisplay(os); + scheme::Env globalEnv = scheme::setupEnvironment(); + const value exp(mklist("storeui_service", string("items"))); + const value val = scheme::evalScript(exp, is, globalEnv); + + ostringstream vs; + vs << val; + assert(contains(str(vs), "(((name \"Apple\") (currencyCode \"USD\") (currencySymbol \"$\") (price 2.99)) ((name \"Orange\") (currencyCode \"USD\") (currencySymbol \"$\") (price 3.55)) ((name \"Pear\") (currencyCode \"USD\") (currencySymbol \"$\") (price 1.55)))")); + } + + { + gc_scoped_pool pool; + ifstream is("script-test.scm"); + ostringstream os; + scheme::setupDisplay(os); + + scheme::Env globalEnv = scheme::setupEnvironment(); + const value exp(mklist("storeui_service", string("total"))); + const value res = scheme::evalScript(exp, is, globalEnv); + + ostringstream rs; + rs << res; + assert(contains(str(rs), "10")); + } + return true; +} + +} + +int main() { + + tuscany::cout << "Testing..." << tuscany::endl; + + store::testScript(); + store::testEval(); + + tuscany::cout << "OK" << tuscany::endl; + + return 0; +} diff --git a/sca-cpp/branches/lightweight-sca/samples/store-scheme/script-test.scm b/sca-cpp/branches/lightweight-sca/samples/store-scheme/script-test.scm new file mode 100644 index 0000000000..50b587b8f1 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-scheme/script-test.scm @@ -0,0 +1,140 @@ +; Licensed to the Apache Software Foundation (ASF) under one +; or more contributor license agreements. See the NOTICE file +; distributed with this work for additional information +; regarding copyright ownership. The ASF licenses this file +; to you under the Apache License, Version 2.0 (the +; "License"); you may not use this file except in compliance +; with the License. You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, +; software distributed under the License is distributed on an +; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +; KIND, either express or implied. See the License for the +; specific language governing permissions and limitations +; under the License. + +; Currency implementation + +(define (currency_convert from to amount) + (if (equal? to "EUR") (* amount 0.70) amount) +) + +(define (currency_symbol currency) + (if (equal? currency "EUR") "E" "$") +) + +(define (currency_impl op args) + (cond + ((equal? op "convert") (apply currency_convert args)) + ((equal? op "symbol") (apply currency_symbol args)) + ) +) + +; Currency composite + +(define (currency_service op . args) (currency_impl op args)) + +; Catalog implementation + +(define (catalog_get converter) + (define (convert price) (converter "convert" "USD" "USD" price)) + + (define code "USD") + (define symbol (converter "symbol" code)) + + (list + (list (list 'name "Apple") (list 'currencyCode code) (list 'currencySymbol symbol) (list 'price 2.99)) + (list (list 'name "Orange") (list 'currencyCode code) (list 'currencySymbol symbol) (list 'price 3.55)) + (list (list 'name "Pear") (list 'currencyCode code) (list 'currencySymbol symbol) (list 'price 1.55)) + ) +) + +(define (catalog_impl converter op args) + (cond + ((equal? op "items") (apply catalog_get (cons converter args))) + ) +) + +; Catalog composite + +(define (catalog_service op . args) (catalog_impl currency_service op args)) + +; Cart implementation + +(define (cart_post content item) + (cons (cons "Item" (list (uuid) item)) content) +) + +(define (cart_getall content) + (cons "Sample Feed" (cons (uuid) content)) +) + +(define (cart_getentry id) + (define entry (list (list 'name "Apple") (list 'currencyCode "USD") (list 'currencySymbol "$") (list 'price 2.99))) + (cons "Item" (list id entry)) +) + +(define (cart_total) + 10.0 +) + +(define (cart_impl op args) + (cond + ((equal? op "post") (apply cart_post args)) + ((equal? op "getall") (apply cart_getall args)) + ((equal? op "getentry") (apply cart_getentry args)) + ((equal? op "total") (apply cart_total args)) + ) +) + +; Store UI implementation + +(define (storeui_post cart content item) + (cart "post" content item) +) + +(define (storeui_getcart cart content) + (cart "getall" content) +) + +(define (storeui_getentry cart id) + (cart "getentry" id) +) + +(define (storeui_items catalog) + (catalog "items") +) + +(define (storeui_total cart) + (cart "total") +) + +(define (storeui_impl cart catalog op args) + (cond + ((equal? op "post") (apply storeui_post (cons cart args))) + ((equal? op "getall") (apply storeui_getcart (cons cart args))) + ((equal? op "getentry") (apply storeui_getentry (cons cart args))) + ((equal? op "items") (apply storeui_items (cons catalog args))) + ((equal? op "total") (apply storeui_total (cons cart args))) + ) +) + +; Store UI composite + +(define (cart_service op . args) (cart_impl op args)) + +(define (storeui_service op . args) (storeui_impl cart_service catalog_service op args)) + +; Store UI test case + +(define catalog (storeui_service "items")) +(define empty (list)) +(define apple (car catalog)) +(define orange (car (cdr catalog))) +(define added1 (storeui_service "post" empty apple)) +(define added2 (storeui_service "post" added1 orange)) +(display (storeui_service "getall" added2)) +(display (storeui_service "total")) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-scheme/server-test b/sca-cpp/branches/lightweight-sca/samples/store-scheme/server-test new file mode 100755 index 0000000000..fb629a6814 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-scheme/server-test @@ -0,0 +1,58 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +echo "Testing..." +here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here` +curl_prefix=`cat $here/../../modules/http/curl.prefix` + +# Setup +./start +sleep 2 + +# Test HTTP GET +$curl_prefix/bin/curl http://localhost:8090/ 2>/dev/null >tmp/index.html +diff tmp/index.html htdocs/index.html +rc=$? + +# Test Catalog +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://localhost:8090/references/Store/catalog -X POST -H "Content-type: application/json-rpc" --data @../store-cpp/htdocs/test/items-request.txt >tmp/items-result.txt 2>/dev/null + diff tmp/items-result.txt ../store-cpp/htdocs/test/items-result.txt + rc=$? +fi + +# Test Shopping Cart +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://localhost:8090/references/Store/shoppingCart -X POST -H "Content-type: application/atom+xml" --data @../store-cpp/htdocs/test/shopping-cart-entry.xml 2>/dev/null + rc=$? +fi +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://localhost:8090/references/Store/shoppingCart >tmp/shopping-cart-feed.xml 2>/dev/null + grep "3.55" tmp/shopping-cart-feed.xml >/dev/null + rc=$? +fi + +# Cleanup +./stop +sleep 2 + +if [ "$rc" = "0" ]; then + echo "OK" +fi +exit $rc diff --git a/sca-cpp/branches/lightweight-sca/samples/store-scheme/shopping-cart.scm b/sca-cpp/branches/lightweight-sca/samples/store-scheme/shopping-cart.scm new file mode 100644 index 0000000000..e653f1e33c --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-scheme/shopping-cart.scm @@ -0,0 +1,82 @@ +; Licensed to the Apache Software Foundation (ASF) under one +; or more contributor license agreements. See the NOTICE file +; distributed with this work for additional information +; regarding copyright ownership. The ASF licenses this file +; to you under the Apache License, Version 2.0 (the +; "License"); you may not use this file except in compliance +; with the License. You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, +; software distributed under the License is distributed on an +; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +; KIND, either express or implied. See the License for the +; specific language governing permissions and limitations +; under the License. + +; Shopping cart implementation + +(define cartId "1234") + +; Get the shopping cart from the cache +; Return an empty cart if not found +(define (getcart id cache) + (define cart (cache "get" (list id))) + (if (nul cart) + (list) + cart) +) + +; Post a new item to the cart, create a new cart if necessary +(define (post collection item cache) + (define id (uuid)) + (define newItem (list 'entry (cadr (car item)) (list 'id id) (cadddr (car item)))) + (define cart (cons newItem (getcart cartId cache))) + (cache "put" (list cartId) cart) + (list id) +) + +; Find an item in the cart +(define (find id cart) + (if (nul cart) + (list (list 'entry (list 'title "Item") (list 'id "0"))) + (if (= id (cadr (caddr (car cart)))) + (list (car cart)) + (find id (cdr cart)))) +) + +; Get items from the cart +(define (get id cache) + (if (nul id) + (list (append (list 'feed (list 'title "Your Cart") (list 'id cartId)) (getcart cartId cache))) + (find (car id) (getcart cartId cache)) + ) +) + +; Delete items from the cart +(define (delete id cache) + (if (nul id) + (cache "delete" (list cartId)) + true + ) +) + +; Return the price of an item +(define (price item) + (cadr (assoc 'price (cadr (cadddr item)))) +) + +; Sum the prices of a list of items +(define (sum items) + (if (nul items) + 0 + (+ (price (car items)) (sum (cdr items)))) +) + +; Return the total price of the items in the cart +(define (total cache) + (define cart (getcart cartId cache)) + (sum cart) +) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-scheme/ssl-start b/sca-cpp/branches/lightweight-sca/samples/store-scheme/ssl-start new file mode 100755 index 0000000000..cc0272c28f --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-scheme/ssl-start @@ -0,0 +1,36 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +../../modules/http/ssl-ca-conf tmp localhost +../../modules/http/ssl-cert-conf tmp localhost +../../modules/http/httpd-conf tmp localhost 8090 htdocs +../../modules/http/httpd-ssl-conf tmp 8453 +../../modules/http/basic-auth-conf tmp +../../modules/http/passwd-auth-conf tmp foo foo +../../modules/server/server-conf tmp +../../modules/server/scheme-conf tmp +cat >>tmp/conf/httpd.conf <>tmp/conf/httpd.conf < + + + + + + + + + + + + + + + + USD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost:11211 + + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-scheme/store.scm b/sca-cpp/branches/lightweight-sca/samples/store-scheme/store.scm new file mode 100644 index 0000000000..f54257343e --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-scheme/store.scm @@ -0,0 +1,47 @@ +; Licensed to the Apache Software Foundation (ASF) under one +; or more contributor license agreements. See the NOTICE file +; distributed with this work for additional information +; regarding copyright ownership. The ASF licenses this file +; to you under the Apache License, Version 2.0 (the +; "License"); you may not use this file except in compliance +; with the License. You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, +; software distributed under the License is distributed on an +; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +; KIND, either express or implied. See the License for the +; specific language governing permissions and limitations +; under the License. + +; Store implementation + +(define (post item catalog shoppingCart shoppingTotal) + (shoppingCart "post" item) +) + +(define (getall catalog shoppingCart shoppingTotal) + (shoppingCart "getall") +) + +(define (get id catalog shoppingCart shoppingTotal) + (shoppingCart "get" id) +) + +(define (items catalog shoppingCart shoppingTotal) + (catalog "items") +) + +(define (total catalog shoppingCart shoppingTotal) + (shoppingCart "total") +) + +(define (deleteall catalog shoppingCart shoppingTotal) + (shoppingCart "deleteall") +) + +(define (delete id catalog shoppingCart shoppingTotal) + (shoppingCart "delete" id) +) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-sql/Makefile.am b/sca-cpp/branches/lightweight-sca/samples/store-sql/Makefile.am new file mode 100644 index 0000000000..3b738e3972 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-sql/Makefile.am @@ -0,0 +1,28 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +if WANT_SQLDB + +dist_sample_SCRIPTS = start stop ssl-start +sampledir = $(prefix)/samples/store-sql + +nobase_dist_sample_DATA = currency-converter.scm fruits-catalog.scm shopping-cart.scm store.scm store.composite htdocs/*.html + +dist_noinst_SCRIPTS = server-test +TESTS = server-test + +endif diff --git a/sca-cpp/branches/lightweight-sca/samples/store-sql/currency-converter.scm b/sca-cpp/branches/lightweight-sca/samples/store-sql/currency-converter.scm new file mode 100644 index 0000000000..fc506c3d73 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-sql/currency-converter.scm @@ -0,0 +1,27 @@ +; Licensed to the Apache Software Foundation (ASF) under one +; or more contributor license agreements. See the NOTICE file +; distributed with this work for additional information +; regarding copyright ownership. The ASF licenses this file +; to you under the Apache License, Version 2.0 (the +; "License"); you may not use this file except in compliance +; with the License. You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, +; software distributed under the License is distributed on an +; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +; KIND, either express or implied. See the License for the +; specific language governing permissions and limitations +; under the License. + +; Currency converter implementation + +(define (convert from to amount) + (if (equal? to "EUR") (* amount 0.70) amount) +) + +(define (symbol currency) + (if (equal? currency "EUR") "E" "$") +) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-sql/fruits-catalog.scm b/sca-cpp/branches/lightweight-sca/samples/store-sql/fruits-catalog.scm new file mode 100644 index 0000000000..d55394b96a --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-sql/fruits-catalog.scm @@ -0,0 +1,30 @@ +; Licensed to the Apache Software Foundation (ASF) under one +; or more contributor license agreements. See the NOTICE file +; distributed with this work for additional information +; regarding copyright ownership. The ASF licenses this file +; to you under the Apache License, Version 2.0 (the +; "License"); you may not use this file except in compliance +; with the License. You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, +; software distributed under the License is distributed on an +; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +; KIND, either express or implied. See the License for the +; specific language governing permissions and limitations +; under the License. + +; Catalog implementation + +(define (items converter currencyCode) + (define code (currencyCode)) + (define (convert price) (converter "convert" "USD" code price)) + (define symbol (converter "symbol" code)) + (list + (list (list 'name "Apple") (list 'currencyCode code) (list 'currencySymbol symbol) (list 'price (convert 2.99))) + (list (list 'name "Orange") (list 'currencyCode code) (list 'currencySymbol symbol) (list 'price (convert 3.55))) + (list (list 'name "Pear") (list 'currencyCode code) (list 'currencySymbol symbol) (list 'price (convert 1.55))) + ) +) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-sql/htdocs/index.html b/sca-cpp/branches/lightweight-sca/samples/store-sql/htdocs/index.html new file mode 100644 index 0000000000..0698a32cc5 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-sql/htdocs/index.html @@ -0,0 +1,156 @@ + + + + + + + +Store + + + + + + + +

Store

+
+
+

Catalog

+
+
+
+ +
+
+ +

Your Shopping Cart

+
+
+
+
+
+ + +(feed) +
+
+ + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-sql/server-test b/sca-cpp/branches/lightweight-sca/samples/store-sql/server-test new file mode 100755 index 0000000000..fb629a6814 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-sql/server-test @@ -0,0 +1,58 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +echo "Testing..." +here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here` +curl_prefix=`cat $here/../../modules/http/curl.prefix` + +# Setup +./start +sleep 2 + +# Test HTTP GET +$curl_prefix/bin/curl http://localhost:8090/ 2>/dev/null >tmp/index.html +diff tmp/index.html htdocs/index.html +rc=$? + +# Test Catalog +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://localhost:8090/references/Store/catalog -X POST -H "Content-type: application/json-rpc" --data @../store-cpp/htdocs/test/items-request.txt >tmp/items-result.txt 2>/dev/null + diff tmp/items-result.txt ../store-cpp/htdocs/test/items-result.txt + rc=$? +fi + +# Test Shopping Cart +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://localhost:8090/references/Store/shoppingCart -X POST -H "Content-type: application/atom+xml" --data @../store-cpp/htdocs/test/shopping-cart-entry.xml 2>/dev/null + rc=$? +fi +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://localhost:8090/references/Store/shoppingCart >tmp/shopping-cart-feed.xml 2>/dev/null + grep "3.55" tmp/shopping-cart-feed.xml >/dev/null + rc=$? +fi + +# Cleanup +./stop +sleep 2 + +if [ "$rc" = "0" ]; then + echo "OK" +fi +exit $rc diff --git a/sca-cpp/branches/lightweight-sca/samples/store-sql/shopping-cart.scm b/sca-cpp/branches/lightweight-sca/samples/store-sql/shopping-cart.scm new file mode 100644 index 0000000000..e653f1e33c --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-sql/shopping-cart.scm @@ -0,0 +1,82 @@ +; Licensed to the Apache Software Foundation (ASF) under one +; or more contributor license agreements. See the NOTICE file +; distributed with this work for additional information +; regarding copyright ownership. The ASF licenses this file +; to you under the Apache License, Version 2.0 (the +; "License"); you may not use this file except in compliance +; with the License. You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, +; software distributed under the License is distributed on an +; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +; KIND, either express or implied. See the License for the +; specific language governing permissions and limitations +; under the License. + +; Shopping cart implementation + +(define cartId "1234") + +; Get the shopping cart from the cache +; Return an empty cart if not found +(define (getcart id cache) + (define cart (cache "get" (list id))) + (if (nul cart) + (list) + cart) +) + +; Post a new item to the cart, create a new cart if necessary +(define (post collection item cache) + (define id (uuid)) + (define newItem (list 'entry (cadr (car item)) (list 'id id) (cadddr (car item)))) + (define cart (cons newItem (getcart cartId cache))) + (cache "put" (list cartId) cart) + (list id) +) + +; Find an item in the cart +(define (find id cart) + (if (nul cart) + (list (list 'entry (list 'title "Item") (list 'id "0"))) + (if (= id (cadr (caddr (car cart)))) + (list (car cart)) + (find id (cdr cart)))) +) + +; Get items from the cart +(define (get id cache) + (if (nul id) + (list (append (list 'feed (list 'title "Your Cart") (list 'id cartId)) (getcart cartId cache))) + (find (car id) (getcart cartId cache)) + ) +) + +; Delete items from the cart +(define (delete id cache) + (if (nul id) + (cache "delete" (list cartId)) + true + ) +) + +; Return the price of an item +(define (price item) + (cadr (assoc 'price (cadr (cadddr item)))) +) + +; Sum the prices of a list of items +(define (sum items) + (if (nul items) + 0 + (+ (price (car items)) (sum (cdr items)))) +) + +; Return the total price of the items in the cart +(define (total cache) + (define cart (getcart cartId cache)) + (sum cart) +) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-sql/ssl-start b/sca-cpp/branches/lightweight-sca/samples/store-sql/ssl-start new file mode 100755 index 0000000000..adfba0d761 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-sql/ssl-start @@ -0,0 +1,39 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +../../modules/http/ssl-ca-conf tmp localhost +../../modules/http/ssl-cert-conf tmp localhost +../../modules/http/httpd-conf tmp localhost 8090 htdocs +../../modules/http/httpd-ssl-conf tmp 8453 +../../modules/http/basic-auth-conf tmp +../../modules/http/passwd-auth-conf tmp foo foo +../../modules/server/server-conf tmp +../../modules/server/scheme-conf tmp +cat >>tmp/conf/httpd.conf </dev/null 2>&1 +../../modules/http/httpd-start tmp diff --git a/sca-cpp/branches/lightweight-sca/samples/store-sql/start b/sca-cpp/branches/lightweight-sca/samples/store-sql/start new file mode 100755 index 0000000000..f3d5e67a33 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-sql/start @@ -0,0 +1,36 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +rm -rf tmp +../../modules/http/httpd-conf tmp localhost 8090 htdocs +../../modules/http/httpd-event-conf tmp +../../modules/server/server-conf tmp +../../modules/server/scheme-conf tmp +cat >>tmp/conf/httpd.conf </dev/null 2>&1 +../../modules/http/httpd-start tmp diff --git a/sca-cpp/branches/lightweight-sca/samples/store-sql/stop b/sca-cpp/branches/lightweight-sca/samples/store-sql/stop new file mode 100755 index 0000000000..daf271cbfa --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-sql/stop @@ -0,0 +1,22 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +../../modules/http/httpd-stop tmp +../../components/sqldb/pgsql-stop tmp +../../components/cache/memcached-stop tmp diff --git a/sca-cpp/branches/lightweight-sca/samples/store-sql/store.composite b/sca-cpp/branches/lightweight-sca/samples/store-sql/store.composite new file mode 100644 index 0000000000..bb6898140f --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-sql/store.composite @@ -0,0 +1,89 @@ + + + + + + + + + + + + + + + + + USD + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + localhost:11211 + + + + + host=localhost port=6432 dbname=db + store + + + + + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-sql/store.scm b/sca-cpp/branches/lightweight-sca/samples/store-sql/store.scm new file mode 100644 index 0000000000..f54257343e --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-sql/store.scm @@ -0,0 +1,47 @@ +; Licensed to the Apache Software Foundation (ASF) under one +; or more contributor license agreements. See the NOTICE file +; distributed with this work for additional information +; regarding copyright ownership. The ASF licenses this file +; to you under the Apache License, Version 2.0 (the +; "License"); you may not use this file except in compliance +; with the License. You may obtain a copy of the License at +; +; http://www.apache.org/licenses/LICENSE-2.0 +; +; Unless required by applicable law or agreed to in writing, +; software distributed under the License is distributed on an +; "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +; KIND, either express or implied. See the License for the +; specific language governing permissions and limitations +; under the License. + +; Store implementation + +(define (post item catalog shoppingCart shoppingTotal) + (shoppingCart "post" item) +) + +(define (getall catalog shoppingCart shoppingTotal) + (shoppingCart "getall") +) + +(define (get id catalog shoppingCart shoppingTotal) + (shoppingCart "get" id) +) + +(define (items catalog shoppingCart shoppingTotal) + (catalog "items") +) + +(define (total catalog shoppingCart shoppingTotal) + (shoppingCart "total") +) + +(define (deleteall catalog shoppingCart shoppingTotal) + (shoppingCart "deleteall") +) + +(define (delete id catalog shoppingCart shoppingTotal) + (shoppingCart "delete" id) +) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-vhost/Makefile.am b/sca-cpp/branches/lightweight-sca/samples/store-vhost/Makefile.am new file mode 100644 index 0000000000..71dca3621d --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-vhost/Makefile.am @@ -0,0 +1,28 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +if WANT_PYTHON + +dist_sample_SCRIPTS = start stop ssl-start uec2-start +sampledir = $(prefix)/samples/store-vhost + +nobase_dist_sample_DATA = htdocs/*.html domains/*/htdocs/*.html domains/*/*.py domains/*/*.composite shared/*.composite + +dist_noinst_SCRIPTS = server-test +#TESTS = server-test + +endif diff --git a/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/currency-converter.py b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/currency-converter.py new file mode 100644 index 0000000000..2fded8f616 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/currency-converter.py @@ -0,0 +1,29 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Currency converter implementation + +def convert(fr, to, amount): + if to == "EUR": + return amount * 0.70 + return amount + +def symbol(currency): + if currency == "EUR": + return "E" + return "$" + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/fruits-catalog.py b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/fruits-catalog.py new file mode 100644 index 0000000000..fb20b4ff27 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/fruits-catalog.py @@ -0,0 +1,30 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Catalog implementation + +def items(converter, currencyCode): + code = currencyCode.eval() + def convert(price): + return converter.convert("USD", code, price) + symbol = converter.symbol(code) + return ( + (("'name", "Passion"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(2.99))), + (("'name", "Mango"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(3.55))), + (("'name", "Pineapple"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(1.55))) + ) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/htdocs/index.html b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/htdocs/index.html new file mode 100644 index 0000000000..832c0a1472 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/htdocs/index.html @@ -0,0 +1,156 @@ + + + + + + + +Jane's Store + + + + + + + +

Jane's Store

+
+
+

Catalog

+
+
+
+ +
+
+ +

Your Shopping Cart

+
+
+
+
+
+ + +(feed) +
+
+ + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/shopping-cart.py b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/shopping-cart.py new file mode 100644 index 0000000000..1dac82522f --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/shopping-cart.py @@ -0,0 +1,75 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Shopping cart implementation +import uuid +import sys + +cartId = "1234" + +# Get the shopping cart from the cache +# Return an empty cart if not found +def getcart(id, cache): + cart = cache.get((id,)) + if cart is None: + return () + return cart + +# Post a new item to the cart, create a new cart if necessary +def post(collection, item, cache): + id = str(uuid.uuid1()) + cart = (("'entry", item[0][1], ("'id", id), item[0][3]),) + getcart(cartId, cache) + cache.put((cartId,), cart) + return (id,) + + +# Find an item in the cart +def find(id, cart): + if cart == (): + return (("'entry", ("'title", "Item"), ("'id", 0)),) + elif id == cart[0][2][1]: + return (cart[0],) + else: + return find(id, cart[1:]) + +# Get items from the cart +def get(id, cache): + if id == (): + return ((("'feed", ("'title", "Your Cart"), ("'id", cartId)) + getcart(cartId, cache)),) + return find(id[0], getcart(cartId, cache)) + +# Delete items from the cart +def delete(id, cache): + if id == (): + return cache.delete((cartId,)) + return True + +# Return the price of an item +def price(item): + return float(filter(lambda x: x[0] == "'price", item[3][1][1:])[0][1]) + +# Sum the prices of a list of items +def sum(items): + if items == (): + return 0 + return price(items[0]) + sum(items[1:]) + +# Return the total price of the items in the cart +def total(cache): + cart = getcart(cartId, cache) + return sum(cart) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/store.composite b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/store.composite new file mode 100644 index 0000000000..58e5832bcf --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/store.composite @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + USD + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/store.py b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/store.py new file mode 100644 index 0000000000..ff82f1d327 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/jane/store.py @@ -0,0 +1,40 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Store implementation + +def post(item, catalog, shoppingCart, shoppingTotal): + return shoppingCart.post(item) + +def getall(catalog, shoppingCart, shoppingTotal): + return shoppingCart.getall() + +def get(id, catalog, shoppingCart, shoppingTotal): + return shoppingCart.get(id) + +def items(catalog, shoppingCart, shoppingTotal): + return catalog.items() + +def total(catalog, shoppingCart, shoppingTotal): + return shoppingCart.total() + +def deleteall(catalog, shoppingCart, shoppingTotal): + return shoppingCart.deleteall() + +def delete(id, catalog, shoppingCart, shoppingTotal): + return shoppingCart.delete(id) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/currency-converter.py b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/currency-converter.py new file mode 100644 index 0000000000..2fded8f616 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/currency-converter.py @@ -0,0 +1,29 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Currency converter implementation + +def convert(fr, to, amount): + if to == "EUR": + return amount * 0.70 + return amount + +def symbol(currency): + if currency == "EUR": + return "E" + return "$" + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/fruits-catalog.py b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/fruits-catalog.py new file mode 100644 index 0000000000..6644421683 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/fruits-catalog.py @@ -0,0 +1,30 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Catalog implementation + +def items(converter, currencyCode): + code = currencyCode.eval() + def convert(price): + return converter.convert("USD", code, price) + symbol = converter.symbol(code) + return ( + (("'name", "Apple"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(2.99))), + (("'name", "Orange"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(3.55))), + (("'name", "Pear"), ("'currencyCode", code), ("'currencySymbol", symbol), ("'price", convert(1.55))) + ) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/htdocs/index.html b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/htdocs/index.html new file mode 100644 index 0000000000..0caf8b3df1 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/htdocs/index.html @@ -0,0 +1,156 @@ + + + + + + + +Joe's Store + + + + + + + +

Joe's Store

+
+
+

Catalog

+
+
+
+ +
+
+ +

Your Shopping Cart

+
+
+
+
+
+ + +(feed) +
+
+ + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/shopping-cart.py b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/shopping-cart.py new file mode 100644 index 0000000000..1dac82522f --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/shopping-cart.py @@ -0,0 +1,75 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Shopping cart implementation +import uuid +import sys + +cartId = "1234" + +# Get the shopping cart from the cache +# Return an empty cart if not found +def getcart(id, cache): + cart = cache.get((id,)) + if cart is None: + return () + return cart + +# Post a new item to the cart, create a new cart if necessary +def post(collection, item, cache): + id = str(uuid.uuid1()) + cart = (("'entry", item[0][1], ("'id", id), item[0][3]),) + getcart(cartId, cache) + cache.put((cartId,), cart) + return (id,) + + +# Find an item in the cart +def find(id, cart): + if cart == (): + return (("'entry", ("'title", "Item"), ("'id", 0)),) + elif id == cart[0][2][1]: + return (cart[0],) + else: + return find(id, cart[1:]) + +# Get items from the cart +def get(id, cache): + if id == (): + return ((("'feed", ("'title", "Your Cart"), ("'id", cartId)) + getcart(cartId, cache)),) + return find(id[0], getcart(cartId, cache)) + +# Delete items from the cart +def delete(id, cache): + if id == (): + return cache.delete((cartId,)) + return True + +# Return the price of an item +def price(item): + return float(filter(lambda x: x[0] == "'price", item[3][1][1:])[0][1]) + +# Sum the prices of a list of items +def sum(items): + if items == (): + return 0 + return price(items[0]) + sum(items[1:]) + +# Return the total price of the items in the cart +def total(cache): + cart = getcart(cartId, cache) + return sum(cart) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/store.composite b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/store.composite new file mode 100644 index 0000000000..58e5832bcf --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/store.composite @@ -0,0 +1,61 @@ + + + + + + + + + + + + + + + + + USD + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/store.py b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/store.py new file mode 100644 index 0000000000..ff82f1d327 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-vhost/domains/joe/store.py @@ -0,0 +1,40 @@ +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# Store implementation + +def post(item, catalog, shoppingCart, shoppingTotal): + return shoppingCart.post(item) + +def getall(catalog, shoppingCart, shoppingTotal): + return shoppingCart.getall() + +def get(id, catalog, shoppingCart, shoppingTotal): + return shoppingCart.get(id) + +def items(catalog, shoppingCart, shoppingTotal): + return catalog.items() + +def total(catalog, shoppingCart, shoppingTotal): + return shoppingCart.total() + +def deleteall(catalog, shoppingCart, shoppingTotal): + return shoppingCart.deleteall() + +def delete(id, catalog, shoppingCart, shoppingTotal): + return shoppingCart.delete(id) + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-vhost/htdocs/index.html b/sca-cpp/branches/lightweight-sca/samples/store-vhost/htdocs/index.html new file mode 100644 index 0000000000..fc377e5b61 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-vhost/htdocs/index.html @@ -0,0 +1,39 @@ + + + + + + + +Store + + + +

Store

+
+

For this sample to work, add the sample domain to your /etc/hosts as follows:
+127.0.0.1 example.com jane.example.com joe.example.com

+ +

+

Jane's store at jane.example.com +
Joe's store at joe.example.com

+ + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-vhost/server-test b/sca-cpp/branches/lightweight-sca/samples/store-vhost/server-test new file mode 100755 index 0000000000..4d8c7a9129 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-vhost/server-test @@ -0,0 +1,61 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +echo "Testing..." +here=`echo "import os; print os.path.realpath('$0')" | python`; here=`dirname $here` +curl_prefix=`cat $here/../../modules/http/curl.prefix` + +# Setup +./start +sleep 2 + +# For this test to work, add the test domain to your etc/hosts as follows: +# 127.0.0.1 example.com joe.example.com joe.example.com + +# Test HTTP GET +$curl_prefix/bin/curl http://joe.example.com:8090/ 2>/dev/null >tmp/index.html +diff tmp/index.html htdocs/domains/joe/index.html +rc=$? + +# Test Catalog +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://joe.example.com:8090/references/Store/catalog -X POST -H "Content-type: application/json-rpc" --data @../store-cpp/htdocs/test/items-request.txt >tmp/items-result.txt 2>/dev/null + diff tmp/items-result.txt ../store-cpp/htdocs/test/items-result.txt + rc=$? +fi + +# Test Shopping Cart +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://joe.example.com:8090/references/Store/shoppingCart -X POST -H "Content-type: application/atom+xml" --data @../store-cpp/htdocs/test/shopping-cart-entry.xml 2>/dev/null + rc=$? +fi +if [ "$rc" = "0" ]; then + $curl_prefix/bin/curl http://joe.example.com:8090/references/Store/shoppingCart >tmp/shopping-cart-feed.xml 2>/dev/null + grep "3.55" tmp/shopping-cart-feed.xml >/dev/null + rc=$? +fi + +# Cleanup +./stop +sleep 2 + +if [ "$rc" = "0" ]; then + echo "OK" +fi +exit $rc diff --git a/sca-cpp/branches/lightweight-sca/samples/store-vhost/shared/shared.composite b/sca-cpp/branches/lightweight-sca/samples/store-vhost/shared/shared.composite new file mode 100644 index 0000000000..3183891ade --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-vhost/shared/shared.composite @@ -0,0 +1,32 @@ + + + + + + + + + + localhost:11211 + + + diff --git a/sca-cpp/branches/lightweight-sca/samples/store-vhost/ssl-start b/sca-cpp/branches/lightweight-sca/samples/store-vhost/ssl-start new file mode 100755 index 0000000000..528c0a5e73 --- /dev/null +++ b/sca-cpp/branches/lightweight-sca/samples/store-vhost/ssl-start @@ -0,0 +1,48 @@ +#!/bin/sh + +# Licensed to the Apache Software Foundation (ASF) under one +# or more contributor license agreements. See the NOTICE file +# distributed with this work for additional information +# regarding copyright ownership. The ASF licenses this file +# to you under the Apache License, Version 2.0 (the +# "License"); you may not use this file except in compliance +# with the License. You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, +# software distributed under the License is distributed on an +# "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY +# KIND, either express or implied. See the License for the +# specific language governing permissions and limitations +# under the License. + +# For this sample to work, add the sample domain to your /etc/hosts as follows: +# 127.0.0.1 example.com jane.example.com joe.example.com + +../../modules/http/ssl-ca-conf tmp example.com +../../modules/http/ssl-cert-conf tmp example.com server +../../modules/http/ssl-cert-conf tmp *.example.com vhost +../../modules/http/httpd-conf tmp example.com 8090 htdocs +../../modules/http/httpd-event-conf tmp +../../modules/http/mass-host-conf tmp domains htdocs +../../modules/http/httpd-ssl-conf tmp 8453 +../../modules/http/mass-host-ssl-conf tmp +../../modules/http/basic-auth-conf tmp +../../modules/http/passwd-auth-conf tmp foo foo +../../modules/server/server-conf tmp +../../modules/python/python-conf tmp +cat >>tmp/conf/httpd.conf <>tmp/conf/httpd.conf <>tmp/conf/httpd.conf <