diff options
author | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-01-17 09:02:39 +0000 |
---|---|---|
committer | jsdelfino <jsdelfino@13f79535-47bb-0310-9956-ffa450edef68> | 2010-01-17 09:02:39 +0000 |
commit | e34c4a9109bbbb28d7ecef7cccccdc537008f8a5 (patch) | |
tree | f1d946b5401763a306068cc7bbfad4ac7d489d8e /sca-cpp/trunk/modules/java/mod-java.hpp | |
parent | b00fe2747627bc95ac8d1d548e0621930a1775a2 (diff) |
Integrated Java component support as an HTTPD module. Added test case and store scenario skeleton.
git-svn-id: http://svn.us.apache.org/repos/asf/tuscany@900072 13f79535-47bb-0310-9956-ffa450edef68
Diffstat (limited to 'sca-cpp/trunk/modules/java/mod-java.hpp')
-rw-r--r-- | sca-cpp/trunk/modules/java/mod-java.hpp | 78 |
1 files changed, 78 insertions, 0 deletions
diff --git a/sca-cpp/trunk/modules/java/mod-java.hpp b/sca-cpp/trunk/modules/java/mod-java.hpp new file mode 100644 index 0000000000..933550b7c3 --- /dev/null +++ b/sca-cpp/trunk/modules/java/mod-java.hpp @@ -0,0 +1,78 @@ +/* + * 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$ */ + +#ifndef tuscany_modjava_hpp +#define tuscany_modjava_hpp + +/** + * Evaluation functions used by mod-eval to evaluate Java + * component implementations. + */ + +#include "string.hpp" +#include "stream.hpp" +#include "function.hpp" +#include "list.hpp" +#include "value.hpp" +#include "monad.hpp" +#include "eval.hpp" +#include "../http/httpd.hpp" + +namespace tuscany { +namespace server { +namespace modjava { + +/** + * Apply a Java component implementation function. + */ +struct applyImplementation { + java::JavaClass impl; + const list<value> px; + applyImplementation(const java::JavaClass& 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::java::applyImplementation::input"); + const failable<value> val = java::evalClass(java::javaRuntime, expr, impl); + debug(val, "modeval::java::applyImplementation::result"); + if (!hasContent(val)) + return mklist<value>(value(), reason(val)); + return mklist<value>(content(val)); + } +}; + +/** + * Evaluate a Java component implementation and convert it to an applicable + * lambda function. + */ +const failable<lambda<value(const list<value>&)> > evalImplementation(unused const string& path, const value& impl, const list<value>& px) { + const string cn(attributeValue("class", impl)); + const failable<java::JavaClass> jc = java::readClass(java::javaRuntime, cn); + if (!hasContent(jc)) + return mkfailure<lambda<value(const list<value>&)> >(reason(jc)); + return lambda<value(const list<value>&)>(applyImplementation(content(jc), px)); +} + +} +} +} + +#endif /* tuscany_modjava_hpp */ |