diff options
Diffstat (limited to 'sca-cpp/trunk')
20 files changed, 386 insertions, 22 deletions
diff --git a/sca-cpp/trunk/components/Makefile.am b/sca-cpp/trunk/components/Makefile.am index 0f1cd48197..e4a0f051f0 100644 --- a/sca-cpp/trunk/components/Makefile.am +++ b/sca-cpp/trunk/components/Makefile.am @@ -15,7 +15,7 @@ # specific language governing permissions and limitations # under the License. -SUBDIRS = cache store webservice +SUBDIRS = cache chat log queue store webservice includedir = $(prefix)/include/components nobase_include_HEADERS = */*.hpp diff --git a/sca-cpp/trunk/components/chat/Makefile.am b/sca-cpp/trunk/components/chat/Makefile.am new file mode 100644 index 0000000000..09cb5fa26a --- /dev/null +++ b/sca-cpp/trunk/components/chat/Makefile.am @@ -0,0 +1,20 @@ +# 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. + +if WANT_STORE + +endif diff --git a/sca-cpp/trunk/components/chat/chat.composite b/sca-cpp/trunk/components/chat/chat.composite new file mode 100644 index 0000000000..8b797bf75b --- /dev/null +++ b/sca-cpp/trunk/components/chat/chat.composite @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. +--> +<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" + xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1" + targetNamespace="http://tuscany.apache.org/xmlns/sca/components" + name="chat"> + + <component name="chat"> + <implementation.cpp path=".libs" library="libchat"/> + <property name="jid">sample@apache.org</property> + <service name="chat"> + <t:binding.http uri="chat"/> + </service> + </component> + +</composite> diff --git a/sca-cpp/trunk/components/log/Makefile.am b/sca-cpp/trunk/components/log/Makefile.am new file mode 100644 index 0000000000..de5c2d1b1e --- /dev/null +++ b/sca-cpp/trunk/components/log/Makefile.am @@ -0,0 +1,17 @@ +# 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. + diff --git a/sca-cpp/trunk/components/log/log.composite b/sca-cpp/trunk/components/log/log.composite new file mode 100644 index 0000000000..2b0a557e4e --- /dev/null +++ b/sca-cpp/trunk/components/log/log.composite @@ -0,0 +1,33 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. +--> +<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" + xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1" + targetNamespace="http://tuscany.apache.org/xmlns/sca/components" + name="log"> + + <component name="log"> + <implementation.cpp path=".libs" library="liblog"/> + <property name="file">sample.log</property>property> + <service name="log"> + <t:binding.http uri="log"/> + </service> + </component> + +</composite> diff --git a/sca-cpp/trunk/components/queue/Makefile.am b/sca-cpp/trunk/components/queue/Makefile.am new file mode 100644 index 0000000000..b2a9b3819e --- /dev/null +++ b/sca-cpp/trunk/components/queue/Makefile.am @@ -0,0 +1,20 @@ +# 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. + +if WANT_QUEUE + +endif diff --git a/sca-cpp/trunk/components/queue/queue.composite b/sca-cpp/trunk/components/queue/queue.composite new file mode 100644 index 0000000000..c60427dcc5 --- /dev/null +++ b/sca-cpp/trunk/components/queue/queue.composite @@ -0,0 +1,46 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. +--> +<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" + xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1" + targetNamespace="http://tuscany.apache.org/xmlns/sca/components" + name="queue"> + + <component name="queue-sender"> + <implementation.cpp path=".libs" library="libqueue-sender"/> + <property name="uri">amqp://localhost:5672/print</property> + <service name="queue-sender"> + <t:binding.http uri="print-sender"/> + </service> + </component> + + <component name="queue-listener"> + <implementation.cpp path=".libs" library="libqueue-listener"/> + <property name="uri">amqp://localhost:5672/print</property> + <reference name="relay" target="print"/> + </component> + + <component name="print"> + <t:implementation.scheme script="print.scm"/> + <service name="print"> + <t:binding.http uri="print"/> + </service> + </component> + +</composite> diff --git a/sca-cpp/trunk/components/store/Makefile.am b/sca-cpp/trunk/components/store/Makefile.am index 9270d00bc7..09cb5fa26a 100644 --- a/sca-cpp/trunk/components/store/Makefile.am +++ b/sca-cpp/trunk/components/store/Makefile.am @@ -15,5 +15,6 @@ # specific language governing permissions and limitations # under the License. -INCLUDES = -I. -I$(top_builddir)/kernel -I${LIBXML2_INCLUDE} -I${APR_INCLUDE} +if WANT_STORE +endif diff --git a/sca-cpp/trunk/components/store/store.composite b/sca-cpp/trunk/components/store/store.composite new file mode 100644 index 0000000000..ccfd61fc4d --- /dev/null +++ b/sca-cpp/trunk/components/store/store.composite @@ -0,0 +1,32 @@ +<?xml version="1.0" encoding="UTF-8"?> +<!-- + * 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. +--> +<composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" + xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1" + targetNamespace="http://tuscany.apache.org/xmlns/sca/components" + name="store"> + + <component name="store"> + <implementation.cpp path=".libs" library="libstore"/> + <service name="store"> + <t:binding.http uri="store"/> + </service> + </component> + +</composite> diff --git a/sca-cpp/trunk/components/webservice/Makefile.am b/sca-cpp/trunk/components/webservice/Makefile.am index fd85cf4cb0..8d6a9a7879 100644 --- a/sca-cpp/trunk/components/webservice/Makefile.am +++ b/sca-cpp/trunk/components/webservice/Makefile.am @@ -22,10 +22,13 @@ noinst_PROGRAMS = axiom-test axis2-test client-test INCLUDES = -I${AXIS2C_INCLUDE} compdir=$(prefix)/components/webservice -comp_LTLIBRARIES = libwebservice.la +comp_LTLIBRARIES = libwebservice-client.la libwebservice-listener.la -libwebservice_la_SOURCES = webservice.cpp -libwebservice_la_LDFLAGS = -lxml2 -L${AXIS2C_LIB} -R${AXIS2C_LIB} -laxis2_engine +libwebservice_client_la_SOURCES = webservice-client.cpp +libwebservice_client_la_LDFLAGS = -lxml2 -L${AXIS2C_LIB} -R${AXIS2C_LIB} -laxis2_engine + +libwebservice_listener_la_SOURCES = webservice-listener.cpp +libwebservice_listener_la_LDFLAGS = -lxml2 -L${AXIS2C_LIB} -R${AXIS2C_LIB} -laxis2_engine axiom_test_SOURCES = axiom-test.cpp axiom_test_LDFLAGS = -lxml2 -L${AXIS2C_LIB} -R${AXIS2C_LIB} -laxis2_engine diff --git a/sca-cpp/trunk/components/webservice/axiom-test.cpp b/sca-cpp/trunk/components/webservice/axiom-test.cpp index c52183ea9b..a3ab8e7e8f 100644 --- a/sca-cpp/trunk/components/webservice/axiom-test.cpp +++ b/sca-cpp/trunk/components/webservice/axiom-test.cpp @@ -31,7 +31,7 @@ #include "monad.hpp" #include "value.hpp" #include "perf.hpp" -#include "webservice.hpp" +#include "axis2.hpp" namespace tuscany { namespace webservice { diff --git a/sca-cpp/trunk/components/webservice/axis2-test.cpp b/sca-cpp/trunk/components/webservice/axis2-test.cpp index 8ab21bee29..d7c2f3b671 100644 --- a/sca-cpp/trunk/components/webservice/axis2-test.cpp +++ b/sca-cpp/trunk/components/webservice/axis2-test.cpp @@ -31,7 +31,7 @@ #include "monad.hpp" #include "value.hpp" #include "perf.hpp" -#include "webservice.hpp" +#include "axis2.hpp" namespace tuscany { namespace webservice { diff --git a/sca-cpp/trunk/components/webservice/webservice.hpp b/sca-cpp/trunk/components/webservice/axis2.hpp index ba13b9ad7f..ba13b9ad7f 100644 --- a/sca-cpp/trunk/components/webservice/webservice.hpp +++ b/sca-cpp/trunk/components/webservice/axis2.hpp diff --git a/sca-cpp/trunk/components/webservice/client-test.cpp b/sca-cpp/trunk/components/webservice/client-test.cpp index 6e63c83ecb..7c1cd601e0 100644 --- a/sca-cpp/trunk/components/webservice/client-test.cpp +++ b/sca-cpp/trunk/components/webservice/client-test.cpp @@ -36,7 +36,6 @@ namespace tuscany { namespace webservice { -const string url("http://localhost:8090/webservice"); bool testEval() { http::CURLSession cs; @@ -47,7 +46,7 @@ bool testEval() { + (list<value>() + "@xmlns:ns1" + string("http://ws.apache.org/axis2/services/echo")) + (list<value>() + "text" + string("Hello World!"))); - const failable<value> rval = http::evalExpr(mklist<value>(func, arg), url, cs); + const failable<value> rval = http::evalExpr(mklist<value>(func, arg), "http://localhost:8090/echo-client", cs); assert(hasContent(rval)); const list<value> r = mklist<value>( diff --git a/sca-cpp/trunk/components/webservice/webservice.cpp b/sca-cpp/trunk/components/webservice/webservice-client.cpp index 6427756b40..cc3a15c734 100644 --- a/sca-cpp/trunk/components/webservice/webservice.cpp +++ b/sca-cpp/trunk/components/webservice/webservice-client.cpp @@ -20,7 +20,7 @@ /* $Rev$ $Date$ */ /** - * Web service component implementation. + * Web service client component implementation. */ #include "string.hpp" @@ -28,13 +28,13 @@ #include "list.hpp" #include "value.hpp" #include "monad.hpp" -#include "webservice.hpp" +#include "axis2.hpp" namespace tuscany { namespace webservice { /** - * Apply a Web service function / operation using Axis2. + * Apply a function provided by a remote Web service using Axis2. */ const failable<value> apply(const value& func, const list<value>& params) { const Axis2Context ax; diff --git a/sca-cpp/trunk/components/webservice/webservice-listener.cpp b/sca-cpp/trunk/components/webservice/webservice-listener.cpp new file mode 100644 index 0000000000..495eb3478c --- /dev/null +++ b/sca-cpp/trunk/components/webservice/webservice-listener.cpp @@ -0,0 +1,63 @@ +/* + * 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$ */ + +/** + * Web service listener component implementation. + */ + +#include "string.hpp" +#include "function.hpp" +#include "list.hpp" +#include "value.hpp" +#include "monad.hpp" +#include "../../modules/http/httpd.hpp" +#include "axis2.hpp" + +namespace tuscany { +namespace webservice { + +/** + * Handle an HTTP request. + */ +const failable<value> handle(const list<value>& params) { + + // Extract HTTPD request and relay reference + unused request_rec* r = httpd::request(car(params)); + const lambda<value(const list<value>&)> relay = cadr(params); + + //TODO Hook Axis2/C server module here + + return value(true); +} + +} +} + +extern "C" { + +const tuscany::value apply(const tuscany::list<tuscany::value>& params) { + const tuscany::value func(car(params)); + if (func == "handle") + return tuscany::webservice::handle(cdr(params)); + return tuscany::mkfailure<tuscany::value>(tuscany::string("Function not supported: ") + func); +} + +} diff --git a/sca-cpp/trunk/components/webservice/webservice.composite b/sca-cpp/trunk/components/webservice/webservice.composite index ebb007b37e..bbfc926e2e 100644 --- a/sca-cpp/trunk/components/webservice/webservice.composite +++ b/sca-cpp/trunk/components/webservice/webservice.composite @@ -20,13 +20,28 @@ <composite xmlns="http://docs.oasis-open.org/ns/opencsa/sca/200912" xmlns:t="http://tuscany.apache.org/xmlns/sca/1.1" targetNamespace="http://tuscany.apache.org/xmlns/sca/components" - name="webservice"> + name="webservice-client"> - <component name="webservice"> - <implementation.cpp path=".libs" library="libwebservice"/> + <component name="webservice-client"> + <implementation.cpp path=".libs" library="libwebservice-client"/> <property name="uri">http://localhost:9090/axis2/services/echo</property> - <service name="webservice"> - <t:binding.http uri="webservice"/> + <service name="webservice-client"> + <t:binding.jsonrpc uri="echo-client"/> + </service> + </component> + + <component name="webservice-listener"> + <implementation.cpp path=".libs" library="libwebservice-listener"/> + <service name="webservice-listener"> + <t:binding.http uri="echo-listener"/> + </service> + <reference name="relay" target="echo"/> + </component> + + <component name="echo"> + <t:implementation.scheme script="echo.scm"/> + <service name="echo"> + <t:binding.jsonrpc uri="echo"/> </service> </component> diff --git a/sca-cpp/trunk/configure.ac b/sca-cpp/trunk/configure.ac index 3a35bb1406..b1a5e8a489 100644 --- a/sca-cpp/trunk/configure.ac +++ b/sca-cpp/trunk/configure.ac @@ -360,9 +360,9 @@ AC_ARG_WITH([axis2c], [AC_HELP_STRING([--with-axis2c=PATH], [path to installed A AC_SUBST(AXIS2C_INCLUDE) AC_SUBST(AXIS2C_LIB) -# Enable Web service support. -AC_MSG_CHECKING([whether to enable Web service support]) -AC_ARG_ENABLE(webservice, [AS_HELP_STRING([--enable-webservice], [enable Web service support [default=no]])], +# Enable Web service component. +AC_MSG_CHECKING([whether to enable the Web service component]) +AC_ARG_ENABLE(webservice, [AS_HELP_STRING([--enable-webservice], [enable Web service component [default=no]])], [ case "${enableval}" in no) AC_MSG_RESULT(no) @@ -377,11 +377,71 @@ if test "${want_webservice}" = "true"; then LIBS="-L${AXIS2C_LIB} ${default_LIBS}" AC_CHECK_LIB([axis2_engine], [axis2_svc_client_create], [], [AC_MSG_ERROR([couldn't find a suitable libaxis2_engine, use --with-axis2c=PATH])]) AM_CONDITIONAL([WANT_WEBSERVICE], true) - AC_DEFINE([WANT_WEBSERVICE], 1, [enable Web service support]) + AC_DEFINE([WANT_WEBSERVICE], 1, [enable Web service component]) else AM_CONDITIONAL([WANT_WEBSERVICE], false) fi +# Enable Store component. +AC_MSG_CHECKING([whether to enable the Store component]) +AC_ARG_ENABLE(store, [AS_HELP_STRING([--enable-store], [enable Store component [default=no]])], +[ case "${enableval}" in + no) + AC_MSG_RESULT(no) + ;; + *) + AC_MSG_RESULT(yes) + want_store=true + ;; + esac ], +[ AC_MSG_RESULT(no)]) +if test "${want_store}" = "true"; then + AM_CONDITIONAL([WANT_STORE], true) + AC_DEFINE([WANT_STORE], 1, [enable Store component]) +else + AM_CONDITIONAL([WANT_STORE], false) +fi + +# Enable Queue component. +AC_MSG_CHECKING([whether to enable the Queue component]) +AC_ARG_ENABLE(queue, [AS_HELP_STRING([--enable-queue], [enable Queue component [default=no]])], +[ case "${enableval}" in + no) + AC_MSG_RESULT(no) + ;; + *) + AC_MSG_RESULT(yes) + want_queue=true + ;; + esac ], +[ AC_MSG_RESULT(no)]) +if test "${want_queue}" = "true"; then + AM_CONDITIONAL([WANT_QUEUE], true) + AC_DEFINE([WANT_QUEUE], 1, [enable Queue component]) +else + AM_CONDITIONAL([WANT_QUEUE], false) +fi + +# Enable Chat component. +AC_MSG_CHECKING([whether to enable the Chat component]) +AC_ARG_ENABLE(chat, [AS_HELP_STRING([--enable-chat], [enable Chat component [default=no]])], +[ case "${enableval}" in + no) + AC_MSG_RESULT(no) + ;; + *) + AC_MSG_RESULT(yes) + want_chat=true + ;; + esac ], +[ AC_MSG_RESULT(no)]) +if test "${want_chat}" = "true"; then + AM_CONDITIONAL([WANT_CHAT], true) + AC_DEFINE([WANT_CHAT], 1, [enable Chat component]) +else + AM_CONDITIONAL([WANT_CHAT], false) +fi + # Configure GCC C++ and LD options. AC_SUBST([CXXFLAGS], ["${cxxflags}"]) AC_SUBST([LDFLAGS], ["${ldflags}"]) @@ -400,6 +460,9 @@ AC_CONFIG_FILES([Makefile modules/server/Makefile components/Makefile components/cache/Makefile + components/log/Makefile + components/chat/Makefile + components/queue/Makefile components/store/Makefile components/webservice/Makefile samples/Makefile diff --git a/sca-cpp/trunk/modules/http/httpd.hpp b/sca-cpp/trunk/modules/http/httpd.hpp index 4a3e5d0f58..1e8f2a80b5 100644 --- a/sca-cpp/trunk/modules/http/httpd.hpp +++ b/sca-cpp/trunk/modules/http/httpd.hpp @@ -264,6 +264,20 @@ const int reportStatus(const failable<int>& rc) { return content(rc); } +/** + * Convert an HTTPD request struct to a value + */ +const value requestValue(request_rec* r) { + return value((const value*)r); +} + +/** + * Convert a value to an HTTPD request struc + */ +request_rec* request(const value& v) { + return (request_rec*)(const value*)gc_ptr<value>(v); +} + } } diff --git a/sca-cpp/trunk/modules/server/mod-eval.hpp b/sca-cpp/trunk/modules/server/mod-eval.hpp index dfc376c55c..aaf31f2b18 100644 --- a/sca-cpp/trunk/modules/server/mod-eval.hpp +++ b/sca-cpp/trunk/modules/server/mod-eval.hpp @@ -169,7 +169,12 @@ const failable<int> post(request_rec* r, const lambda<value(const list<value>&)> return OK; } - return HTTP_NOT_IMPLEMENTED; + // Unknown content type, wrap the HTTP request struct in a value and pass it to + // the component implementation function + const failable<value> val = failableResult(impl(cons<value>("handle", mklist<value>(httpd::requestValue(r))))); + if (!hasContent(val)) + return mkfailure<int>(reason(val)); + return OK; } /** |