java - GWT RequestFactory - how to initialize it properly? -


my gwt applications follow mvp pattern singleton eventbus, , display+presenter bound in activity (with of gin):

public class myactivity implements activity {   @inject mydisplay display; //usually bound in singleton scope   @inject mypresenter presenter;    ...   @override   public void start(acceptsonewidget panel, eventbus eventbus) {     diplay.bindpresenter(presenter);     presenter.start(eventbus);     panel.setwidget(display);   }   ... } 

usually inject new instances of specific requestfactory specific presenter gin. presenters have start() method, can pass eventbus instance created on behalf of activity (resettableeventbus).

public mypresenter {    @inject myrequestfactory requestfactory;    public void start(eventbus eventbus) {     requestfactory.initialize(eventbus);     ...   }   ... } 

i assume safe, let gin create , inject new instance of myrequestfactory. if want unit test mypresenter using requestfactorysource, rather need initialize requestfactory using:

requestfactory.initialize(eventbus, new inprocessrequesttransport(processor)); 

and here comes question. can bind myrequestfactory in scope singleton (does generated instance keep state?), , initialize globally singleton eventbus (does depend on activity's eventbus?) - consequences? assume myrequestfactory instance injected mypresenter initialized either production, or testing. solution inject additional requestfactory initialization strategy mypresenter, necessary?

requestfactory designed used singleton.

assuming have application-wide event bus, it'll work same use today: requestfactory posts event bus, doesn't listen events.


Comments

Popular posts from this blog

node.js - Bad Request - node js ajax post -

Why does Ruby on Rails generate add a blank line to the end of a file? -

keyboard - Smiles and long press feature in Android -