Reputation: 7585
Is there a best place to put a guava EventBus in a GUI application ? Is there in the Model, the View, or the Controler ? Or three EventBus in the three levels ? Or only two of them ?
Thanks.
Upvotes: 3
Views: 3029
Reputation: 12692
The event bus design pattern is often used in Swing applications (as mentioned in this other SO question).
Guava's EventBus is just another implementation of the design pattern, with some cool tricks to simplify event handling (such as using annotations). But the goal of using the design pattern stays the same.
If I were you, I'd look into how the event bus pattern is usually used in rich client applications (on SO / Google), while using the Guava EventBus to simplify your code.
The EventBus should IMO be a singleton (ideally injected through Google Guice or some other DI framework).
I'm not a Swing dev, but I've done GWT development. A while ago, there was a big push toward the MVP / EventBus architecture for GWT applications. It might be work looking into it, to see if you could apply the same ideas to your Swing app.
Upvotes: 3
Reputation: 35457
I suggest you take a look at this experience someone recently had.
Upvotes: 3