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.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
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.