views:

729

answers:

2

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  A: 

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.

rcreswick
I agree that singleton seems like a bad idea. I wish I could offer a real solution.
Jason Dagit
I had similar question: http://stackoverflow.com/questions/277291/eclipse-rcp-where-should-i-keep-my-model-objects-and-how-do-they-talk-to-the-views
eed3si9n
+1  A: 

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