You are viewing a plain text version of this content. The canonical link for it is here.
Posted to user@aries.apache.org by hu...@zte.com.cn on 2017/07/24 11:46:31 UTC

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

SGksIA0KDQoNCkknbSB0cnlpbmcgdG8gY292ZXJ0IGlvLmdycGMuKiBsaWJyYXJ5IHRvIE9TR0kg
YnVuZGxlIGFuZCBJJ20gdXNpbmcgYXJpZXMgc3BpLWZseSB0byByZXNvbHZlIHNlcnZpY2UgbG9h
ZGVyIHByb2JsZW0uIEJ1dCBJdCBzZWVtcyB0aGF0IEFTRiBjYW4gbm90IHdvcmsgaWYgdGhlIGph
ciB1c2UgbG9hZChjbGFzcywgY2xhc3Nsb2FkZXIpIGFwaS4gSSBmb3VuZCBzb21lIG1haWwtcGlw
ZWxpbmUgYWJvdXQgdGhpcyBwcm9ibGVtIGluIDIwMTM6DQoNCg0KaHR0cDovL21haWwtYXJjaGl2
ZXMuYXBhY2hlLm9yZy9tb2RfbWJveC9hcmllcy11c2VyLzIwMTMxMC5tYm94L2Jyb3dzZXINCg0K
DQpJJ2QgbGlrZSB0byBrbm93IGlzIHRoZXJlIGFueSB3YXkgdG8gcmVzb2x2ZSB0aGlzIHByb2Js
ZW0gbm93Pw0KDQoNCg0KDQoNCg0KDQoNCg0KDQoNCg0KVGhhbmtzIQ0KDQoNCg0KDQoNCg0KDQoN
Cg0KDQoNCg0KDQrlrqbmnpfoi7EgSHVhbiBMaW55aW5nDQoNCg0KDQoNCg0KDQrljZfkuqzljY/o
rq7lvIDlj5HkuInpg6gv5pyJ57q/56CU56m26ZmiL+aciee6v+S6p+WTgee7j+iQpemDqCBOYW5q
aW5nIFByb3RvY29sIERldmVsb3BtZW50IERlcHQuIElJSS9XaXJlbGluZSBQcm9kdWN0IE9wZXJh
dGlvbiBEaXZpc2lvbg0KDQoNCg0KDQoNCg0KDQoNCg0K5Y2X5Lqs5biC6Zuo6Iqx5Y+w5Yy657Sr
6I2G6Iqx6LevNjjlj7cgDQpOYW5qaW5nIGNpdHkgWXVodWF0YWkgRGlzdHJpY3QgQmF1aGluaWEg
Rmxvd2VyIFJvYWQgTm8uNjgNCg0KTTogKzg2IDEzMTgyODQ1NTA1DQpFOiBodWFuLmxpbnlpbmdA
enRlLmNvbS5jbiANCnd3dy56dGUuY29tLmNu


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

Posted by David Bosschaert <da...@gmail.com>.
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, <hu...@zte.com.cn> 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: +86 13182845505 <+86%20131%208284%205505>
> E: huan.linying@zte.com.cn
> www.zte.com.cn
>