Hey Geraldo, Check out this thread:
http://groups.google.com/group/Google-Web-Toolkit/browse_thread/thread/ccb5b07a24ac5a97/4b98bf080e8bf231?lnk=gst&q=command+pattern#4b98bf080e8bf231 Also, I've posted an implementation of my understanding of Ray's example here: http://code.google.com/p/gwt-dispatch This is from a working app. It may not be the absolute best implementation, but it's not bad and is working. Hopefully it helps. David On Jul 6, 1:39 am, Geraldo Lopes <geraldo...@gmail.com> wrote: > I've been trying to understand Ray's presentation and want to share > some doubts hoping for clarification: > > http://dl.google.com/io/2009/pres/Th_0200_GoogleWebToolkitArchitectur... > > Considering Page 21 > > interface Action<T extends Response> { } > > interface Response { } > > interface ContactsService extends RemoteService { > <T extends Response> T execute(Action<T> action); > > } > > interface ContactsServiceAsync { > <T extends Response> void execute(Action<T> action, > AsyncCallback<T> callback); > > } > > Considering the Tossing the Event Page (46) > > public void execute(final UpdateContact update, > final AsyncCallback<GetContactsResponse> cb) { > realService.execute(update, > new AsyncCallback<UpdateContactResponse>() { > .. > .. > > Observe that the execute method has specialized parameters. If it's > implementing the ContactsServiceAsync interface it probably has a > > void execute(Action<T> action, AsyncCallback<T> callback) { > if (action instanceof UpdateContact) > execute(UpdateContact(action), (GetContactsResponse)callback); > else > if (action instanceof AnotherCommand) > .. > .. > > } > > I've understood the purpose of the code (It's a kind of a manual proxy > to intercept the calls to the realService and make whatever is > necessary ,caching, eventbus interaction). That's not the point. My > doubt is : What is the signature of the class ? > > If you see the code of page 58 which is a Mock of the > ContactsServiceAsync > > class MockContactsService implements ContactsServiceAsync { > Action<?> lastAction; > AsyncCallback<?> lastCallback; > > public <T extends Response> void execute(Action<T> action, > AsyncCallback<T> callback) { > lastAction = action; > lastCallback = callback; > } > > } > > You get the impression of there has to be some mechanism to dispatch > to the real execute methods because one can't write > > class CachedBatchingService implements ContactsServiceAsync > > public CachedBatchingService(ContactsServiceAsync realService) { > } > > public void execute(final UpdateContact update, > final AsyncCallback<GetContactsResponse> cb) { > realService.execute(update, > new AsyncCallback<UpdateContactResponse>() { > .. > > The compiler demands a method with : > > <T extends Response> void execute(Action<T> action, > AsyncCallback<T> callback); > > Please be tolerant with my english and my java. > > Thanks in advance > > Geraldo --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group. To post to this group, send email to Google-Web-Toolkit@googlegroups.com To unsubscribe from this group, send email to google-web-toolkit+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/Google-Web-Toolkit?hl=en -~----------~----~----~----~------~----~------~--~---