You are viewing a plain text version of this content. The canonical link for it is here.
Posted to dev@felix.apache.org by "Steven E. Harris" <se...@panix.com> on 2007/02/07 20:53:32 UTC

Re: OBR Resource from a Bundle

"Richard S. Hall" <he...@ungoverned.org> writes:

Thanks for the suggestions so far.

> I think I slightly modified the original OBR interfaces, though, but
> we can probably deal with that by extending the original interface
> definitions.

This looks easy to achieve.

> Regardless, this means that it may now be possible to use
> ManifestParser to convert manifests to capabilities/
> requirements...or at least it will be in the future. So, we have an
> option now of using the existing OBR approach or adopting the
> ManifestParser if it will be sufficient (or moving in that direction
> later if need be).

I started looking into using ManifestParser. A problem arises with the
ManifestParser constructor. First, I need to get ahold of a
PropertyResolver instance. The Felix class exposes one with
getConfig(), but I can't get back "out" to Felix from within one of my
bundles.

The logger and headerMap parameters are easy enough to provide. If I
knew how to get a PropertyResolver from within a bundle, I could start
experimenting with using ManifestParser to write the Bundle->Resource
conversion function.

-- 
Steven E. Harris

Re: OBR Resource from a Bundle

Posted by "Steven E. Harris" <se...@panix.com>.
"Steven E. Harris" <se...@panix.com> writes:

> Is there some way short of writing another such class to get from a
> Dictionary to a Map?

Oh, maybe copy-construct a new java.util.Hashtable, providing the Map
to the constructor, and taking advantage of Hashtable implementing the
Dictionary interface. Unfortunately, we'd have to copy all the
mappings, rather than just providing an adapted view of them.

-- 
Steven E. Harris

Re: OBR Resource from a Bundle

Posted by "Richard S. Hall" <he...@ungoverned.org>.
Steven E. Harris wrote:
> "Richard S. Hall" <he...@ungoverned.org> writes:
>
>   
>> In truth, we could avoid passing this into the constructor and pass it
>> into the getLibraries() instead, then you wouldn't need it at all,
>> since you don't need to call this method for converting a bundle to a
>> resource.
>>     
>
> I just made that change, and only had to correct one constructor call
> and one method call elsewhere.
>
>   
>> Admittedly, ManifestParser is still a little bit rough around the
>> edges for this purpose, but it definitely has the basics. It currently
>> has the ability to:
>>
>>    * Convert bundle symbolic name and package export to capabilities.
>>    * Convert require-bundle and package import to requirements.
>>     
>
> That's probably all I need here.
>
> On to the next small problem: ManifestParser wants a java.util.Map as
> its "header map". Bundle.getHeaders() returns a
> java.util.Dictionary. I see that there's a MapToDictionary class in
> Felix already. Is there some way short of writing another such class
> to get from a Dictionary to a Map?
>
> Funny, I see that BundleInfo.getCurrentLocalizedHeader(String) returns
> a Map, which is converted to a Dictionary by Bundle.getHeaders().
>   

Yep. We generally only use Map/List, but the OSGi R1 spec stuck us with 
Dictionary...perhaps we could make MapToDictionary also implement Map?

-> richard

Re: OBR Resource from a Bundle

Posted by "Steven E. Harris" <se...@panix.com>.
"Richard S. Hall" <he...@ungoverned.org> writes:

> In truth, we could avoid passing this into the constructor and pass it
> into the getLibraries() instead, then you wouldn't need it at all,
> since you don't need to call this method for converting a bundle to a
> resource.

I just made that change, and only had to correct one constructor call
and one method call elsewhere.

> Admittedly, ManifestParser is still a little bit rough around the
> edges for this purpose, but it definitely has the basics. It currently
> has the ability to:
>
>    * Convert bundle symbolic name and package export to capabilities.
>    * Convert require-bundle and package import to requirements.

That's probably all I need here.

On to the next small problem: ManifestParser wants a java.util.Map as
its "header map". Bundle.getHeaders() returns a
java.util.Dictionary. I see that there's a MapToDictionary class in
Felix already. Is there some way short of writing another such class
to get from a Dictionary to a Map?

Funny, I see that BundleInfo.getCurrentLocalizedHeader(String) returns
a Map, which is converted to a Dictionary by Bundle.getHeaders().

-- 
Steven E. Harris

Re: OBR Resource from a Bundle

Posted by "Richard S. Hall" <he...@ungoverned.org>.
Steven E. Harris wrote:
> "Richard S. Hall" <he...@ungoverned.org> writes:
>
> Thanks for the suggestions so far.
>
>   
>> I think I slightly modified the original OBR interfaces, though, but
>> we can probably deal with that by extending the original interface
>> definitions.
>>     
>
> This looks easy to achieve.
>
>   
>> Regardless, this means that it may now be possible to use
>> ManifestParser to convert manifests to capabilities/
>> requirements...or at least it will be in the future. So, we have an
>> option now of using the existing OBR approach or adopting the
>> ManifestParser if it will be sufficient (or moving in that direction
>> later if need be).
>>     
>
> I started looking into using ManifestParser. A problem arises with the
> ManifestParser constructor. First, I need to get ahold of a
> PropertyResolver instance. The Felix class exposes one with
> getConfig(), but I can't get back "out" to Felix from within one of my
> bundles.
>
> The logger and headerMap parameters are easy enough to provide. If I
> knew how to get a PropertyResolver from within a bundle, I could start
> experimenting with using ManifestParser to write the Bundle->Resource
> conversion function.
>   

You don't need to get the PropertyResolver that Felix uses, you can 
create your own instance...it is essentially a map. The only thing that 
it is used for is to determine that matching set of libraries from the 
available libraries. It essentially examines osname and processor to 
determine which of the available native code libraries are appropriate 
for the current platform.

In truth, we could avoid passing this into the constructor and pass it 
into the getLibraries() instead, then you wouldn't need it at all, since 
you don't need to call this method for converting a bundle to a 
resource. In this case, ManifestParser is also helping out with some 
runtime issues. We might find that some of this stuff has to be cleaned 
up to some degree.

Admittedly, ManifestParser is still a little bit rough around the edges 
for this purpose, but it definitely has the basics. It currently has the 
ability to:

    * Convert bundle symbolic name and package export to capabilities.
    * Convert require-bundle and package import to requirements.

At a minimum, it still needs a mechanism to convert native code headers 
to requirements.

-> richard