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/09/08 16:00:27 UTC

RE: some remarks and questions

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