diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-02-17 04:14:31 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-02-17 04:14:31 +0000 |
commit | 00438314438f3dde00b532ac5d8d28ccc35c7096 (patch) | |
tree | 80dbbb010c5125455a164c77670b8694231f123f /sca-cpp/trunk/modules/java/mod-java.cpp | |
parent | 50063bc212e8e93d014519ef0e4d4cabef0b6be2 (diff) |
Working queue and chat components. Added a few useful start/stop scripts. Fixed lifecycle code to call start/stop/restart functions before APR pools are cleaned up in both parent and child processes. Minor build script improvements.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@910819 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/modules/java/mod-java.cpp')
-rw-r--r-- | sca-cpp/trunk/modules/java/mod-java.cpp | 47 |
1 files changed, 24 insertions, 23 deletions
diff --git a/sca-cpp/trunk/modules/java/mod-java.cpp b/sca-cpp/trunk/modules/java/mod-java.cpp index 4b8e7dca56..510f9574b0 100644 --- a/sca-cpp/trunk/modules/java/mod-java.cpp +++ b/sca-cpp/trunk/modules/java/mod-java.cpp @@ -37,40 +37,41 @@ namespace server { namespace modeval { /** - * Start the module. + * Apply a lifecycle start or restart event. */ -const failable<bool> start(unused ServerConf& sc) { - // Start a Java runtime - sc.moduleConf = new (gc_new<java::JavaRuntime>()) java::JavaRuntime(); - return true; -} +struct javaLifecycle { + javaLifecycle(java::JavaRuntime& jr) : jr(jr) { + } + const value operator()(const list<value>& params) const { + const value func = car(params); + if (func == "javaRuntime") + return (gc_ptr<value>)(value*)(void*)&jr; + return lambda<value(const list<value>&)>(); + } + java::JavaRuntime& jr; +}; -/** - * Stop the module. - */ -const failable<bool> stop(unused ServerConf& sc) { - return true; -} +const value applyLifecycle(unused const list<value>& params) { -/** - * Restart the module. - */ -const failable<bool> restart(ServerConf& sc) { - // Start a Java runtime - sc.moduleConf = new (gc_new<java::JavaRuntime>()) java::JavaRuntime(); - return true; + // Create a Java runtime + java::JavaRuntime& jr = *(new (gc_new<java::JavaRuntime>()) java::JavaRuntime()); + + // Return the function to invoke on subsequent events + return failable<value>(lambda<value(const list<value>&)>(javaLifecycle(jr))); } /** * Evaluate a Java component implementation and convert it to an applicable * lambda function. */ -const failable<lambda<value(const list<value>&)> > evalImplementation(const string& path, const value& impl, const list<value>& px, modeval::ServerConf& sc) { +const failable<lambda<value(const list<value>&)> > evalImplementation(const string& path, const value& impl, const list<value>& px, const lambda<value(const list<value>&)>& lifecycle) { const string itype(elementName(impl)); - if (contains(itype, ".java")) - return modjava::evalImplementation(path, impl, px, sc); + if (contains(itype, ".java")) { + const void* p = (gc_ptr<value>)lifecycle(mklist<value>("javaRuntime")); + return modjava::evalImplementation(path, impl, px, *(java::JavaRuntime*)p); + } if (contains(itype, ".cpp")) - return modcpp::evalImplementation(path, impl, px, sc); + return modcpp::evalImplementation(path, impl, px); return mkfailure<lambda<value(const list<value>&)> >(string("Unsupported implementation type: ") + itype); } |