celix-dev mailing list archives

Site index · List index
Message view « Date » · « Thread »
Top « Date » · « Thread »
From Miroslav Beranič <miroslav.bera...@mibesis.si>
Subject Re: Apache Celix (Simple) HTTP Service
Date Wed, 09 Dec 2015 11:43:09 GMT
Hello Gerrit,

thank you for the tips. Will lookup and see how it is done. As I said, I
do not know all the "dark corners" yet. But I got really good starting
boost from Bjoern. To me service_tracker was quite easy to use :).
I was thinking about such "project" as CELIX-236 also! Wooohooo, many
thanks. I've looked at the different branches, but (again :) ) it is
missing "simple" documentation. That would make clear what is what and
why. It is also marked as "Stale branches" so I thought this is some
unused code.

I learn about Celix from documentation I find on the internet, so
it is quite difficult to pickup all this. I've started to read mailing archives,
but again - it is quite difficult if you (me) do not have a context to
link dots.


Kind Regards,
Miroslav

2015-12-05 14:38 GMT+01:00 Gerrit Binnenmars <gerritbinnenmars@gmail.com>:
> Hello Miroslav,
>
> Nice to read your mail.  Especially your remarks on "easy to learn API" and
> that you spend 32 hours realising this project are very valueable for this
> list.
> One small tip: please have a look at the updated dependency manager code in
> the develop branch. It's much easier to use than the service_trackers.
> To increase productivity further CELIX-236-celix-bootstrap is helpful. We
> hope to pick it up soon and extend it, after that more "default" code can be
> generated.
>
> With kind regards,
>
> Gerrit Binnenmars
>
> Op 2-12-2015 om 22:56 schreef Miroslav Beranič:
>
>> 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 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 ...
>>
>> 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,
>
>



-- 
Miroslav Beranič
MIBESIS
+386(0)40/814-843
miroslav.beranic@mibesis.si
http://www.mibesis.si

Mime
View raw message