summaryrefslogtreecommitdiffstats
path: root/sca-cpp/trunk/modules/server/mod-eval.hpp
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--sca-cpp/trunk/modules/server/mod-eval.hpp47
1 files changed, 35 insertions, 12 deletions
diff --git a/sca-cpp/trunk/modules/server/mod-eval.hpp b/sca-cpp/trunk/modules/server/mod-eval.hpp
index 03cce5aeb4..f319942f8d 100644
--- a/sca-cpp/trunk/modules/server/mod-eval.hpp
+++ b/sca-cpp/trunk/modules/server/mod-eval.hpp
@@ -104,15 +104,22 @@ const failable<int> get(request_rec* r, const lambda<value(const list<value>&)>&
return httpd::writeResult(json::jsonResult(id, content(val), cx), "application/json-rpc", r);
}
- // Evaluate the GET expression and return an ATOM entry or feed representing a resource
+ // Evaluate the GET expression
const list<value> path(pathValues(r->uri));
const failable<value> val = failableResult(impl(cons<value>("get", mklist<value>(cddr(path)))));
if (!hasContent(val))
return mkfailure<int>(reason(val));
+ const value c = content(val);
+
+ // Write returned content-type / content-list pair
+ if (isList(cadr<value>(c)))
+ return httpd::writeResult(convertValues<string>(cadr<value>(c)), car<value>(c), r);
+
+ // Write returned ATOM feed or entry
if (isNil(cddr(path)))
- return httpd::writeResult(atom::writeATOMFeed(atom::feedValuesToElements(content(val))), "application/atom+xml;type=feed", r);
+ return httpd::writeResult(atom::writeATOMFeed(atom::feedValuesToElements(c)), "application/atom+xml;type=feed", r);
else
- return httpd::writeResult(atom::writeATOMEntry(atom::entryValuesToElements(content(val))), "application/atom+xml;type=entry", r);
+ return httpd::writeResult(atom::writeATOMEntry(atom::entryValuesToElements(c)), "application/atom+xml;type=entry", r);
}
/**
@@ -375,7 +382,7 @@ const failable<list<value> > applyLifecycleExpr(const list<value>& impls, const
/**
* Configure the components declared in the deployed composite.
*/
-const failable<bool> confComponents(const string& lifecycle, ServerConf& sc, server_rec& server) {
+const failable<bool> confComponents(ServerConf& sc, server_rec& server) {
if (sc.contributionPath == "" || sc.compositeName == "")
return false;
@@ -383,20 +390,29 @@ const failable<bool> confComponents(const string& lifecycle, ServerConf& sc, ser
const failable<list<value> > comps = readComponents(sc.contributionPath + sc.compositeName);
if (!hasContent(comps))
return mkfailure<bool>(reason(comps));
- const list<value> starts = componentToImplementationAssoc(sc, server, content(comps));
+ sc.implementations = componentToImplementationAssoc(sc, server, content(comps));
+ debug(sc.implementations, "modeval::confComponents::implementations");
+
+ // Store the implementation lambda functions in a tree for fast retrieval
+ sc.implTree = mkbtree(sort(sc.implementations));
+ return true;
+}
+
+/**
+ * Start the components declared in the deployed composite.
+ */
+const failable<bool> startComponents(ServerConf& sc) {
- // Start or restart the component implementations
- // Record the returned lambda functions
- debug(starts, "modeval::confComponents::start");
- const failable<list<value> > impls = applyLifecycleExpr(starts, mklist<value>(c_str(lifecycle)));
+ // Start the components and record the returned implementation lambda functions
+ debug(sc.implementations, "modeval::startComponents::start");
+ const failable<list<value> > impls = applyLifecycleExpr(sc.implementations, mklist<value>("start"));
if (!hasContent(impls))
return mkfailure<bool>(reason(impls));
sc.implementations = content(impls);
- debug(sc.implementations, "modeval::confComponents::implementations");
+ debug(sc.implementations, "modeval::startComponents::implementations");
// Store the implementation lambda functions in a tree for fast retrieval
sc.implTree = mkbtree(sort(sc.implementations));
-
return true;
}
@@ -458,7 +474,7 @@ int postConfig(apr_pool_t *p, unused apr_pool_t *plog, unused apr_pool_t *ptemp,
debug(sc.wiringServerName, "modeval::postConfig::wiringServerName");
debug(sc.contributionPath, "modeval::postConfig::contributionPath");
debug(sc.compositeName, "modeval::postConfig::compositeName");
- const failable<bool> res = confComponents(count > 1? "restart" : "start", sc, *s);
+ const failable<bool> res = confComponents(sc, *s);
if (!hasContent(res)) {
cerr << "[Tuscany] Due to one or more errors mod_tuscany_eval loading failed. Causing apache to stop loading." << endl;
return -1;
@@ -481,6 +497,13 @@ void childInit(apr_pool_t* p, server_rec* s) {
exit(APEXIT_CHILDFATAL);
}
+ // Start the components in the child process
+ const failable<bool> res = startComponents(*sc);
+ if (!hasContent(res)) {
+ cerr << "[Tuscany] Due to one or more errors mod_tuscany_eval loading failed. Causing apache to stop loading." << endl;
+ exit(APEXIT_CHILDFATAL);
+ }
+
// Register a cleanup callback, called when the child is stopped or restarted
apr_pool_pre_cleanup_register(p, (void*)sc, serverCleanup);
}