| [news.eclipse.platform.rcp] Re: How parts communicate - best practice |
Hi Diego!
Obviously there are many approaches the best you will have to choose from. I've ended up creating a 'message bus' singleton, similar to JMS in enterprise applications. (I find it exciting how all these JEE problems even occur in a standalone application - so why not use the same patterns ?).
Great analogy, you are thinking of jms messaging queues?
>You essentially have a singelton that is registered with the application's main plugin. It maintains lists of listeners of different type and offers the standard add/remove listener and fire event functionality. This allows for a 'loose coupling' of event producers and consumers. The firing party doesn't care if and how by the event is consumed by.
Does the rcp include such message bus? Other frameworks use similar mechanisms and promote events. Often integer types (extendable) are used to identify such events.In your case, the selection of a new 'current account' would definitely be a candidate for a message fired via the message bus. The event would then either include a reference to the new account and be dealt with by the other perspective. Alternatively, the event would only notify listeners that there was a change and the perspective would get the new account from a centralised data model, if this is the approach you take.
Markus