You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@celix.apache.org by MULDER Frank Willem <fr...@nl.thalesgroup.com> on 2011/08/29 15:48:19 UTC

some remarks and questions

Hello,

Some remarks/questions concerning Celix:


1.       For several applications, I need to select and follow a service, based on its properties. In  the current service tracker implementation, on service creation, one can only give the service class name as a parameter. In the Felix (java OSGi) implementation one can, alternatively, give a LDAP filter as parameter. The full Felix interface needs to be provided in Celix.


2.       The processing of a bundle's manifest file (in celix) is not robust for whitespace and lacking carriage returns, e.g. in the Services-Import/Export lists.  I don't know whether the OSGi spec says something about this, but it would save the developers a lot of time when robustness was built in.


3.       In some OSGi applications a resource file is used, see e.g. the paint example of the book "OSGi in Action". Here some .png files are used in the application to display icons on a user interface. In the book "OSGi in Action" it is possible to get resources through the bundle object, see listing 3.17 of "OSGi in action". Is the resource interface already implemented in Celix?



4.       I have implemented some of the easier examples of the book 'OSGi in action' (that concerns Felix, a java implementation of OSGi) in celix. I have sent the code to 'celix' and hope that these will be provided in celix's svn repository in the near future.


5.       In the Celix environment, cmake is used for building.  I have an implementation of the paint-example in Celix, that uses the GDK environment as an external library. In the makefiles of GDK applications, one generally uses the 'pkg-config' tool to find information about include-files and libraries of GDK.  In cmake one can use the FindPkgConfig macro, by adding the following lines:


include(FindPkgConfig)
...
pkg_search_module(GLIB REQUIRED glib-2.0)
pkg_search_module(GTHR REQUIRED gthread-2.0)
pkg_search_module(GTK REQUIRED gtk+-2.0)
...
include_directories(${GTK_INCLUDE_DIRS})
include_directories (${GLIB_INCLUDE_DIRS})
include_directories (${GTHR_INCLUDE_DIRS})
...
link_directories(${GTK_LINK_DIRS})
link_directories (${GLIB_ LINK_DIRS})
link_directories (${GTHR_ LINK _DIRS})
...
target_link_libraries(${_targetname} pthread ${GLIB_LIBRARIES} ${GTK_LIBRARIES} ${GTHR_LIBRARIES})

                                Under MacOS, cmake has some problems using the link directories, communicated in the 'link_directories()' commands in the 'target_link_libraries()' command. The 'pkg_search_module()' finds the correct link directories. I need to look deeper in this problem, but maybe someone already has experience with cmake files and knows the solution to the problem.

Gr. Frank Mulder




------------------------------------------------------------------------------------------------------------
Disclaimer:

If you are not the intended recipient of this email, please notify the sender and delete it. 
Any unauthorized copying, disclosure or distribution of this email or its attachment(s) is forbidden. 
Thales Nederland BV will not accept liability for any damage caused by this email or its attachment(s). 
Thales Nederland BV is seated in Hengelo and is registered at the Chamber of Commerce under number 06061578.
------------------------------------------------------------------------------------------------------------



Re: some remarks and questions

Posted by Alexander Broekhuis <a....@gmail.com>.
Hi,

Could you post a new thread for new questions? Someone searching for
something might now miss posts, since an "old" thread is being continued.


>                The paint example in Celix uses Gtk as GUI package. I have
> several bundles that perform GUI actions, however the GUI is initialized in
> the activation of one paint-frame bundle. The activation of the paint-frame
> bundle should therefore be done before the other bundles are activated
> because they also use Gtk facilities. Do you have  a suggestion how to
> organize this?
>
>
Short answer, let the paint-frame bundle expose a service and use a service
tracker to depend on it.

Longer answer:
The OSGi spec describes something like start levels which can be used, Celix
doesn't support this. But looking at the inherent dynamic behaviour I thinks
it is also a bad usage model in most (if not all) cases. For example, if
start levels are used, but later on a bundle would be updated (or even
uninstalled) all bundles implicitly depending on the first bundle might
start behaving strange.

A proper solution for this would be to make all other components (requiring
the gtk initialization) depend on the first component. To solve this, the
initialization component can expose a service (might even be an empty
service which is only used for tracking). This service can then be tracked
by a service tracker which can be used to properly activate all other
bundles.

To make this easier, Celix provides a basic implementation of a Dependency
Manager (dm).. Basically this manager takes care of tracking and resolving
service dependencies. It provides an additional state model for services
(OSGi already provides a bundle state model). Using the dm it is possible to
add dependencies to components (required and/or unrequired). For required
dependencies the dm blocks activation of the component until they are all
resolved.

The whiteboard/tracker_depman uses the dm, and provides an example on how to
use it yourself.

Hth!


-- 
Met vriendelijke groet,

Alexander Broekhuis

RE: some remarks and questions

Posted by MULDER Frank Willem <fr...@nl.thalesgroup.com>.
Hi,

	This information was very useful. Now I have another problem:

		The paint example in Celix uses Gtk as GUI package. I have several bundles that perform GUI actions, however the GUI is initialized in the activation of one paint-frame bundle. The activation of the paint-frame bundle should therefore be done before the other bundles are activated because they also use Gtk facilities. Do you have  a suggestion how to organize this? 

Thanks: Frank


-----Original Message-----
From: Alexander Broekhuis [mailto:a.broekhuis@gmail.com] 
Sent: Thursday, 08 September, 2011 17:16
To: celix-dev@incubator.apache.org
Subject: Re: some remarks and questions

Hi

       I'm using the function bundle_getEntry(..) to read a resource file
> within the bundle. However I need to know the number of bytes read in 
> the function. Is this lacking in the API, or can I find this 
> information elsewhere?
>
>
Perhaps there is a misunderstanding about what this method does, the bundle_getEntry return a path to the actual entry. Opening and reading the file is up to the user (you). The entry pointer provides a regular (0
terminated) string with the location of the entry in the bundle cache.

So Celix doesn't read anything, and can't tell you the number of bytes read.

Does this answer your question?

--
Met vriendelijke groet,

Alexander Broekhuis

------------------------------------------------------------------------------------------------------------
Disclaimer:

If you are not the intended recipient of this email, please notify the sender and delete it. 
Any unauthorized copying, disclosure or distribution of this email or its attachment(s) is forbidden. 
Thales Nederland BV will not accept liability for any damage caused by this email or its attachment(s). 
Thales Nederland BV is seated in Hengelo and is registered at the Chamber of Commerce under number 06061578.
------------------------------------------------------------------------------------------------------------


Re: some remarks and questions

Posted by Alexander Broekhuis <a....@gmail.com>.
Hi

       I'm using the function bundle_getEntry(..) to read a resource file
> within the bundle. However I need to know the number of bytes read in the
> function. Is this lacking in the API, or can I find this information
> elsewhere?
>
>
Perhaps there is a misunderstanding about what this method does, the
bundle_getEntry return a path to the actual entry. Opening and reading the
file is up to the user (you). The entry pointer provides a regular (0
terminated) string with the location of the entry in the bundle cache.

So Celix doesn't read anything, and can't tell you the number of bytes read.

Does this answer your question?

-- 
Met vriendelijke groet,

Alexander Broekhuis

RE: some remarks and questions

Posted by MULDER Frank Willem <fr...@nl.thalesgroup.com>.
Hello,

	I'm using the function bundle_getEntry(..) to read a resource file within the bundle. However I need to know the number of bytes read in the function. Is this lacking in the API, or can I find this information elsewhere?

Thanks: Frank Mulder


-----Original Message-----
From: Marcel Offermans [mailto:marcel.offermans@luminis.nl] 
Sent: Tuesday, 30 August, 2011 23:57
To: celix-dev@incubator.apache.org
Subject: Re: some remarks and questions

On 30 Aug 2011, at 21:08 , Alexander Broekhuis wrote:

>> -------  I must admit that I don't know the difference between 
>> getEntry() and getResource().  I need to look further into these API's.
> 
> Following the OSGi spec, getResource looks in the bundle classpath, 
> while getEntry only looks in the bundle itself. The difference being 
> that with getResource one could end up with a resource from a 
> different bundle (as it might be imported by the current bundle).
> 
> Since Celix doesn't have a concept like bundle classpath, it is save 
> to assume you have to use getEntry. Missing is the "getEntryPaths" 
> function to get a list of entries.

You could also say that the bundle classpath in Celix is "everything in the current bundle" which would make both methods equal (and perhaps it does not make too much sense implementing both).

Greetings, Marcel


------------------------------------------------------------------------------------------------------------
Disclaimer:

If you are not the intended recipient of this email, please notify the sender and delete it. 
Any unauthorized copying, disclosure or distribution of this email or its attachment(s) is forbidden. 
Thales Nederland BV will not accept liability for any damage caused by this email or its attachment(s). 
Thales Nederland BV is seated in Hengelo and is registered at the Chamber of Commerce under number 06061578.
------------------------------------------------------------------------------------------------------------


Re: some remarks and questions

Posted by Marcel Offermans <ma...@luminis.nl>.
On 30 Aug 2011, at 21:08 , Alexander Broekhuis wrote:

>> -------  I must admit that I don't know the difference between getEntry()
>> and getResource().  I need to look further into these API's.
> 
> Following the OSGi spec, getResource looks in the bundle classpath, while
> getEntry only looks in the bundle itself. The difference being that with
> getResource one could end up with a resource from a different bundle (as it
> might be imported by the current bundle).
> 
> Since Celix doesn't have a concept like bundle classpath, it is save to
> assume you have to use getEntry. Missing is the "getEntryPaths" function to
> get a list of entries.

You could also say that the bundle classpath in Celix is "everything in the current bundle" which would make both methods equal (and perhaps it does not make too much sense implementing both).

Greetings, Marcel


Re: some remarks and questions

Posted by Alexander Broekhuis <a....@gmail.com>.
Hi,

>
> ----- I added issue CELIX-17
>

Fixed.


> -------  I must admit that I don't know the difference between getEntry()
> and getResource().  I need to look further into these API's.
>

Following the OSGi spec, getResource looks in the bundle classpath, while
getEntry only looks in the bundle itself. The difference being that with
getResource one could end up with a resource from a different bundle (as it
might be imported by the current bundle).

Since Celix doesn't have a concept like bundle classpath, it is save to
assume you have to use getEntry. Missing is the "getEntryPaths" function to
get a list of entries.


>
> ----- I have installed GTK on the mac and with make (i.s.o cmake) the
> pkg-config command works fine.  If you don't have a solution readily
> available, I'll look into it myself, as it is not really related to Celix
>

If you've got some small test code, feel free to email it to me directly,
having an example in Celix which uses some widgets would be a cool use case
to show the possibilities. So I'd like to get something like this working.

-- 
Met vriendelijke groet,

Alexander Broekhuis

RE: some remarks and questions

Posted by MULDER Frank Willem <fr...@nl.thalesgroup.com>.
Hello,

        Thanks for your replies, herewith my responses (in bold characters):

-----Original Message-----
From: Alexander Broekhuis [mailto:a.broekhuis@gmail.com]
Sent: Monday, 29 August, 2011 23:03
To: celix-dev@incubator.apache.org
Subject: Re: some remarks and questions

Hi Frank,

Thanks for your interest in Celix! See my answers inline.

1.       For several applications, I need to select and follow a service,
> based on its properties. In  the current service tracker
> implementation, on service creation, one can only give the service class name as a parameter.
> In the Felix (java OSGi) implementation one can, alternatively, give a
> LDAP filter as parameter. The full Felix interface needs to be provided in Celix.
>

First off all, it is important to understand that Celix isn't simply an implementation of Felix in C. It goes a little further, it tries to implement the OSGi specification in C. (Felix probably is a good reference for this, but not leading). For example, the ServiceTracker is a utility made available by the OSGi Alliance, and not made by the Felix team.

To answer the actual question, the Celix service tracker is indeed missing this API, and this has to be added. Please add a bug entry to our Jira ( http://incubator.apache.org/celix/support/issuetracking.html).

----- I added issue CELIX-17


>
> 2.       The processing of a bundle's manifest file (in celix) is not
> robust for whitespace and lacking carriage returns, e.g. in the
> Services-Import/Export lists.  I don't know whether the OSGi spec says
> something about this, but it would save the developers a lot of time
> when robustness was built in.
>

I am not sure on this one, the answer is probably two-fold. First, the manifest files in OSGi follow the Java JAR manifest file rules. These rules state that a manifest file has to end with a newline. So this is intended behaviour.
The second one is probably a bug, again, please add a bug.

------------- I created issue CELIX-18



> 3.       In some OSGi applications a resource file is used, see e.g. the
> paint example of the book "OSGi in Action". Here some .png files are
> used in the application to display icons on a user interface. In the
> book "OSGi in Action" it is possible to get resources through the
> bundle object, see listing 3.17 of "OSGi in action". Is the resource
> interface already implemented in Celix?
>
>
I am not sure what interface the examples use, but as of now this is limited in Celix to only the "bundle_getEntry" method to retrieve a named entry from the bundle.

Again (as you probably guessed ;)), feel free to add bugs for the missing functions.

-------  I must admit that I don't know the difference between getEntry() and getResource().  I need to look further into these API's.


>
> 4.       I have implemented some of the easier examples of the book 'OSGi
> in action' (that concerns Felix, a java implementation of OSGi) in
> celix. I have sent the code to 'celix' and hope that these will be
> provided in celix's svn repository in the near future.
>

The examples are greatly appreciated! If I find some time, I will definitely add them. First I would like to browse a little through the code and see if it all fits in the current structure.


> 5.       In the Celix environment, cmake is used for building.  I have an
> implementation of the paint-example in Celix, that uses the GDK
> environment as an external library. In the makefiles of GDK
> applications, one generally uses the 'pkg-config' tool to find
> information about include-files and libraries of GDK.  In cmake one
> can use the FindPkgConfig macro, by adding the following lines:
>
>                                Under MacOS, cmake has some problems
> using the link directories, communicated in the 'link_directories()'
> commands in the 'target_link_libraries()' command. The
> 'pkg_search_module()' finds the correct link directories. I need to
> look deeper in this problem, but maybe someone already has experience
> with cmake files and knows the solution to the problem.
>

This one I can't answer easily, I would have to take a look into it. Isn't this something related to the fact that GTK normally isn't available for the mac?

----- I have installed GTK on the mac and with make (i.s.o cmake) the pkg-config command works fine.  If you don't have a solution readily available, I'll look into it myself, as it is not really related to Celix

Agains, thanks for your interest, looking forward to more!


--
Met vriendelijke groet,

Alexander Broekhuis



------------------------------------------------------------------------------------------------------------
Disclaimer:

If you are not the intended recipient of this email, please notify the sender and delete it. 
Any unauthorized copying, disclosure or distribution of this email or its attachment(s) is forbidden. 
Thales Nederland BV will not accept liability for any damage caused by this email or its attachment(s). 
Thales Nederland BV is seated in Hengelo and is registered at the Chamber of Commerce under number 06061578.
------------------------------------------------------------------------------------------------------------



Re: some remarks and questions

Posted by Alexander Broekhuis <a....@gmail.com>.
Hi Frank,

Thanks for your interest in Celix! See my answers inline.

1.       For several applications, I need to select and follow a service,
> based on its properties. In  the current service tracker implementation, on
> service creation, one can only give the service class name as a parameter.
> In the Felix (java OSGi) implementation one can, alternatively, give a LDAP
> filter as parameter. The full Felix interface needs to be provided in Celix.
>

First off all, it is important to understand that Celix isn't simply an
implementation of Felix in C. It goes a little further, it tries to
implement the OSGi specification in C. (Felix probably is a good reference
for this, but not leading). For example, the ServiceTracker is a utility
made available by the OSGi Alliance, and not made by the Felix team.

To answer the actual question, the Celix service tracker is indeed missing
this API, and this has to be added. Please add a bug entry to our Jira (
http://incubator.apache.org/celix/support/issuetracking.html).


>
> 2.       The processing of a bundle's manifest file (in celix) is not
> robust for whitespace and lacking carriage returns, e.g. in the
> Services-Import/Export lists.  I don't know whether the OSGi spec says
> something about this, but it would save the developers a lot of time when
> robustness was built in.
>

I am not sure on this one, the answer is probably two-fold. First, the
manifest files in OSGi follow the Java JAR manifest file rules. These rules
state that a manifest file has to end with a newline. So this is intended
behaviour.
The second one is probably a bug, again, please add a bug.



> 3.       In some OSGi applications a resource file is used, see e.g. the
> paint example of the book "OSGi in Action". Here some .png files are used in
> the application to display icons on a user interface. In the book "OSGi in
> Action" it is possible to get resources through the bundle object, see
> listing 3.17 of "OSGi in action". Is the resource interface already
> implemented in Celix?
>
>
I am not sure what interface the examples use, but as of now this is limited
in Celix to only the "bundle_getEntry" method to retrieve a named entry from
the bundle.

Again (as you probably guessed ;)), feel free to add bugs for the missing
functions.


>
> 4.       I have implemented some of the easier examples of the book 'OSGi
> in action' (that concerns Felix, a java implementation of OSGi) in celix. I
> have sent the code to 'celix' and hope that these will be provided in
> celix's svn repository in the near future.
>

The examples are greatly appreciated! If I find some time, I
will definitely add them. First I would like to browse a little through the
code and see if it all fits in the current structure.


> 5.       In the Celix environment, cmake is used for building.  I have an
> implementation of the paint-example in Celix, that uses the GDK environment
> as an external library. In the makefiles of GDK applications, one generally
> uses the 'pkg-config' tool to find information about include-files and
> libraries of GDK.  In cmake one can use the FindPkgConfig macro, by adding
> the following lines:
>
>                                Under MacOS, cmake has some problems using
> the link directories, communicated in the 'link_directories()' commands in
> the 'target_link_libraries()' command. The 'pkg_search_module()' finds the
> correct link directories. I need to look deeper in this problem, but maybe
> someone already has experience with cmake files and knows the solution to
> the problem.
>

This one I can't answer easily, I would have to take a look into it. Isn't
this something related to the fact that GTK normally isn't available for the
mac?

Agains, thanks for your interest, looking forward to more!


-- 
Met vriendelijke groet,

Alexander Broekhuis