Istao
Istao

Reputation: 7585

Guava EventBus : where to put it in GUI application?

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

Answers (2)

Etienne Neveu
Etienne Neveu

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

Olivier Grégoire
Olivier Grégoire

Reputation: 35457

I suggest you take a look at this experience someone recently had.

http://stupidgwttricks.wordpress.com/2011/12/20/using-guavas-eventbus-to-decouple-components-of-a-swing-application/

Upvotes: 3

Related Questions