How do you communicate between eclipse declarative services and Views (ContentProviders)

别来无恙 提交于 2019-12-04 13:37:25

问题


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)?


回答1:


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.




回答2:


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...



来源:https://stackoverflow.com/questions/282509/how-do-you-communicate-between-eclipse-declarative-services-and-views-contentpr

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!