From de5a3e20aa493e9bfad8ea32deb2f3bd7e4ff2be Mon Sep 17 00:00:00 2001 From: jsdelfino Date: Tue, 24 Aug 2010 04:51:25 +0000 Subject: Support local in-process function proxies between components contributed by a virtual host and the main host. git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@988384 13f79535-47bb-0310-9956-ffa450edef68 --- sca-cpp/trunk/modules/server/mod-eval.hpp | 53 ++++++++++++---------- .../store-cluster/domains/jane/store.composite | 4 +- .../store-cluster/domains/joe/store.composite | 4 +- 3 files changed, 31 insertions(+), 30 deletions(-) diff --git a/sca-cpp/trunk/modules/server/mod-eval.hpp b/sca-cpp/trunk/modules/server/mod-eval.hpp index 5eb9d5af72..e573d9a1fd 100644 --- a/sca-cpp/trunk/modules/server/mod-eval.hpp +++ b/sca-cpp/trunk/modules/server/mod-eval.hpp @@ -512,9 +512,6 @@ const failable confComponents(ServerConf& sc) { return mkfailure(reason(comps)); sc.implementations = componentToImplementationAssoc(sc, 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; } @@ -530,9 +527,6 @@ const failable startComponents(ServerConf& sc) { return mkfailure(reason(impls)); sc.implementations = content(impls); 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; } @@ -560,40 +554,47 @@ public: /** * Configure and start the components deployed in a virtual host. */ -const failable virtualHostConfig(ServerConf& sc, request_rec* r) { +const failable virtualHostConfig(ServerConf& vsc, const ServerConf& sc, request_rec* r) { extern const value applyLifecycle(const list&); // Determine the server name and wiring server name - debug(httpd::serverName(sc.server), "modeval::virtualHostConfig::serverName"); + debug(httpd::serverName(vsc.server), "modeval::virtualHostConfig::serverName"); debug(httpd::serverName(r), "modeval::virtualHostConfig::virtualHostName"); - sc.wiringServerName = httpd::serverName(r); - debug(sc.wiringServerName, "modeval::virtualHostConfig::wiringServerName"); - debug(sc.virtualHostContributionPath, "modwiring::virtualHostConfig::virtualHostContributionPath"); + vsc.wiringServerName = httpd::serverName(r); + debug(vsc.wiringServerName, "modeval::virtualHostConfig::wiringServerName"); + debug(vsc.virtualHostContributionPath, "modwiring::virtualHostConfig::virtualHostContributionPath"); // Resolve the configured virtual contribution under // the virtual host's SCA contribution root - sc.contributionPath = sc.virtualHostContributionPath + httpd::subdomain(httpd::hostName(r)) + "/"; - sc.compositeName = sc.virtualHostCompositeName; + vsc.contributionPath = vsc.virtualHostContributionPath + httpd::subdomain(httpd::hostName(r)) + "/"; + vsc.compositeName = vsc.virtualHostCompositeName; // Configure the deployed components - const failable cr = confComponents(sc); + const failable cr = confComponents(vsc); if (!hasContent(cr)) return cr; // Start the configured components - return startComponents(sc); + const failable sr = startComponents(vsc); + if (!hasContent(sr)) + return sr; + + // Store the implementation lambda functions (from both the virtual host and the + // main server) in a tree for fast retrieval + vsc.implTree = mkbtree(sort(append(vsc.implementations, sc.implementations))); + return true; } /** * Cleanup a virtual host. */ -const failable virtualHostCleanup(const ServerConf& sc) { - if (!hasCompositeConf(sc)) +const failable virtualHostCleanup(const ServerConf& vsc) { + if (!hasCompositeConf(vsc)) return true; debug("modeval::virtualHostCleanup"); // Stop the component implementations - applyLifecycleExpr(sc.implementations, mklist("stop")); + applyLifecycleExpr(vsc.implementations, mklist("stop")); return true; } @@ -617,7 +618,7 @@ int handler(request_rec *r) { VirtualHostConf vhc(gc_pool(r->pool), sc); const bool usevh = hasVirtualCompositeConf(vhc.sc) && httpd::isVirtualHostRequest(sc.server, r); if (usevh) { - const failable cr = virtualHostConfig(vhc.sc, r); + const failable cr = virtualHostConfig(vhc.sc, sc, r); if (!hasContent(cr)) return httpd::reportStatus(mkfailure(reason(cr))); } @@ -742,24 +743,28 @@ int postConfig(apr_pool_t *p, unused apr_pool_t *plog, unused apr_pool_t *ptemp, */ void childInit(apr_pool_t* p, server_rec* s) { gc_scoped_pool pool(p); - ServerConf* sc = (ServerConf*)ap_get_module_config(s->module_config, &mod_tuscany_eval); - if(sc == NULL) { + ServerConf* psc = (ServerConf*)ap_get_module_config(s->module_config, &mod_tuscany_eval); + if(psc == NULL) { cfailure << "[Tuscany] Due to one or more errors mod_tuscany_eval loading failed. Causing apache to stop loading." << endl; exit(APEXIT_CHILDFATAL); } + ServerConf& sc = *psc; // Start the components in the child process - const failable res = startComponents(*sc); + const failable res = startComponents(sc); if (!hasContent(res)) { cfailure << "[Tuscany] Due to one or more errors mod_tuscany_eval loading failed. Causing apache to stop loading." << endl; exit(APEXIT_CHILDFATAL); } + // Store the implementation lambda functions in a tree for fast retrieval + sc.implTree = mkbtree(sort(sc.implementations)); + // Merge the updated configuration into the virtual hosts - postConfigMerge(*sc, s->next); + postConfigMerge(sc, s->next); // Register a cleanup callback, called when the child is stopped or restarted - apr_pool_pre_cleanup_register(p, (void*)sc, serverCleanup); + apr_pool_pre_cleanup_register(p, (void*)psc, serverCleanup); } /** diff --git a/sca-cpp/trunk/samples/store-cluster/domains/jane/store.composite b/sca-cpp/trunk/samples/store-cluster/domains/jane/store.composite index be67d20955..137027a50c 100644 --- a/sca-cpp/trunk/samples/store-cluster/domains/jane/store.composite +++ b/sca-cpp/trunk/samples/store-cluster/domains/jane/store.composite @@ -51,9 +51,7 @@ - - - + diff --git a/sca-cpp/trunk/samples/store-cluster/domains/joe/store.composite b/sca-cpp/trunk/samples/store-cluster/domains/joe/store.composite index be67d20955..137027a50c 100644 --- a/sca-cpp/trunk/samples/store-cluster/domains/joe/store.composite +++ b/sca-cpp/trunk/samples/store-cluster/domains/joe/store.composite @@ -51,9 +51,7 @@ - - - + -- cgit v1.2.3