Return-Path: X-Original-To: apmail-celix-dev-archive@www.apache.org Delivered-To: apmail-celix-dev-archive@www.apache.org Received: from mail.apache.org (hermes.apache.org [140.211.11.3]) by minotaur.apache.org (Postfix) with SMTP id 0EBB818E85 for ; Thu, 3 Dec 2015 20:59:22 +0000 (UTC) Received: (qmail 84252 invoked by uid 500); 3 Dec 2015 20:59:15 -0000 Delivered-To: apmail-celix-dev-archive@celix.apache.org Received: (qmail 84204 invoked by uid 500); 3 Dec 2015 20:59:15 -0000 Mailing-List: contact dev-help@celix.apache.org; run by ezmlm Precedence: bulk List-Help: List-Unsubscribe: List-Post: List-Id: Reply-To: dev@celix.apache.org Delivered-To: mailing list dev@celix.apache.org Received: (qmail 84192 invoked by uid 99); 3 Dec 2015 20:59:15 -0000 Received: from Unknown (HELO spamd1-us-west.apache.org) (209.188.14.142) by apache.org (qpsmtpd/0.29) with ESMTP; Thu, 03 Dec 2015 20:59:15 +0000 Received: from localhost (localhost [127.0.0.1]) by spamd1-us-west.apache.org (ASF Mail Server at spamd1-us-west.apache.org) with ESMTP id D4A1CC49EC for ; Thu, 3 Dec 2015 20:59:14 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at spamd1-us-west.apache.org X-Spam-Flag: NO X-Spam-Score: 2.901 X-Spam-Level: ** X-Spam-Status: No, score=2.901 tagged_above=-999 required=6.31 tests=[DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, HTML_MESSAGE=3, SPF_PASS=-0.001, URIBL_BLOCKED=0.001, WEIRD_PORT=0.001] autolearn=disabled Authentication-Results: spamd1-us-west.apache.org (amavisd-new); dkim=pass (2048-bit key) header.d=gmail.com Received: from mx1-eu-west.apache.org ([10.40.0.8]) by localhost (spamd1-us-west.apache.org [10.40.0.7]) (amavisd-new, port 10024) with ESMTP id 6WakAQdB6B4r for ; Thu, 3 Dec 2015 20:59:03 +0000 (UTC) Received: from mail-wm0-f54.google.com (mail-wm0-f54.google.com [74.125.82.54]) by mx1-eu-west.apache.org (ASF Mail Server at mx1-eu-west.apache.org) with ESMTPS id D025725E3C for ; Thu, 3 Dec 2015 20:59:02 +0000 (UTC) Received: by wmww144 with SMTP id w144so37793060wmw.1 for ; Thu, 03 Dec 2015 12:59:02 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=mime-version:references:in-reply-to:from:date:message-id:subject:to :content-type; bh=UASzojG6skfp+yzfqqXb/uRc4/Wa037JHLuL/6Py7SM=; b=Jr7g/fHbX5W98n6090dECt6nuWLN+81uystz5Aq/9lbPs6OYH3X6kb2n05tW0e2cK1 gWOGw4tfyVggMXASLN0WzZk1iKlS/0G/orL1DNawPR3LwxuD75T8AKZRUdGVYj7/KXWB QLfUV5a0i9qtKZSLyyFl3vPAMx4V78N+6AAgF02RT1ESvOhBZx3N46COWa+ka00mm/p3 rS0hC+4zMx9y6in5vBKaVqVSKIA3wLOcLLHRA4cmjYjynBVSf+Zi05bpUGatbzOKoqas lw8ZdanQp6ReS/beGujwd4zFjc306OP8Zb0dM027Sqn0xmVlWyzFdjI4pE3NUNJCSjWK ZmVw== X-Received: by 10.28.173.21 with SMTP id w21mr787087wme.102.1449176342534; Thu, 03 Dec 2015 12:59:02 -0800 (PST) MIME-Version: 1.0 References: In-Reply-To: From: Pepijn Noltes Date: Thu, 03 Dec 2015 20:58:52 +0000 Message-ID: Subject: Re: Apache Celix (Simple) HTTP Service To: dev@celix.apache.org Content-Type: multipart/alternative; boundary=001a11444e401d224e052604a918 --001a11444e401d224e052604a918 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: quoted-printable Hi, On Wed, Dec 2, 2015 at 10:56 PM Miroslav Berani=C4=8D < miroslav.beranic@mibesis.si> wrote: > Hi All, > > this is my first post/mail to Apache Celix and also my first Apache > Celix (and after a long time C) project. > Welcome :) > I would like to use Apache Celix as base for my future projects. I am > big fan of OSGi (starting with Eclipse IDE) and Apache Felix and > Apache Karaf etc. > Well, to have it (OSGI) in C it makes it so much more fun! (well, > sometimes it is not that fun ...) > Could agree more. OSGI is great, but there is something about combing OSGi and C that is really fun. Not always easy, often challenging, but fun :). > > My day ful-time job is in Java-based system integration projects. Jump > into C is (most of the time) fun, but different; so take that into an > account when you evaluate C code plus this is really simple PoC > project - to learn Apache Celix, CMake, C, ... I am not doing correct > cleanup, that much I know. > > What I've implemented is a simple HTTP Service, based on Whiteboard > pattern and whiteboard example located in the Apache Celix source code > tree. I used that example as a base: 1.) to learn the API of the > Apache Celix and 2.) it was already using Whiteboard pattern that I > wanted to use. > Cool. Something like the http service specification is really missing in Celix. In quite a few situation bundle run their own http servers (remote service admin, discovery). > > This implementation is split into multiple bundles. > - apache_celix_simple_http_server =3D> Really simple HTTP server written > in C (pure socket open/listen) > Is there a reason not to use a 3rd party (open source) http service. e.g. something like civet web (https://github.com/civetweb/civetweb) ? I would spare you some work, especially getting all the features of http correct (for example cache header.) > - apache_celix_http_service =3D> HTTP Service that binds to (first > found) HTTP Server implementation and creates service tracker for the > servlet bundles > - apache_celix_examples_servlet_a =3D> Servlet bundle for /hello_world_a > and some more URIs + HTTP methods > - apache_celix_examples_servlet_b =3D> Servlet bundle for /hello_world_b = URI > > Most of the code was first hit on Google search and modified to do > this one simple job. It is not rock solid and ideally crafted. > > There can be any number of the Servlet bundles - started and stopped > at runtime. Regex URI are supported plus HTTP method filtering too > (GET/POST/DELETE, ...). Servlet bundle A makes use of the Regex URI > pattern and HTTP method servlet mapping filtering. > I am planning to add support for HTTP filters and interceptors (I am > "influenced" by Spring Framework project ... can't help it, I use it > daily). But than ... full HTTP "stack" has to be added with requests, > responses, sessions, security ... > Whoa big plans, but very cool. Would be interesting for sure. > > To build this baby: > CMake is used (who would have guessed it). Create build folder. And > run (from the inside of build folder): > cmake -DCELIX_DIR=3D/path/to/celix -DCMAKE_BUILD_TYPE=3DDebug > -DCMAKE_INSTALL_PREFIX=3D/path/to/install > -DJAR_COMMAND=3D/path/to/jdk1.8/bin/jar ../source/ > > Next > make all > make deploy > > For building on Mac. I needed to edit the CMake target_link_libraries command to include Celix libs (${CELIX_LIBRARIES). No big deal, but good to known. > cd ./deploy/http_whiteboard/run.sh > chmod u+x ./run.sh > ./run.sh > > > (open new terminal) > [Handled by servlet/bundle A) > curl -X GET -i http://localhost:9090/static/resources/my-theme.css > curl -X GET -i http://localhost:9090/hello_world/a/ > curl -X GET -i http://localhost:9090/hello_world_a > > [Handled by servlet/bundle B] > curl -X GET -i http://localhost:9090/hello_world_b > > > lb > > stop 7 > > stop 6 > Try the curl URLs... how they come and go : if not registered HTTP 404 > error message is returned. > > ... > > start 6 > > And at the end press Ctrl+C to terminate. Trigger one more request, as > there is no timeout > implemented and it is waiting for the thread to terminate (running > flag to be false). > > > I know this is not usable in real world cases. But I like the idea. I > put this together in about ... 32hours of work, more ore less; keep in > mind: this was next task after compiling Apache Celix for the first > time ever and not really be a C expert; so to me - this is a proof > that Apache Celix has easy to learn API and it is easy to use it. I > did not use "deep and dark" corners of Apache Celix, but I like the > project. I looked/played with kubernetes project also and all worked > great - first time. > > Well that is nice to hear. Of course one of the benefits of Apache Celix should be a easier development time, specifically for more complex/abstracted applications. But it is nice to hear the experience from the "field" :). With the kubernetes project I assume you mean the INAETICS project ( https://github.com/INAETICS/kubernetes-demo-cluster). Impressive that worked great for you, we known this is a difficult project to setup, tryout and most importantly understand. > > What I am wondering though is - is there any plan to add Web-related > support (I am talking about the HTTP Service known from the > Felix/OSGI) to Apache Celix or is this considered non-Celix related > (to make Celix only the "kernel") : to make it as different/sister > project? > No real plans but there are wishes :). Apache Celix is already grown out of it's "kernel" size and contains a lot feature from the compendium/enterprise spec. IMO something like the http service spec should not be a sister project, but part of Apache Celix. > I am also not clear how the C++ is seen in the Apache Celix community, > is this no-go or go area? I will most probably be using Boost C++ > (mostly ASIO) library in the future (with Apache Celix). So, C for the > "framework" layer and C++ for the "application" layer. > > For now we are 100% C. Personally I a bit worried about introducing C++ even on the "application" layer. Because I am afraid this will slowly move to the "framework" layer. That being said. I do think that eventually we want C++ and other native language support. Some time ago there where some discussion about Native OSGi. And I would like to see Celix move to that direction. That would mean that we should support bundles written in 100% cpp and maybe D, Rust, Swift. I think support bundles written in other (native) language is quite feasible. I even started prototyping with some Swift code (which is promised to become open source) . The beauty about C is that it is the common dominator for native languages and therefore ideal as core framework language. The biggest challenges would be how and if those bundles can share services written in different language. So cpp pure abstract class as service used in a C bundle ?? Note that this is my opinion and not _the_ Celix policy, everything is discussable. > > Well, I guess this is all. I will attach source to this email. As I > did not publish the sourcecode to GitHub. In the source I state > "Author/Copyright" Miroslav, Mibesis (my company) -- but this code is > open to anyone that thinks will benefit to him. I hope there is no > filter on the mail server to filter attachments out. Attachments > contains source only, no binaries). But I have full GIT repo in - so > it can be seen, how I worked whiteboard example to get to the current > result. > > Before we can accept code the license must be Apache License v2 and attached as a attachment to a lira issue. But the start of I think is wise to discuss this a bit more and than see how we want to move forward. > > BTW: Bjoern was of great support and motivation to grab Apache Celix > and start working with it. Thank you Bjoern big time. > Good work Bjoern :) > > > Kind Regards, > -- > Miroslav Berani=C4=8D > MIBESIS > +386(0)40/814-843 > miroslav.beranic@mibesis.si > http://www.mibesis.si > --001a11444e401d224e052604a918--