sofastack / sofa-ark

SOFAArk is a light-weight,java based classloader isolation framework.
https://www.sofastack.tech/projects/sofa-boot/sofa-ark-readme/
Apache License 2.0
1.56k stars 497 forks source link

Plugin released services #321

Closed howtobegin closed 4 years ago

howtobegin commented 4 years ago

Plugin发布的服务问题 1、如何使用? 2、什么场景可能会用到其他plugin发布的服务

例子 有2个plugin,分别为plugin-A,plugin-B 1、plugin-A在插件入口实现类SamplePluginActivator中注册了context.publishService(SamplePluginService.class, new SamplePluginServiceImpl()); 2、plugin-B也在插件入口实现类SamplePluginActivator中注册了context.publishService(SamplePluginService.class, new SamplePluginServiceImpl()); 3、通过如下方式没有拿到发布的服务,得到ClassNotFoundException错误 ArkServiceContainerHolder.getContainer().getService(RegistryService.class).referenceService(SamplePluginService.class)

请问这个报错是什么原因,应该怎么获取plugin发布的服务?

sofastack-bot[bot] commented 4 years ago

Hi @tensecond, we detect non-English characters in the issue. This comment is an auto translation by @sofastack-robot to help other users to understand this issue.

We encourage you to describe your issue in English which is more friendly to other users.

Service issues released by Plugin 1. How to use it? 2, what scenarios may use other plugin published service examples have 2 plugins, plugin-A, plugin-B 1, plugin-A registered in the plugin entry implementation class SamplePluginActivator context.publishService (SamplePluginService.class, New SamplePluginServiceImpl()); 2, plugin-B is also registered in the plugin entry implementation class SamplePluginActivator context.publishService(SamplePluginService.class, new SamplePluginServiceImpl()); 3, through the following way did not get the published service, get ClassNotFoundException error ArkServiceContainerHolder.getContainer().getService(RegistryService.class).referenceService(SamplePluginService.class) What is the reason for this error, how should I get the service released by plugin?

glmapper commented 4 years ago

@tensecond 可以参考下 SOFAArk 中 web 插件和 config 插件实现