dev@glassfish.java.net

Re: How to make META-INF/mailcap visible to Java EE apps [Was: Re: OSGi confusion...]

From: Sahoo <Sahoo_at_Sun.COM>
Date: Sat, 23 May 2009 17:58:30 +0530

Bill Shannon wrote:
> Richard S. Hall wrote:
>>> If I have an OSGi bundle and I want to export all my resources in
>>> META-INF, I should export the "package" META-INF? There's no way
>>> to export an individual resource?
>>
>> Conceptually, you are correct, but in practice that really doesn't
>> make a lot of sense in pure OSGi since in this model you want to be
>> able to see more than one (or all) META-INF "packages", but a bundle
>> importing "META-INF" will only be able to see it from one bundle.
>>
>> This is why the extender pattern is used here, since it probes all
>> META-INF directories, which is what you want.
>
> The problem is we're not in a pure OSGi environment. In many ways OSGi
> is just an implementation detail. At best we're in a transitional stage
> where things need to work in an OSGi and non-OSGi environment.
>
> If there's a way to probe all the META-INF directories, why can't the
> OSGi
> class loader do that when I try to load a resource?
>
Although this is doable, it kinds of breaks modularity, so it has not
been done for all kinds of resources. We had implemented it for
META-INF/services only and now we added support for META-INF/mailcap.
Those two make sense, as the bundle that's looking for the resources
does not want to know about the bundle supplying the resources. Are
there other such resources?

An alternative way to achieve this is to package such resources in a
separate jar and make the jar available in glassfish lib directory.

Thanks,
Sahoo