How to support ServiceLoader.load(class, class.ClassLoader)

classic Classic list List threaded Threaded
2 messages Options
Reply | Threaded
Open this post in threaded view
|

How to support ServiceLoader.load(class, class.ClassLoader)

huan.linying
Hi,


I'm trying to covert io.grpc.* library to OSGI bundle and I'm using aries spi-fly to resolve service loader problem. But It seems that ASF can not work if the jar use load(class, classloader) api. I found some mail-pipeline about this problem in 2013:


http://mail-archives.apache.org/mod_mbox/aries-user/201310.mbox/browser


I'd like to know is there any way to resolve this problem now?












Thanks!













宦林英 Huan Linying






南京协议开发三部/有线研究院/有线产品经营部 Nanjing Protocol Development Dept. III/Wireline Product Operation Division









南京市雨花台区紫荆花路68号
Nanjing city Yuhuatai District Bauhinia Flower Road No.68

M: +86 13182845505
E: [hidden email]
www.zte.com.cn

=?UTF-8?B?MjQyNDJlNTYzN2FmNDI4ODkxYzRkYjczMWU3NzY1YWQuanBn?= (2K) Download Attachment
=?UTF-8?B?OWFlM2UyMTRjMTdkNDllZDkzNWQ4N2M2NzRiYTNlZTIuanBn?= (8K) Download Attachment
Reply | Threaded
Open this post in threaded view
|

Re: How to support ServiceLoader.load(class, class.ClassLoader)

David Bosschaert
Hi Huan,

When you're calling ServiceLoader.load(Class, ClassLoader) you are already explicitly specifying an actual classloader. So you should not need to use Aries SPI-Fly at all, but just need to ensure that the classloader provided is the right one. SPI Fly (and the OSGi ServiceLoader Mediator spec) is about handling the implicit classloader used with ServiceLoader.load(Class).

If for some reason you the code that calls ServiceLoader.load(Class, ClassLoader) is not passing the right classloader then I think the best way would be to fix that code. 
I guess SPI Fly could support a scenario like this but it would mean that existing actual code is changed, rather then additonal code inserted. I'm not too sure if that is really the best thing to do, but if there is a need for it then I think it could be considered as an addition, if someone proposes a patch...

Cheers,

David



On 24 July 2017 at 12:46, <[hidden email]> wrote:

Hi, 

I'm trying to covert io.grpc.* library to OSGI bundle and I'm using aries spi-fly to resolve service loader problem. But It seems that ASF can not work if the jar use load(class, classloader) api. I found some mail-pipeline about this problem in 2013:

http://mail-archives.apache.org/mod_mbox/aries-user/201310.mbox/browser

I'd like to know is there any way to resolve this problem now?


Thanks!


宦林英 Huan Linying


南京协议开发三部/有线研究院/有线产品经营部 Nanjing Protocol Development Dept. III/Wireline Product Operation Division



南京市雨花台区紫荆花路68号 

Nanjing city Yuhuatai District Bauhinia Flower Road No.68

M: <a href="tel:+86%20131%208284%205505" value="+8613182845505" target="_blank">+86 13182845505
E: [hidden email]
www.zte.com.cn