celix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Bjoern Petri <bjoern.pe...@sundevil.de>
Subject Re: Apache Celix (Simple) HTTP Service
Date Mon, 14 Dec 2015 09:43:43 GMT

Hi Miroslav,

I was quite busy within the last days, so sorry for my late response. 
Nevertheless - Welcome to the Mailing list - its nice to see you here! I 
didn't find the time yet to take a look at your code, but holidays (and 
hence some free time) are coming :).


On 2015-12-02 22:56, Miroslav Beranič 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.
> 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 ...)
> 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.
> This implementation is split into multiple bundles.
> - apache_celix_simple_http_server => Really simple HTTP server written
> in C (pure socket open/listen)
> - apache_celix_http_service => HTTP Service that binds to (first
> found) HTTP Server implementation and creates service tracker for the
> servlet bundles
> - apache_celix_examples_servlet_a => Servlet bundle for /hello_world_a
> and some more URIs + HTTP methods
> - apache_celix_examples_servlet_b => Servlet bundle for /hello_world_b 
> 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 ...
> 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=/path/to/celix -DCMAKE_BUILD_TYPE=Debug
> -DCMAKE_INSTALL_PREFIX=/path/to/install
> -DJAR_COMMAND=/path/to/jdk1.8/bin/jar ../source/
> Next
> make all
> make deploy
> 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.
> 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?
> 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.
> 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.
> BTW: Bjoern was of great support and motivation to grab Apache Celix
> and start working with it. Thank you Bjoern big time.
> Kind Regards,

View raw message