summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sca-cpp/trunk/modules/python/domain-test.composite4
-rw-r--r--sca-cpp/trunk/modules/python/mod-python.cpp11
-rw-r--r--sca-cpp/trunk/modules/python/mod-python.hpp30
-rw-r--r--sca-cpp/trunk/modules/python/tuscany-sca-1.1-implementation-python.xsd2
-rw-r--r--sca-cpp/trunk/modules/scdl/scdl-test.cpp2
-rw-r--r--sca-cpp/trunk/modules/scdl/test.composite11
-rw-r--r--sca-cpp/trunk/modules/scheme/tuscany-sca-1.1-implementation-scheme.xsd (renamed from sca-cpp/trunk/modules/scheme/tuscany-sca-1.1-implementation-eval.xsd)6
-rw-r--r--sca-cpp/trunk/modules/server/domain-test.composite6
-rw-r--r--sca-cpp/trunk/modules/server/impl-test.cpp2
-rw-r--r--sca-cpp/trunk/modules/server/mod-cpp.hpp31
-rw-r--r--sca-cpp/trunk/modules/server/mod-eval.cpp11
-rw-r--r--sca-cpp/trunk/modules/server/mod-eval.hpp8
-rw-r--r--sca-cpp/trunk/modules/server/mod-scheme.hpp30
13 files changed, 81 insertions, 73 deletions
diff --git a/sca-cpp/trunk/modules/python/domain-test.composite b/sca-cpp/trunk/modules/python/domain-test.composite
index 7318f96520..a0e92dfb0c 100644
--- a/sca-cpp/trunk/modules/python/domain-test.composite
+++ b/sca-cpp/trunk/modules/python/domain-test.composite
@@ -23,14 +23,14 @@
name="domain-test">
<component name="python-test">
- <t:implementation.python uri="server-test.py"/>
+ <t:implementation.python script="server-test.py"/>
<service name="test">
<t:binding.http uri="python"/>
</service>
</component>
<component name="client-test">
- <t:implementation.python uri="client-test.py"/>
+ <t:implementation.python script="client-test.py"/>
<service name="client">
<t:binding.http uri="client"/>
</service>
diff --git a/sca-cpp/trunk/modules/python/mod-python.cpp b/sca-cpp/trunk/modules/python/mod-python.cpp
index 1352c50c11..1c35467b4b 100644
--- a/sca-cpp/trunk/modules/python/mod-python.cpp
+++ b/sca-cpp/trunk/modules/python/mod-python.cpp
@@ -37,14 +37,15 @@ namespace server {
namespace modeval {
/**
- * Return a configured component implementation.
- * For now only Scheme and C++ implementations are supported.
+ * Evaluate a Python component implementation and convert it to an applicable
+ * lambda function.
*/
-const failable<lambda<value(const list<value>&)> > readImplementation(const string& itype, const string& path, const list<value>& px) {
+const failable<lambda<value(const list<value>&)> > evalImplementation(const string& path, const value& impl, const list<value>& px) {
+ const string itype(elementName(impl));
if (contains(itype, ".python"))
- return modpython::readImplementation(path, px);
+ return modpython::evalImplementation(path, impl, px);
if (contains(itype, ".cpp"))
- return modcpp::readImplementation(path, px);
+ return modcpp::evalImplementation(path, impl, px);
return mkfailure<lambda<value(const list<value>&)> >(string("Unsupported implementation type: ") + itype);
}
diff --git a/sca-cpp/trunk/modules/python/mod-python.hpp b/sca-cpp/trunk/modules/python/mod-python.hpp
index a56232d641..e67b9a4a93 100644
--- a/sca-cpp/trunk/modules/python/mod-python.hpp
+++ b/sca-cpp/trunk/modules/python/mod-python.hpp
@@ -23,7 +23,7 @@
#define tuscany_modpython_hpp
/**
- * Evaluation functions used by mod-eval to evaluate implementation.python
+ * Evaluation functions used by mod-eval to evaluate Python
* component implementations.
*/
@@ -41,18 +41,18 @@ namespace server {
namespace modpython {
/**
- * Evaluate a script component implementation function.
+ * Apply a Python component implementation function.
*/
-struct evalImplementation {
+struct applyImplementation {
PyObject* impl;
const list<value> px;
- evalImplementation(PyObject* impl, const list<value>& px) : impl(impl), px(px) {
+ applyImplementation(PyObject* impl, const list<value>& px) : impl(impl), px(px) {
}
const value operator()(const list<value>& params) const {
const value expr = append<value>(params, px);
- debug(expr, "modeval::python::evalImplementation::input");
+ debug(expr, "modeval::python::applyImplementation::input");
const failable<value> val = python::evalScript(expr, impl);
- debug(val, "modeval::python::evalImplementation::result");
+ debug(val, "modeval::python::applyImplementation::result");
if (!hasContent(val))
return mklist<value>(value(), reason(val));
return mklist<value>(content(val));
@@ -60,16 +60,18 @@ struct evalImplementation {
};
/**
- * Read a script component implementation.
+ * Evaluate a Python component implementation and convert it to an applicable
+ * lambda function.
*/
-const failable<lambda<value(const list<value>&)> > readImplementation(const string& path, const list<value>& px) {
- ifstream is(path);
+const failable<lambda<value(const list<value>&)> > evalImplementation(const string& path, const value& impl, const list<value>& px) {
+ const string fpath(path + attributeValue("script", impl));
+ ifstream is(fpath);
if (fail(is))
- return mkfailure<lambda<value(const list<value>&)> >(string("Could not read implementation: ") + path);
- const failable<PyObject*> impl = python::readScript(path, is);
- if (!hasContent(impl))
- return mkfailure<lambda<value(const list<value>&)> >(reason(impl));
- return lambda<value(const list<value>&)>(evalImplementation(content(impl), px));
+ return mkfailure<lambda<value(const list<value>&)> >(string("Could not read implementation: ") + fpath);
+ const failable<PyObject*> script = python::readScript(fpath, is);
+ if (!hasContent(script))
+ return mkfailure<lambda<value(const list<value>&)> >(reason(script));
+ return lambda<value(const list<value>&)>(applyImplementation(content(script), px));
}
}
diff --git a/sca-cpp/trunk/modules/python/tuscany-sca-1.1-implementation-python.xsd b/sca-cpp/trunk/modules/python/tuscany-sca-1.1-implementation-python.xsd
index 95ffc4f743..24d5e224bc 100644
--- a/sca-cpp/trunk/modules/python/tuscany-sca-1.1-implementation-python.xsd
+++ b/sca-cpp/trunk/modules/python/tuscany-sca-1.1-implementation-python.xsd
@@ -34,7 +34,7 @@
<any namespace="##targetNamespace" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</sequence>
- <attribute name="location" type="anyURI" use="required"/>
+ <attribute name="script" type="anyURI" use="required"/>
<anyAttribute namespace="##any" processContents="lax"/>
</extension>
</complexContent>
diff --git a/sca-cpp/trunk/modules/scdl/scdl-test.cpp b/sca-cpp/trunk/modules/scdl/scdl-test.cpp
index d6034d1e2f..e8ee77eb4e 100644
--- a/sca-cpp/trunk/modules/scdl/scdl-test.cpp
+++ b/sca-cpp/trunk/modules/scdl/scdl-test.cpp
@@ -48,7 +48,7 @@ bool testComponents() {
assert(name(store) == string("Store"));
const value impl = implementation(store);
assert(uri(impl) == string("store.html"));
- assert(implementationType(impl) == "t:implementation.widget");
+ assert(implementationType(impl) == "t:implementation.scheme");
const value catalog = named(string("Catalog"), c);
assert(name(catalog) == string("Catalog"));
diff --git a/sca-cpp/trunk/modules/scdl/test.composite b/sca-cpp/trunk/modules/scdl/test.composite
index b315f23f9a..92e8f64ca5 100644
--- a/sca-cpp/trunk/modules/scdl/test.composite
+++ b/sca-cpp/trunk/modules/scdl/test.composite
@@ -23,7 +23,7 @@
name="store">
<component name="Store">
- <t:implementation.widget uri="store.html"/>
+ <t:implementation.scheme script="store.scm"/>
<service name="Widget">
<t:binding.http uri="/store"/>
</service>
@@ -39,7 +39,7 @@
</component>
<component name="Catalog">
- <t:implementation.scheme uri="fruits-catalog.scm"/>
+ <t:implementation.scheme script="fruits-catalog.scm"/>
<property name="currencyCode">USD</property>
<service name="Catalog">
<t:binding.jsonrpc/>
@@ -48,20 +48,17 @@
</component>
<component name="ShoppingCart">
- <t:implementation.scheme uri="shopping-cart.scm"/>
+ <t:implementation.scheme script="shopping-cart.scm"/>
<service name="Cart">
<t:binding.atom uri="/ShoppingCart"/>
</service>
<service name="Total">
<t:binding.jsonrpc/>
</service>
- <reference name="cache">
- <binding.memcached uri="localhost:11311"/>
- </reference>
</component>
<component name="CurrencyConverter">
- <t:implementation.scheme uri="currency-converter.scm"/>
+ <t:implementation.scheme script="currency-converter.scm"/>
</component>
</composite>
diff --git a/sca-cpp/trunk/modules/scheme/tuscany-sca-1.1-implementation-eval.xsd b/sca-cpp/trunk/modules/scheme/tuscany-sca-1.1-implementation-scheme.xsd
index bbf4935346..4c2a30a55a 100644
--- a/sca-cpp/trunk/modules/scheme/tuscany-sca-1.1-implementation-eval.xsd
+++ b/sca-cpp/trunk/modules/scheme/tuscany-sca-1.1-implementation-scheme.xsd
@@ -25,16 +25,16 @@
<import namespace="http://docs.oasis-open.org/ns/opencsa/sca/200903" schemaLocation="sca-1.1-cd04.xsd"/>
- <element name="implementation.eval" type="t:EvalImplementation" substitutionGroup="sca:implementation"/>
+ <element name="implementation.scheme" type="t:SchemeImplementation" substitutionGroup="sca:implementation"/>
- <complexType name="EvalImplementation">
+ <complexType name="SchemeImplementation">
<complexContent>
<extension base="sca:Implementation">
<sequence>
<any namespace="##targetNamespace" processContents="lax"
minOccurs="0" maxOccurs="unbounded"/>
</sequence>
- <attribute name="location" type="anyURI" use="required"/>
+ <attribute name="script" type="anyURI" use="required"/>
<anyAttribute namespace="##any" processContents="lax"/>
</extension>
</complexContent>
diff --git a/sca-cpp/trunk/modules/server/domain-test.composite b/sca-cpp/trunk/modules/server/domain-test.composite
index d5b0dae511..1635f1f6cf 100644
--- a/sca-cpp/trunk/modules/server/domain-test.composite
+++ b/sca-cpp/trunk/modules/server/domain-test.composite
@@ -23,21 +23,21 @@
name="domain-test">
<component name="scheme-test">
- <t:implementation.scheme uri="server-test.scm"/>
+ <t:implementation.scheme script="server-test.scm"/>
<service name="test">
<t:binding.http uri="test"/>
</service>
</component>
<component name="cpp-test">
- <t:implementation.cpp uri=".libs/libimpl-test"/>
+ <implementation.cpp path=".libs" library="libimpl-test"/>
<service name="cpp">
<t:binding.http uri="cpp"/>
</service>
</component>
<component name="client-test">
- <t:implementation.scheme uri="client-test.scm"/>
+ <t:implementation.scheme script="client-test.scm"/>
<service name="client">
<t:binding.http uri="client"/>
</service>
diff --git a/sca-cpp/trunk/modules/server/impl-test.cpp b/sca-cpp/trunk/modules/server/impl-test.cpp
index ad8953bf12..748e5f3837 100644
--- a/sca-cpp/trunk/modules/server/impl-test.cpp
+++ b/sca-cpp/trunk/modules/server/impl-test.cpp
@@ -58,7 +58,7 @@ const failable<value> echo(const list<value>& params) {
extern "C" {
-const tuscany::value eval(const tuscany::list<tuscany::value>& params) {
+const tuscany::value apply(const tuscany::list<tuscany::value>& params) {
const tuscany::value func(car(params));
if (func == "get")
return tuscany::server::get(cdr(params));
diff --git a/sca-cpp/trunk/modules/server/mod-cpp.hpp b/sca-cpp/trunk/modules/server/mod-cpp.hpp
index 416ccabf39..f10b91dc28 100644
--- a/sca-cpp/trunk/modules/server/mod-cpp.hpp
+++ b/sca-cpp/trunk/modules/server/mod-cpp.hpp
@@ -23,7 +23,7 @@
#define tuscany_modcpp_hpp
/**
- * Evaluation functions used by mod-eval to evaluate implementation.cpp
+ * Evaluation functions used by mod-eval to evaluate C++
* component implementations.
*/
@@ -32,6 +32,7 @@
#include "function.hpp"
#include "list.hpp"
+#include "element.hpp"
#include "value.hpp"
#include "monad.hpp"
#include "dynlib.hpp"
@@ -43,31 +44,35 @@ namespace server {
namespace modcpp {
/**
- * Evaluate a C++ component implementation function.
+ * Apply a C++ component implementation function.
*/
-struct evalImplementation {
+struct applyImplementation {
const lib ilib;
const lambda<value(const list<value>&)> impl;
const list<value> px;
- evalImplementation(const lib& ilib, const lambda<value(const list<value>&)>& impl, const list<value>& px) : ilib(ilib), impl(impl), px(px) {
+ applyImplementation(const lib& ilib, const lambda<value(const list<value>&)>& impl, const list<value>& px) : ilib(ilib), impl(impl), px(px) {
}
const value operator()(const list<value>& params) const {
- debug(params, "modeval::cpp::evalImplementation::input");
+ debug(params, "modeval::cpp::applyImplementation::input");
const value val = impl(append(params, px));
- debug(val, "modeval::cpp::evalImplementation::result");
+ debug(val, "modeval::cpp::applyImplementation::result");
return val;
}
};
/**
- * Read a C++ component implementation.
+ * Evaluate a C++ component implementation and convert it to
+ * an applicable lambda function.
*/
-const failable<lambda<value(const list<value>&)> > readImplementation(const string& path, const list<value>& px) {
- const lib ilib(*(new (gc_new<lib>()) lib(path + dynlibExt)));
- const failable<lambda<value(const list<value>&)> > impl(dynlambda<value(const list<value>&)>("eval", ilib));
- if (!hasContent(impl))
- return impl;
- return lambda<value(const list<value>&)>(evalImplementation(ilib, content(impl), px));
+const failable<lambda<value(const list<value>&)> > evalImplementation(const string& path, const value& impl, const list<value>& px) {
+ const value ipath(attributeValue("path", impl));
+ const value iname(attributeValue("library", impl));
+ const string fpath(isNil(ipath)? path + iname : path + ipath + "/" + iname);
+ const lib ilib(*(new (gc_new<lib>()) lib(fpath + dynlibExt)));
+ const failable<lambda<value(const list<value>&)> > evalf(dynlambda<value(const list<value>&)>("apply", ilib));
+ if (!hasContent(evalf))
+ return evalf;
+ return lambda<value(const list<value>&)>(applyImplementation(ilib, content(evalf), px));
}
}
diff --git a/sca-cpp/trunk/modules/server/mod-eval.cpp b/sca-cpp/trunk/modules/server/mod-eval.cpp
index 936c68d70f..54ca171ec4 100644
--- a/sca-cpp/trunk/modules/server/mod-eval.cpp
+++ b/sca-cpp/trunk/modules/server/mod-eval.cpp
@@ -37,14 +37,15 @@ namespace server {
namespace modeval {
/**
- * Return a configured component implementation.
- * For now only Scheme and C++ implementations are supported.
+ * Evaluate a Scheme or C++ component implementation and convert it to an
+ * applicable lambda function.
*/
-const failable<lambda<value(const list<value>&)> > readImplementation(const string& itype, const string& path, const list<value>& px) {
+const failable<lambda<value(const list<value>&)> > evalImplementation(const string& path, const value& impl, const list<value>& px) {
+ const string itype(elementName(impl));
if (contains(itype, ".scheme"))
- return modscheme::readImplementation(path, px);
+ return modscheme::evalImplementation(path, impl, px);
if (contains(itype, ".cpp"))
- return modcpp::readImplementation(path, px);
+ return modcpp::evalImplementation(path, impl, px);
return mkfailure<lambda<value(const list<value>&)> >(string("Unsupported implementation type: ") + itype);
}
diff --git a/sca-cpp/trunk/modules/server/mod-eval.hpp b/sca-cpp/trunk/modules/server/mod-eval.hpp
index 4f95977fea..f5c4266cc1 100644
--- a/sca-cpp/trunk/modules/server/mod-eval.hpp
+++ b/sca-cpp/trunk/modules/server/mod-eval.hpp
@@ -279,11 +279,10 @@ const list<value> proxies(const list<value>& refs, const string& base) {
return cons(mkproxy(car(refs), base), proxies(cdr(refs), base));
}
-extern const failable<lambda<value(const list<value>&)> > readImplementation(const string& itype, const string& path, const list<value>& px);
+extern const failable<lambda<value(const list<value>&)> > evalImplementation(const string& cpath, const value& impl, const list<value>& px);
const value confImplementation(DirConf& dc, ServerConf& sc, server_rec& server, const value& comp) {
const value impl = scdl::implementation(comp);
- const string path = dc.contributionPath + string(scdl::uri(impl));
// Convert component references to configured proxy lambdas
ostringstream base;
@@ -296,8 +295,9 @@ const value confImplementation(DirConf& dc, ServerConf& sc, server_rec& server,
base << sc.wiringServerName << "/references/" << string(scdl::name(comp)) << "/";
const list<value> px(proxies(scdl::references(comp), str(base)));
- // Read and configure the implementation
- const failable<lambda<value(const list<value>&)> > cimpl(readImplementation(elementName(impl), path, px));
+ // Evaluate the component implementation and convert it to an
+ // applicable lambda function
+ const failable<lambda<value(const list<value>&)> > cimpl(evalImplementation(dc.contributionPath, impl, px));
if (!hasContent(cimpl))
return reason(cimpl);
return content(cimpl);
diff --git a/sca-cpp/trunk/modules/server/mod-scheme.hpp b/sca-cpp/trunk/modules/server/mod-scheme.hpp
index 5c6ea9ef7d..fd03ebb43e 100644
--- a/sca-cpp/trunk/modules/server/mod-scheme.hpp
+++ b/sca-cpp/trunk/modules/server/mod-scheme.hpp
@@ -23,7 +23,7 @@
#define tuscany_modscheme_hpp
/**
- * Evaluation functions used by mod-eval to evaluate implementation.scheme
+ * Evaluation functions used by mod-eval to evaluate Scheme
* component implementations.
*/
@@ -50,19 +50,19 @@ const list<value> primitiveProcedures(const list<value>& l) {
}
/**
- * Evaluate a scheme component implementation function.
+ * Apply a Scheme component implementation function.
*/
-struct evalImplementation {
+struct applyImplementation {
const value impl;
const list<value> px;
- evalImplementation(const value& impl, const list<value>& px) : impl(impl), px(scheme::quotedParameters(primitiveProcedures(px))) {
+ applyImplementation(const value& impl, const list<value>& px) : impl(impl), px(scheme::quotedParameters(primitiveProcedures(px))) {
}
const value operator()(const list<value>& params) const {
const value expr = cons<value>(car(params), append(scheme::quotedParameters(cdr(params)), px));
- debug(expr, "modeval::scheme::evalImplementation::input");
+ debug(expr, "modeval::scheme::applyImplementation::input");
scheme::Env env = scheme::setupEnvironment();
const value val = scheme::evalScript(expr, impl, env);
- debug(val, "modeval::scheme::evalImplementation::result");
+ debug(val, "modeval::scheme::applyImplementation::result");
if (isNil(val))
return mklist<value>(value(), string("Could not evaluate expression"));
return mklist<value>(val);
@@ -70,16 +70,18 @@ struct evalImplementation {
};
/**
- * Read a scheme component implementation.
+ * Evaluate a Scheme component implementation and convert it to an
+ * applicable lambda function.
*/
-const failable<lambda<value(const list<value>&)> > readImplementation(const string& path, const list<value>& px) {
- ifstream is(path);
+const failable<lambda<value(const list<value>&)> > evalImplementation(const string& path, const value& impl, const list<value>& px) {
+ const string fpath(path + attributeValue("script", impl));
+ ifstream is(fpath);
if (fail(is))
- return mkfailure<lambda<value(const list<value>&)> >(string("Could not read implementation: ") + path);
- const value impl = scheme::readScript(is);
- if (isNil(impl))
- return mkfailure<lambda<value(const list<value>&)> >(string("Could not read implementation: ") + path);
- return lambda<value(const list<value>&)>(evalImplementation(impl, px));
+ return mkfailure<lambda<value(const list<value>&)> >(string("Could not read implementation: ") + fpath);
+ const value script = scheme::readScript(is);
+ if (isNil(script))
+ return mkfailure<lambda<value(const list<value>&)> >(string("Could not read implementation: ") + fpath);
+ return lambda<value(const list<value>&)>(applyImplementation(script, px));
}
}