Felix Meschberger wrote:
Hi,

Am Mittwoch, den 16.01.2008, 13:37 -0500 schrieb Richard S. Hall:
Guillaume Sauthier wrote:
After a bit of thinking, I was wondering if a possible solution could be to have the ability to change the ContentClassLoader implementation.

If something like this was present, I could have my own JDK5 only ContentClassLoader that extends ContentClassLoader and override the getResources method.

What do you think ?
May I start to create a patch for that ?
Certainly you can do that for your own project, but I am not sure how easily it could be integrated into Felix...this is a case where we could use #ifdef, I guess. :-)

With a bit of hackery: Have a factory method creating the
ContentClassLoader instances, which decides at runtime, whether to
create a pre-5 ContentClassLoader or a 5+ ContentClassLoader. But I will
certainly advocate for such a solution here :-)

I assume you meant to say, "...will certainly NOT advocate..."

But reconsidering the initial problem mentioned by Guillaume: Only local
resources returned. I am not sure why Guillaume mentions the
ContentClassLoader, because the main accessor to resource Enumeration is
the Bundle.getResources method. So I dug into how Bundle.getResources is
actually implemented down to the
org.apache.felix.framework.searchpolicy.R4SearchPolicyCore.findResources() 
method. And then, something stroke me in this method:

Instead of returning a combined enumeration of all resources found, the
method aborts upon first success:

   * If an Enumeration is returned as per the boot delegation, this is
returned ignoring the
     wires and bundle
   * If an Enumeration is returned in a wire, this is returned ignoring
any other wires and
     the bundle
   * Then the bundle is searched and returned if found
   * Finally dynamic imports are returned tested

I think, the method should rather gather all enumerations and returned a
combined enumeration over all results ...

WDYT ?

Yes, I think you are correct.

-> richard

Regards
Felix

-> richard

Thanks
--Guillaume

Guillaume Sauthier wrote:
Thanks for your input Felix
That was not the answer I was expecting :)

Anyway, do you have any idea about how to workaround this problem ?

Thanks
--Guillaume


Felix Meschberger wrote:
Hi Guillaume,

The problem with this method is, that upto and including Java 1.4 it is
marked final. It is not final anymore starting with Java 5.. So, the
ContentClassLoader cannot overwrite.

Hope this helps.

Regards
Felix

Am Mittwoch, den 16.01.2008, 17:09 +0100 schrieb Guillaume Sauthier:
Hi team

I've just noticed that the ContentClassLoader do not override the ClassLoader.getResources(String) method. It only override the ClassLoader.getResource(String method). Notice the final 's', one of theses methods is returning an Enumeration, not the other one. Moreover, the ISearchPolicy, that is used under the hood to find resources have a findResources(String):Enumeration method :)

I expect getResources() to list resources available to the bundle (using OSGi constraints), not only "local" resources, which is the current behavior.

This is probably something forgotten :)
Can you enlight me ? Is this normal, or not ?

Cheers
--Guillaume

Reply via email to