Why not include Gin in GWT 2.1 ? It could maybe be useful inside the GWT codebase as well ?
On Wed, Oct 20, 2010 at 5:32 PM, David Chandler <[email protected]> wrote: > Hmmm, I see my comments about GIN in the ActivityMapper have caught up > with me. I haven't worked this out fully yet, but was thinking of > something along the lines of gwt-presenter's <a > href="http://code.google.com/p/gwt-presenter/source/browse/src/main/java/net/customware/gwt/presenter/client/place/PresenterPlace.java">PresenterPlace</a>. > My thought is to use GIN in place of the ClientFactory, and to write > ActivityMapper.getActivity() like this: > > public Activity getActivity(Place place) { > if (place instanceof ActivityPlace) > { > return ((ActivityPlace) place).getActivity(); > } > } > > where an ActivityPlace would be obtained from a GIN-aware > PlaceHistoryMapperWithFactory implementation so it can be injected > with the EventBus, etc. > > > On Wed, Oct 20, 2010 at 8:54 AM, Aigeec <[email protected]> wrote: >> Hey Guys, >> >> I am also interested in an implementation of GWT 2.1 MVP using GIN. >> >> I have made some head way with it. >> >> This has been done mostly by extending the ActivityManager, >> PlaceController and PlaceHistoryHandler classes and overriding their >> constructors to use GIN injection. I don't know if this is the correct >> implementation and if anyone has comments please let me know. But I >> have been able to remove the need for the ClientFactory and use GIN >> injection to instantiate everything but the Activity classes. >> >> However, I do not know how to tackle the ActivityMapper class. >> >> As Tolga says how do we replace the nested if statement with a GIN >> module? >> >> I would much prefer to be able to instantiate the Activity Class this >> way as I am using the SecureDispatchAsync as would like to use DI to >> pass it to the Activity. >> >> Regards, >> >> Aigeec >> >> On Oct 20, 1:31 am, Tolga Tarhan <[email protected]> wrote: >>> Folks, >>> >>> I'm trying to make GWT 2.1 MVP work nicely with GIN. It looks like this use >>> case was specifically considered when >>> creating PlaceHistoryMapperWithFactory, but no such thing seems to exist for >>> ActivityMapper. There is a passing reference to using Gin in >>> DevGuideMvpActivitiesAndPlaces.html , where it says "... ClientFactory is >>> used by HelloActivity to obtain a reference to the HelloView as well as the >>> EventBus and PlaceController. Any of these could alternatively be injected >>> via GIN." and also when it says "A better way to implement the chain of >>> nested ifs would be with a GIN module", in reference to ActivityMapper. >>> >>> The problem, however, is that we cannot both inject application-level >>> objects (EventBus, PlaceController, etc) and also pass the Place as >>> constructor arguments to the Activity. We could have all of the dependencies >>> for every Activity (like all the views) injected into our ActivityMapper and >>> pass them thru, but this leaks a lot of details into what should be a very >>> simple mapper class. If done incorrectly, it would also cause code-splitting >>> issues. >>> >>> One way around this is to inject a Provider<MyActivity> or >>> AsyncProvider<MyActivity> in the ActivityMapper and then do something like >>> myActivityProvider.get().initPlace(place) - which is like the assisted >>> injection that's discussed in the Guice docs. I'm wondering if there's a >>> more elegant way that was considered? >>> >>> Additionally, I'm not sure I understand how to "implement the chain of >>> nested ifs" in a GIN module. This sounds like a great idea, but what did you >>> have in mind to make GIN do this for us? We can have GIN differentiate on a >>> bunch of things (annotations, generics, interfaces, etc), but I don't know >>> how you could replace the if-block with GIN. Could someone point me in the >>> right direction here? >>> >>> Thanks, >>> Tolga >> >> -- >> http://groups.google.com/group/Google-Web-Toolkit-Contributors >> > > -- > David Chandler > Developer Programs Engineer, Google Web Toolkit > http://googlewebtoolkit.blogspot.com/ > > -- > http://groups.google.com/group/Google-Web-Toolkit-Contributors -- http://groups.google.com/group/Google-Web-Toolkit-Contributors
