Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

关于宿主和插件进程间通信 #31

Closed
Dan-Humphrey opened this issue Jul 4, 2019 · 2 comments
Closed

关于宿主和插件进程间通信 #31

Dan-Humphrey opened this issue Jul 4, 2019 · 2 comments

Comments

@Dan-Humphrey
Copy link

我看插件的binder目前没有通过PluginManagerService暴露出来;宿主或者其他插件怎么做到多进程通信。通过每个插件自己的PPS分发么

@shifujun
Copy link
Collaborator

shifujun commented Jul 4, 2019

这个问题被问到的确实多诶😅 我应该补几个例子。

先在这文字说明一下。

宿主和插件的Service,都可以跨进程的相互使用。

插件的Service由于没有在系统中注册,所以不能直接用context使用。要通过PPS上的startPluginService或者bindPluginService方法使用。

但是在同一个插件内部,是可以正常用context使用的。因为context是被Shadow管理的。

同一个进程中只能有一个Loader,一个Loader可以同时启动多个插件,所以一个Loader的多个插件之间也是可以直接用context使用Service的。

除了Service这种最工程化的通信手段。也可以允许插件访问宿主中的一些类,通过在白名单注册一些类,允许插件直接访问宿主的类。可以利用这一点,将宿主的一些类做成单独的jar,宿主打包,插件编译。

@shifujun
Copy link
Collaborator

shifujun commented Jul 8, 2019

刚刚提交了一个例子
d25da55

后面再补充其他场景。

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants