You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@celix.apache.org by Miroslav Beranič <mi...@mibesis.si> on 2015/12/02 22:56:14 UTC

Apache Celix (Simple) HTTP Service

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

Re: Apache Celix (Simple) HTTP Service

Posted by Miroslav Beranič <mi...@mibesis.si>.
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 <ge...@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

Re: Apache Celix (Simple) HTTP Service

Posted by Gerrit Binnenmars <ge...@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,


Re: Apache Celix (Simple) HTTP Service

Posted by Bjoern Petri <bj...@sundevil.de>.

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 :).

Regards,
   Bjoern


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 
> 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,

Re: Apache Celix (Simple) HTTP Service

Posted by Miroslav Beranič <mi...@mibesis.si>.
Hi Pepijn,


yes, I like when guys say: I know Spring Framework. My first question is

which parts. Spring MVC is I guess by far most used component of all the

available, for a developer in web-related projects.

I was referring to Spring MVC, yes; but also other components are important

for any decent developer, where I equally see no reason C is not "active".

For example: Spring Integration, Spring Batch, Spring Security. As this

are all the projects (as they are called last time I checked) I use

more-or-less daily. I've done training for a certification in the Bangalore,

India; way back in 2011. Have not renewed it since then, but ... if you

use it, it gets like your own pocket.

In general, I do not know any "good alternative" to solutions, concepts

and paradigms provided by Spring in C or C++; or any other language for

that matter.

Well, when I talk/think web-related projects design and implementation,

Spring is first and 99% last project I consider and use: as I have it all

in "once place"; just like IKEA. Some like it, some think it is an over

kill. You use what you know and feel confident I guess.


For the documentation I found biggest pain, that there was out-of-date

documentation. Just to make it build and run hello world. I think any

interested user will first compile the project and run the example. 1. to

see if it compiles (on his working environment - Linux, Windows, MacOS),

2. does it do what it promotes and 3. what is the API to use it.

I was not able to compile, once I thought I did; I was not able to run

the hello world example.



https://celix.apache.org/index.html links to

https://celix.apache.org/documentation.html that links to

https://celix.apache.org/documentation/getting_started.html and

https://celix.apache.org/documentation/buildingandrunning.html


(Please not I have configured environment now with all the dependencies

and all, as in "my own setup" I am able to build, modify and deploy Celix

project and bundles.)


First it was ... ok: what to choose - Getting started or Build and running.

I went with Getting started; as this is what I want and it is listed

first.

Type in the commands there and run the cmake. Terminal says:



mibesis@W520:~/tmp/celix-build$ cmake ../celix-src -DBUILD_SHELL=TRUE
-DBUILD_SHELL_TUI=TRUE -DBUILD_EXAMPLES=TRUE

-- The C compiler identification is GNU 4.8.4

-- The CXX compiler identification is GNU 4.8.4

-- Check for working C compiler: /usr/bin/cc

-- Check for working C compiler: /usr/bin/cc -- works

-- Detecting C compiler ABI info

-- Detecting C compiler ABI info - done

-- Check for working CXX compiler: /usr/bin/c++

-- Check for working CXX compiler: /usr/bin/c++ -- works

-- Detecting CXX compiler ABI info

-- Detecting CXX compiler ABI info - done

-- Found CPack at: /usr/bin/cpack

-- Using JAR to repack bundles, bundles can be used by Apache ACE

-- Found Java: /home/mibesis/Library/jdk1.7/bin/java (found version
"1.7.0.79")

-- Found CPack at: /usr/bin/cpack

-- Found Doxygen: /usr/bin/doxygen (found version "1.8.6")

-- Found DOXYFILE_IN: /home/mibesis/tmp/celix-src/Doxyfile.in

-- NO bundle name set, using symbolic name

-- NO bundle name set, using symbolic name

-- Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so (found version
"7.35.0")

-- Found UUID: /usr/lib/x86_64-linux-gnu/libuuid.so

-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8")

CMake Error at cmake/cmake_celix/Packaging.cmake:357 (get_property):

  get_property could not find TARGET phase1.  Perhaps it has not yet been

  created.

Call Stack (most recent call first):

  examples/dm_example/deploy.cmake:18 (deploy)

  cmake/cmake_celix/Packaging.cmake:478 (include)

  CMakeLists.txt:90 (deploy_targets)



CMake Error at cmake/cmake_celix/Packaging.cmake:357 (get_property):

  get_property could not find TARGET phase2a.  Perhaps it has not yet been

  created.

Call Stack (most recent call first):

  examples/dm_example/deploy.cmake:18 (deploy)

  cmake/cmake_celix/Packaging.cmake:478 (include)

  CMakeLists.txt:90 (deploy_targets)



CMake Error at cmake/cmake_celix/Packaging.cmake:357 (get_property):

  get_property could not find TARGET phase2b.  Perhaps it has not yet been

  created.

Call Stack (most recent call first):

  examples/dm_example/deploy.cmake:18 (deploy)

  cmake/cmake_celix/Packaging.cmake:478 (include)

  CMakeLists.txt:90 (deploy_targets)



CMake Error at cmake/cmake_celix/Packaging.cmake:357 (get_property):

  get_property could not find TARGET phase3.  Perhaps it has not yet been

  created.

Call Stack (most recent call first):

  examples/dm_example/deploy.cmake:18 (deploy)

  cmake/cmake_celix/Packaging.cmake:478 (include)

  CMakeLists.txt:90 (deploy_targets)



-- Configuring incomplete, errors occurred!

See also "/home/mibesis/tmp/celix-build/CMakeFiles/CMakeOutput.log".


/home/mibesis/tmp/celix-build/CMakeFiles/CMakeOutput.log gave no usable

information; not that would be usable to me, that is.



Again, please note: I am not C developer nor guru or expert or anything,

just Java guy wants to be fancy with C. So what I've managed to do is

to run cmake with this set of arguments:

mibesis@W520:~/tmp/celix-build$ cmake -DBUILD_DEPENDENCY_MANAGER=ON

-DBUILD_DEPLOYMENT_ADMIN=ON -DBUILD_DEVICE_ACCESS=ON

-DBUILD_DEVICE_ACCESS_EXAMPLE=ON -DBUILD_EXAMPLES=ON -DBUILD_FRAMEWORK=ON

-DBUILD_LAUNCHER=ON -DBUILD_LOG_SERVICE=ON -DBUILD_LOG_WRITER=ON

-DBUILD_LOG_WRITER_SYSLOG=ON -DBUILD_REMOTE_SERVICE_ADMIN=ON

-DBUILD_REMOTE_SHELL=ON -DBUILD_SHELL=ON -DBUILD_SHELL_TUI=ON

-DCMAKE_BUILD_TYPE=Debug -DCPACK_COMMAND=/usr/bin/cpack -DDOXYFILE_LATEX=ON

-DJAR_COMMAND=/home/mibesis/Library/jdk1.8/bin/jar

DCMAKE_INSTALL_PREFIX=/home/mibesis/tmp/Celix/ ../celix-src/

-- The C compiler identification is GNU 4.8.4

-- The CXX compiler identification is GNU 4.8.4

-- Check for working C compiler: /usr/bin/cc

-- Check for working C compiler: /usr/bin/cc -- works

-- Detecting C compiler ABI info

-- Detecting C compiler ABI info - done

-- Check for working CXX compiler: /usr/bin/c++

-- Check for working CXX compiler: /usr/bin/c++ -- works

-- Detecting CXX compiler ABI info

-- Detecting CXX compiler ABI info - done

-- Found CPack at: /usr/bin/cpack

-- Using JAR to repack bundles, bundles can be used by Apache ACE

-- Found Java: /home/mibesis/Library/jdk1.7/bin/java (found version
"1.7.0.79")

-- Found CPack at: /usr/bin/cpack

-- Found Doxygen: /usr/bin/doxygen (found version "1.8.6")

-- Found DOXYFILE_IN: /home/mibesis/tmp/celix-src/Doxyfile.in

-- NO bundle name set, using symbolic name

-- NO bundle name set, using symbolic name

-- Found CURL: /usr/lib/x86_64-linux-gnu/libcurl.so (found version
"7.35.0")

-- Found UUID: /usr/lib/x86_64-linux-gnu/libuuid.so

-- Found Jansson: /usr/lib/x86_64-linux-gnu/libjansson.so

-- Found LibXml2: /usr/lib/x86_64-linux-gnu/libxml2.so (found version
"2.9.1")

-- Found Syslog: /usr/include

-- Found ZLIB: /usr/lib/x86_64-linux-gnu/libz.so (found version "1.2.8")

-- Configuring done

-- Generating done

-- Build files have been written to: /home/mibesis/tmp/celix-build



And now it looks like it works.




So from the start, project is not build-able. I would not use such project

if I would get to this. Well, this what happened first time. But than

I Googled more and found that the project is usable by others. So this

project has to be build-able - one way or another. After weeks on reading,

I also found out that a book (PDF) about CMake is good to read, and
searching

I've decided to write Bjoern. And rest is history, they say.


I am not able to say: what is wrong with that commands on the web site,

but they to not work for me; and I have working environment with
dependencies

and all.



Bjoern gave me set of commands that I should run. One issue was, I was

trying to build on different environments (as I was planning at that time;

and doing it now - run Celix on a Raspberry PI), with different CMake

versions. Well, I failed. At that time, CMake 2.8 was the only setup that

worked (that was on Ubuntu 14.04 LTS x64).



Move on. OK, read more. What else is there. Super, they use Eclipse! Yeey,

no new fancy tool that does not work. Big plus. Let's create this hello

world project. Welll, no. It does not work. If you will look into my code,

from last time; this is still an issue for me: as I am not able to build

my own bundle without that FindCELIX.cmake file under cmake folder. It works

for me this way, do not want to touch this for now: do not bother sleeping

bear. Problem was: CMake was not able to find Celix installation. Found this

FindCELIX.cmake file somewhere on the internet: GitHub.


Eclipse descriptions work out of the box. Once you get to there, it all

works. I have debugger working, I have Valgrind working all in Eclipse.

Eclipse is IDE of my choice ... well, almost a decade. So this was soo soo

cool when it worked in first try.



One thing that Bjoern pointed out, and yes any C developer would know that,

but it was not obvious to me is : use ccmake. Well, it would be good to

point this out in a documentation.



All in all. Now that I look back at the documentation is like "point on

a slideshow", it is like points for a guy that knows how all this works.

It is not for someone trying to get this monster running (it is not once

you get over all this, but when you start ... it is a pain).



OK! I have enough. This can not be so hard to build. It is "small" code

size. It can not be that complicated to build. What else we have. Hmmm,

GitHub, they have "inhouse" documentation. What is there. Let's check it

out. Skim over: For an introduction into Apache Celix see Getting Started

Guide. I just came from that unusable site; do not point me back to that

site. Grrrr.

Ouuh, wait! For information how to build Apache Celix see BUILDING. Hmmm,

what useless text is there. Let's check.


Whoow. It has all that one would need: What is the environment, what is

the build system: CMake; and pointer to the Apache documentation side (bad,

but OK). But on the good side: "Quick Start" is really good. It all worked

first time. Whooohooo. One note:

- correct flags are needed to be set, to be able to run any deploy

artifact (or else deploy folder is empty)

- it needs executable permissions to run (small but important)


But all in all - it worked. Well, it took me few weeks to get to this

file. I wrote to Bjoern like a cry baby and turned around Google.


As it was said, Celix is really simple project to get started and to

work with. I admire all the complexity it hides and handles, but for

me as "a user" it is simple.


What I would suggest is: just go over the Apache documentation side and

cleanup (less is more). Also write that there is a master and develop
branch;

do not forget to write what is the difference - small but important. For

example how should/can I know for "CELIX-236-celix-bootstrap" if Gerrit

would not pointed me to that branch. It is much simpler now, that I learned

all this "tricks" where is what. But to start ... it was a pain :)


Try : create new user on workstation, or virtual box ; and go over all

the provided information/commnds. For me BUILDING file is main source of

information.


The other issue is: one can not just copy hello world example and compile

it. As existing example bundles are "bound" to the Celix source code.

With that again, I turned Google around and at that point I found out

out the INEATICS project, as it had really nice simple standalone Celix

bundle. With some modifications I was able to create my own and later on

on top of that copy Whiteboard pattern example from the Celix source code

tree.



I have not used Apache Avro before. Need to check and test; but from first

feel and look: The current version of Avro is 1.7.7. The current version of

libavro is 22:0:0. This document was created 2014-07-18. Again, GitHub

has much better picture: Latest commit 4590538  22 hours ago :) (y).


I was planning on asking: what is the status - what do you guys use to

serialize to JSON, XML, HTML ... is there something "defacto" used in C

or you write your own library? Thanks for the Avro pointer.

I used and really like Boost Serialization project. But yes, that is for

another topic.



To use logic cross-bundle I guess it does not make sense to try to share

per-language feature. What I mean by this: I think it is not a benefit

to make abstract class in C++ and try to find a solution to make C bundle

use it. Share/distribute concepts that are know to all: known to C. So

abstract classes, templates, RTTI all falls out. There can be a "C++

glue bundle" that will have abstract class, templates and RTTI; but will

not be usable by a C bundle. But, I can share data structure between

C++ bundle and C bundle, also functions (methods as function pointers).


With that "limitation" there is no need for Thrift. Agree on Schema/IDL

over kill. Again: less is more.


Kind Regards,

Miroslav



V tor., 15. dec. 2015 13.37 je oseba Pepijn Noltes <pe...@gmail.com>
napisala:

> Hi,
>
> On Wed, Dec 9, 2015 at 12:42 PM Miroslav Beranič <
> miroslav.beranic@mibesis.si> wrote:
>
> > Hi Pepijn,
> >
> > when I was looking around the project (when built and deployed) and
> > later on at the source code I've noticed that Celix already has "some"
> > HTTP interface - like the monitoring and REST services for RSA. I looked
> > at this, as I did not want to make "another" hot water or round wheel.
> > Later on I learned the HTTP is based on the Civet web, with "static"
> URIs.
> >
> > As said, this is PoC project/implementation. I was quite happy with it,
> > as it was "easy" to implement (I had all the examples available, so only
> > some code changes were done).
> > It makes sense to use existing open source HTTP implementation. I could
> not
> > agree more. But (there is always a but, when things looks positive,
> doesn't
> > it) the problems I faced (I was looking more at Nginx and Apache Httpd)
> > was that, I (perhaps it can be done, but for me it was an unbreakable
> > challenge) how to dynamically register/unregister request mappings. I
> know
> > HTTPD more, and there - server has to be restarted (if you do not use
> > some hot deploying module) to make effect.
> > Just before I "finished" my implementation, I found that there are "two"
> > HTTP servers in the Celix source code (examples). Civet and Mongoose,
> I've
> > started with Mongoose, but did not make much success; so I started my
> > "really simple" HTTP server.
> > The other "more relevant" why is : I did not want to have only one
> > HTTP implementation. So, I wanted to implement HTTP Service in a way,
> > that can work with any HTTP Server implementation - that is : C socket
> > simple, Civet, Mongoose, Apache HTTPD, Nginx, ... if someone feels his
> > implementation is better/best: woohoo, I want him to do it his way.
> >
> > But (again; do you notice a pattern here ...) that forces to make unified
> > bridge between HTTP Service and HTTP Server implementation. And that is
> > this additional work I had to do. Problem with this is, I haven't decided
> > if this is the best way or way I want to go/write.
> >
> > With filters and interceptors I am also facing some fundamental design
> > issues. Should this be part of HTTP Service or "framework" on top of the
> > HTTP Service (like Spring Framework). I guess you guys are all C, and I
> > also guess we see things different. To me Spring Framework became only
> > way I do HTTP related interfaces logic this days/years; and I do not
> really
> > care about the "core" HTTP Service provided/defined by the standard.
> > Plus, this is also related with how to implement HTTP Service - be a
> > general + different implementations or have only one. If general HTTP
> > Service is implemented with specific implementations, than this filters
> > have to be implemented in a way, that logic it portable/runnable across
> > different HTTP Server implementation. There are a lot of open questions
> > here. I did not want them to be opened.
> >
>
> Just curious which parts of Spring do you mean? I have some experience with
> Spring a few years back and at the time used Spring MVC. To be honest I
> really liked that and in a way I consider the Spring framework a (more
> static/config based) service oriented prorgamming framework if you do it
> correctly.
>
>
>
> >
> > I was building on only my trusted W520 Linux box :) I found (based on the
> > GIT Ignore file :D ) you guys are more-or-less on Macs. To be honest,
> > I am using CMake for the first time - with start of my involvement with
> > Celix. So yes, there is room for improvements. Thank you for the update,
> > will be used.
> >
> > At first I thought Celix is soo soo complex project, I started my own
> > uOSGI project. Found some people from around the Internet that were doing
> > the same, but -- well, it has to be complex as it is not a simple task;
> > event if it seems to be simple. So one year later I took another look
> > at the Celix project and wrote to Bjoern -- to get this "monster" built.
> > The documentation should be updated or if not relevant: deleted! :) It
> > made me wast more time than it was of good use to me.
> > But than you get into the flow and I was able to read/locate pieces of
> > source code that I needed and it was really easy -- it is all easy if you
> > have a good starting point.
> >
>
> Yeah documentation is lacking. Could you be more specific what is missing
> or did not work.
> e.g. did you use the gettting started doc (
> https://celix.apache.org/documentation/getting_started.html) ?
>
>
>
> >
> > With Kubernetes project I mean INAETICS project, yes. As, I said before,
> > in Java one of the first things you do is a cluster :D If you want
> > performance.
> > So to have all this in a package: INAETICS project. It was a good day,
> > that day - I found/built/deployed INAETICS project. Really nice work.
> > Again, the docs could be better :D ; but, Bjoern pointed me to the
> updated
> > documents and added some pointers and it all worked in the first try.
> >
> >
> > I agree that HTTP is missing in Celix. To me, it is all about HTTP; I do
> > not know you guys. I guess you "play" with signals and bits; but I play
> > with massive HTTP traffic -- so "more or less" looking for a HTTP
> Service.
> >
> >
> > I am more at home with C++ than with C. Well, when you learn about C++,
> > you are told: this is like C plus classes; well, this is to not true and
> > total failed statement. It can be, do not get me wrong - but than just
> use
> > C; do not bother with C++. I was working with Java for ten years now and
> > my mind is somehow set on this OO style. It is difficult to think in a
> > way that C is set. I am not saying it is not the correct way, it is
> > different. Like Objective-C is different.
> > Well, for now I do not have any solid argument why use C++, to be honest.
> > Years I go I started to use Boost C++ for one project, and it worked
> > really well for me. So I used C++ more because of the Boost C++ library,
> > than because of the language.
> > Idea is to use (also) C++ as a HTTP server implementation; will see where
> > it goes.
> > I am picking arguments: what makes C so much better - is it simple
> syntax,
> > performance, common dominator, ...
> >
> > I use GCC, tried with Clang/LLVM but did not use it afterwards. When I
> > was playing about my own OSGi platform, I first fall into a trap - how to
> > load modules in runtime. In short: due to "C++ name mangling" it is not
> > possible to make pure C++ plugin. It is, but than again - you are quite
> > on the same level as to use existing C way. I do not know about the other
> > languages - like C, Rust. I do not like Swift, but not for the language;
> > I just do not like an idea of new languages being introduced. I see no
> > real value in it. Objective-C has it all, but this is how I see it.
> >
> >
> > I wrote PoC bundles that use Boost C++ and was able to trap events and
> > do all sorts of things with the bundle -- as long as the activator.c was
> > as is. So to me, this is "100% C++" bundle.
> >
> > Yes, I agree - the problem is in the cross-bundle/service usage of the
> > logic: use pure C++ abstract class in the C bundle. That would introduce
> > a lot of complexity. One solution I can think of is Apache Thrift. I am
> > not big fan of sucha solutions, but it promotes - it is up for the job.
> >
>
> We are working on remote service and for this looking at Apache Avro.
> Thrift is of course also an option, but that also brings the problem of
> such a solution ... which schema/idl to choose (Protobuf, Thrift, Cap'n
> Proto, OMG IDL,  etc).
> Anyways this of course can be used for remote services (C<->C and
> Java<->C), but is also an option for cross native language support. The
> downside, and a big one IMO, is that it forces people to use a schema/IDL
> instead of directly using parts of the choosen language.
>
>
>
> >
> > Thank you for the review and comments. Much appreciated.
> >
> >
> > Kind Regards,
> > Miroslav
> >
> > 2015-12-03 21:58 GMT+01:00 Pepijn Noltes <pe...@gmail.com>:
> > > Hi,
> > >
> > > On Wed, Dec 2, 2015 at 10:56 PM Miroslav Beranič <
> > > 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 => 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 => 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 ...
> > >>
> > >
> > > 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=/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
> > >>
> > >>
> > > 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č
> > >> MIBESIS
> > >> +386(0)40/814-843
> > >> miroslav.beranic@mibesis.si
> > >> http://www.mibesis.si
> > >>
> >
> >
> >
> > --
> > Miroslav Beranič
> > MIBESIS
> > +386(0)40/814-843
> > miroslav.beranic@mibesis.si
> > http://www.mibesis.si
> >
>

Re: Apache Celix (Simple) HTTP Service

Posted by Pepijn Noltes <pe...@gmail.com>.
Hi,

On Wed, Dec 9, 2015 at 12:42 PM Miroslav Beranič <
miroslav.beranic@mibesis.si> wrote:

> Hi Pepijn,
>
> when I was looking around the project (when built and deployed) and
> later on at the source code I've noticed that Celix already has "some"
> HTTP interface - like the monitoring and REST services for RSA. I looked
> at this, as I did not want to make "another" hot water or round wheel.
> Later on I learned the HTTP is based on the Civet web, with "static" URIs.
>
> As said, this is PoC project/implementation. I was quite happy with it,
> as it was "easy" to implement (I had all the examples available, so only
> some code changes were done).
> It makes sense to use existing open source HTTP implementation. I could not
> agree more. But (there is always a but, when things looks positive, doesn't
> it) the problems I faced (I was looking more at Nginx and Apache Httpd)
> was that, I (perhaps it can be done, but for me it was an unbreakable
> challenge) how to dynamically register/unregister request mappings. I know
> HTTPD more, and there - server has to be restarted (if you do not use
> some hot deploying module) to make effect.
> Just before I "finished" my implementation, I found that there are "two"
> HTTP servers in the Celix source code (examples). Civet and Mongoose, I've
> started with Mongoose, but did not make much success; so I started my
> "really simple" HTTP server.
> The other "more relevant" why is : I did not want to have only one
> HTTP implementation. So, I wanted to implement HTTP Service in a way,
> that can work with any HTTP Server implementation - that is : C socket
> simple, Civet, Mongoose, Apache HTTPD, Nginx, ... if someone feels his
> implementation is better/best: woohoo, I want him to do it his way.
>
> But (again; do you notice a pattern here ...) that forces to make unified
> bridge between HTTP Service and HTTP Server implementation. And that is
> this additional work I had to do. Problem with this is, I haven't decided
> if this is the best way or way I want to go/write.
>
> With filters and interceptors I am also facing some fundamental design
> issues. Should this be part of HTTP Service or "framework" on top of the
> HTTP Service (like Spring Framework). I guess you guys are all C, and I
> also guess we see things different. To me Spring Framework became only
> way I do HTTP related interfaces logic this days/years; and I do not really
> care about the "core" HTTP Service provided/defined by the standard.
> Plus, this is also related with how to implement HTTP Service - be a
> general + different implementations or have only one. If general HTTP
> Service is implemented with specific implementations, than this filters
> have to be implemented in a way, that logic it portable/runnable across
> different HTTP Server implementation. There are a lot of open questions
> here. I did not want them to be opened.
>

Just curious which parts of Spring do you mean? I have some experience with
Spring a few years back and at the time used Spring MVC. To be honest I
really liked that and in a way I consider the Spring framework a (more
static/config based) service oriented prorgamming framework if you do it
correctly.



>
> I was building on only my trusted W520 Linux box :) I found (based on the
> GIT Ignore file :D ) you guys are more-or-less on Macs. To be honest,
> I am using CMake for the first time - with start of my involvement with
> Celix. So yes, there is room for improvements. Thank you for the update,
> will be used.
>
> At first I thought Celix is soo soo complex project, I started my own
> uOSGI project. Found some people from around the Internet that were doing
> the same, but -- well, it has to be complex as it is not a simple task;
> event if it seems to be simple. So one year later I took another look
> at the Celix project and wrote to Bjoern -- to get this "monster" built.
> The documentation should be updated or if not relevant: deleted! :) It
> made me wast more time than it was of good use to me.
> But than you get into the flow and I was able to read/locate pieces of
> source code that I needed and it was really easy -- it is all easy if you
> have a good starting point.
>

Yeah documentation is lacking. Could you be more specific what is missing
or did not work.
e.g. did you use the gettting started doc (
https://celix.apache.org/documentation/getting_started.html) ?



>
> With Kubernetes project I mean INAETICS project, yes. As, I said before,
> in Java one of the first things you do is a cluster :D If you want
> performance.
> So to have all this in a package: INAETICS project. It was a good day,
> that day - I found/built/deployed INAETICS project. Really nice work.
> Again, the docs could be better :D ; but, Bjoern pointed me to the updated
> documents and added some pointers and it all worked in the first try.
>
>
> I agree that HTTP is missing in Celix. To me, it is all about HTTP; I do
> not know you guys. I guess you "play" with signals and bits; but I play
> with massive HTTP traffic -- so "more or less" looking for a HTTP Service.
>
>
> I am more at home with C++ than with C. Well, when you learn about C++,
> you are told: this is like C plus classes; well, this is to not true and
> total failed statement. It can be, do not get me wrong - but than just use
> C; do not bother with C++. I was working with Java for ten years now and
> my mind is somehow set on this OO style. It is difficult to think in a
> way that C is set. I am not saying it is not the correct way, it is
> different. Like Objective-C is different.
> Well, for now I do not have any solid argument why use C++, to be honest.
> Years I go I started to use Boost C++ for one project, and it worked
> really well for me. So I used C++ more because of the Boost C++ library,
> than because of the language.
> Idea is to use (also) C++ as a HTTP server implementation; will see where
> it goes.
> I am picking arguments: what makes C so much better - is it simple syntax,
> performance, common dominator, ...
>
> I use GCC, tried with Clang/LLVM but did not use it afterwards. When I
> was playing about my own OSGi platform, I first fall into a trap - how to
> load modules in runtime. In short: due to "C++ name mangling" it is not
> possible to make pure C++ plugin. It is, but than again - you are quite
> on the same level as to use existing C way. I do not know about the other
> languages - like C, Rust. I do not like Swift, but not for the language;
> I just do not like an idea of new languages being introduced. I see no
> real value in it. Objective-C has it all, but this is how I see it.
>
>
> I wrote PoC bundles that use Boost C++ and was able to trap events and
> do all sorts of things with the bundle -- as long as the activator.c was
> as is. So to me, this is "100% C++" bundle.
>
> Yes, I agree - the problem is in the cross-bundle/service usage of the
> logic: use pure C++ abstract class in the C bundle. That would introduce
> a lot of complexity. One solution I can think of is Apache Thrift. I am
> not big fan of sucha solutions, but it promotes - it is up for the job.
>

We are working on remote service and for this looking at Apache Avro.
Thrift is of course also an option, but that also brings the problem of
such a solution ... which schema/idl to choose (Protobuf, Thrift, Cap'n
Proto, OMG IDL,  etc).
Anyways this of course can be used for remote services (C<->C and
Java<->C), but is also an option for cross native language support. The
downside, and a big one IMO, is that it forces people to use a schema/IDL
instead of directly using parts of the choosen language.



>
> Thank you for the review and comments. Much appreciated.
>
>
> Kind Regards,
> Miroslav
>
> 2015-12-03 21:58 GMT+01:00 Pepijn Noltes <pe...@gmail.com>:
> > Hi,
> >
> > On Wed, Dec 2, 2015 at 10:56 PM Miroslav Beranič <
> > 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 => 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 => 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 ...
> >>
> >
> > 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=/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
> >>
> >>
> > 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č
> >> MIBESIS
> >> +386(0)40/814-843
> >> miroslav.beranic@mibesis.si
> >> http://www.mibesis.si
> >>
>
>
>
> --
> Miroslav Beranič
> MIBESIS
> +386(0)40/814-843
> miroslav.beranic@mibesis.si
> http://www.mibesis.si
>

Re: Apache Celix (Simple) HTTP Service

Posted by Miroslav Beranič <mi...@mibesis.si>.
Hi Pepijn,

when I was looking around the project (when built and deployed) and
later on at the source code I've noticed that Celix already has "some"
HTTP interface - like the monitoring and REST services for RSA. I looked
at this, as I did not want to make "another" hot water or round wheel.
Later on I learned the HTTP is based on the Civet web, with "static" URIs.

As said, this is PoC project/implementation. I was quite happy with it,
as it was "easy" to implement (I had all the examples available, so only
some code changes were done).
It makes sense to use existing open source HTTP implementation. I could not
agree more. But (there is always a but, when things looks positive, doesn't
it) the problems I faced (I was looking more at Nginx and Apache Httpd)
was that, I (perhaps it can be done, but for me it was an unbreakable
challenge) how to dynamically register/unregister request mappings. I know
HTTPD more, and there - server has to be restarted (if you do not use
some hot deploying module) to make effect.
Just before I "finished" my implementation, I found that there are "two"
HTTP servers in the Celix source code (examples). Civet and Mongoose, I've
started with Mongoose, but did not make much success; so I started my
"really simple" HTTP server.
The other "more relevant" why is : I did not want to have only one
HTTP implementation. So, I wanted to implement HTTP Service in a way,
that can work with any HTTP Server implementation - that is : C socket
simple, Civet, Mongoose, Apache HTTPD, Nginx, ... if someone feels his
implementation is better/best: woohoo, I want him to do it his way.

But (again; do you notice a pattern here ...) that forces to make unified
bridge between HTTP Service and HTTP Server implementation. And that is
this additional work I had to do. Problem with this is, I haven't decided
if this is the best way or way I want to go/write.

With filters and interceptors I am also facing some fundamental design
issues. Should this be part of HTTP Service or "framework" on top of the
HTTP Service (like Spring Framework). I guess you guys are all C, and I
also guess we see things different. To me Spring Framework became only
way I do HTTP related interfaces logic this days/years; and I do not really
care about the "core" HTTP Service provided/defined by the standard.
Plus, this is also related with how to implement HTTP Service - be a
general + different implementations or have only one. If general HTTP
Service is implemented with specific implementations, than this filters
have to be implemented in a way, that logic it portable/runnable across
different HTTP Server implementation. There are a lot of open questions
here. I did not want them to be opened.

I was building on only my trusted W520 Linux box :) I found (based on the
GIT Ignore file :D ) you guys are more-or-less on Macs. To be honest,
I am using CMake for the first time - with start of my involvement with
Celix. So yes, there is room for improvements. Thank you for the update,
will be used.

At first I thought Celix is soo soo complex project, I started my own
uOSGI project. Found some people from around the Internet that were doing
the same, but -- well, it has to be complex as it is not a simple task;
event if it seems to be simple. So one year later I took another look
at the Celix project and wrote to Bjoern -- to get this "monster" built.
The documentation should be updated or if not relevant: deleted! :) It
made me wast more time than it was of good use to me.
But than you get into the flow and I was able to read/locate pieces of
source code that I needed and it was really easy -- it is all easy if you
have a good starting point.

With Kubernetes project I mean INAETICS project, yes. As, I said before,
in Java one of the first things you do is a cluster :D If you want performance.
So to have all this in a package: INAETICS project. It was a good day,
that day - I found/built/deployed INAETICS project. Really nice work.
Again, the docs could be better :D ; but, Bjoern pointed me to the updated
documents and added some pointers and it all worked in the first try.


I agree that HTTP is missing in Celix. To me, it is all about HTTP; I do
not know you guys. I guess you "play" with signals and bits; but I play
with massive HTTP traffic -- so "more or less" looking for a HTTP Service.


I am more at home with C++ than with C. Well, when you learn about C++,
you are told: this is like C plus classes; well, this is to not true and
total failed statement. It can be, do not get me wrong - but than just use
C; do not bother with C++. I was working with Java for ten years now and
my mind is somehow set on this OO style. It is difficult to think in a
way that C is set. I am not saying it is not the correct way, it is
different. Like Objective-C is different.
Well, for now I do not have any solid argument why use C++, to be honest.
Years I go I started to use Boost C++ for one project, and it worked
really well for me. So I used C++ more because of the Boost C++ library,
than because of the language.
Idea is to use (also) C++ as a HTTP server implementation; will see where
it goes.
I am picking arguments: what makes C so much better - is it simple syntax,
performance, common dominator, ...

I use GCC, tried with Clang/LLVM but did not use it afterwards. When I
was playing about my own OSGi platform, I first fall into a trap - how to
load modules in runtime. In short: due to "C++ name mangling" it is not
possible to make pure C++ plugin. It is, but than again - you are quite
on the same level as to use existing C way. I do not know about the other
languages - like C, Rust. I do not like Swift, but not for the language;
I just do not like an idea of new languages being introduced. I see no
real value in it. Objective-C has it all, but this is how I see it.


I wrote PoC bundles that use Boost C++ and was able to trap events and
do all sorts of things with the bundle -- as long as the activator.c was
as is. So to me, this is "100% C++" bundle.

Yes, I agree - the problem is in the cross-bundle/service usage of the
logic: use pure C++ abstract class in the C bundle. That would introduce
a lot of complexity. One solution I can think of is Apache Thrift. I am
not big fan of sucha solutions, but it promotes - it is up for the job.



Thank you for the review and comments. Much appreciated.


Kind Regards,
Miroslav

2015-12-03 21:58 GMT+01:00 Pepijn Noltes <pe...@gmail.com>:
> Hi,
>
> On Wed, Dec 2, 2015 at 10:56 PM Miroslav Beranič <
> 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 => 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 => 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 ...
>>
>
> 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=/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
>>
>>
> 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č
>> MIBESIS
>> +386(0)40/814-843
>> miroslav.beranic@mibesis.si
>> http://www.mibesis.si
>>



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

Re: Apache Celix (Simple) HTTP Service

Posted by Pepijn Noltes <pe...@gmail.com>.
Hi,

On Wed, Dec 2, 2015 at 10:56 PM Miroslav Beranič <
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 => 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 => 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 ...
>

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=/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
>
>
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č
> MIBESIS
> +386(0)40/814-843
> miroslav.beranic@mibesis.si
> http://www.mibesis.si
>