Eclipse 声明性服务和视图(ContentProviders)之间如何通信

发布于 2024-07-08 10:01:33 字数 426 浏览 8 评论 0原文

假设您有一个带有各种视图的 Eclipse 插件,这些视图应该显示来自某个将数据推送到视图的 OSGi 包的数据。 我没有让每个视图都与 OSGi 包通信,而是有一个中间 Facade 类,它充当视图的黑板并管理视图与其他 OSGi 包之间的通信 —— 嗯,这就是理论。

出现问题的原因是 ui 包(带有视图和外观)使用声明性服务与另一个包(称为数据存储)进行通信。 由于数据存储从另一个源接收异步数据更新,因此它需要将内容推送到外观(以及其他包,如果可用)。 OSGi 实例化 Facade 以满足 DataStore 的 DS 配置上的基数要求,但视图由插件的 IApplication 实现实例化。 即使 IApplication 和 Facade 是同一个类,我也会得到两个彼此不认识的单独实例。

如何启用这些组件(插件应用程序、视图等和 OSGi 实例化外观)之间的通信?

Say you have an eclipse plugin with various views, these views should display data from some OSGi bundle that pushes data to the Views. Rather than have every view communicate with the OSGi bundle, I have an intermediate Facade class that acts as a blackboard for the views and manages communications between the views and the other OSGi bundle--well, that's the theory.

The problem comes about because the ui bundle (with the Views and the Facade) communicate with the other bundle (call it the DataStore) using Declarative Services. Since the Data Store receives asynchronous data updates from yet another source, it needs to push content to the Facade (and to other bundles, if they are available). OSGi instantiates the Facade to satisfy the requirements of the cardinality on the DataStore's DS configuration, but the views are instantiated by the Plugin's IApplication implementation. Even if the IApplication and the Facade are the same class, I get two separate instances that do not know of eachother.

How do I enable communication between these components (the plugin Application, Views, etc. and the OSGi instantiated Facade)?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

半世晨晓 2024-07-15 10:01:33

一种解决方案是使用单例,并让应用程序和外观中的一个或两个向该单例注册。

然而,我真的不喜欢在这个问题上抛出全局变量的想法。 这似乎没有意义——这一定是一个常见问题,所以我假设有一个优雅的解决方案,但我只是不知道如何搜索它。

One solution is to use a Singleton, and have one, or both, of the Application and Facade register with that Singleton.

However, I really don't like the idea of throwing a global variable at this problem. It doesn't seem to make sense -- this must be a common problem, so I'm assuming there is an elegant solution and I just don't know how to search for it.

为你鎻心 2024-07-15 10:01:33

您还可以使用 Spring DM 来连接您的 OSGi 服务并使用 Martin Lippert 粘合插件 将视图与 OSGi 服务连接起来(或Spring beans),它的好处是您不需要编写任何基于服务 API 或 Spring API 的代码......

you could also use Spring DM to wire up your OSGi services and use Martin Lippert glue plugin to wire up the views with OSGi Services (or Spring beans), the good bit with it is that you don't need to write any code based on the service API or spring API...

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文