+1 for this implementation.

This is a lot clearer than a class -> implementation lookup map or  
inlining the whole method at each call site.  As long as the bytecode  
is rewritten in hosted mode to match the expected order of operations,  
there shouldn't be any surprises at compile time.

Could this cause issues with anyone running GWT.create() in server- 
side code?  Does that even work today?

On 12-Mar-09, at 10:23 PM, Ray Cromwell wrote:

>
> BTW,
>  My proposed implementation is to rewrite these methods changing the
> literal parameter to the result of invoking GWT.create() at the call
> site, e.g.
>
> interface MyService extends RemoteService<MyServiceAsync> { ... }
> // example call
> OAuth.withSignature(MyService.class).method1(arg1, arg2,  
> asyncCallback);
>
> public class OAuth {
>  @GwtCreate  // method must be static, class parameter must be final
>  public static <S, T extends RemoteService<S>> S withSignature(final
> Class<T> service) {
>        // GWT.create with non-literal ONLY allowed
>        // if enclosing method is @GwtCreate and
>       // variable statically resolvable to literal param
>        S async = GWT.create(service);
>        ((ServiceDefTarget)async).setRequestBuilderCallback(new
> OAuthRequestBuilderSigner());
>        return async;
>  }
> }
>
> after rewrite at callsite:
> Object async = GWT.create(MyService.class);
> OAuth.withSignature(async).method1(arg1, arg2, asyncCallback);
>
> rewritten method:
> public class OAuth {
>  @GwtCreate  // method must be static, class parameter must be final
>  public static <S, T extends RemoteService<S>> S withSignature(Object
> asyncInstance) {
>
>        //S async = GWT.create(service); replaced with instance
>        S async = (S)asyncInstance;
>        ((ServiceDefTarget)async).setRequestBuilderCallback(new
> OAuthRequestBuilderSigner());
>        return async;
>  }
> }
>
> This doesn't handle generator override or extra params, but it's a
> start and could work with minimal changes to ReplaceRebinds.
>
> -Ray
>
> On Thu, Mar 12, 2009 at 7:17 PM, Ray Cromwell  
> <cromwell...@gmail.com> wrote:
>> Yeah, it's mostly the same as was discussed in the past. I just
>> decided to resurrect the idea given that 1.6 is almost shipped to
>> ensure it has a good chance of making it into the next version.
>>
>> -Ray
>>
>> On Thu, Mar 12, 2009 at 5:49 PM, Ian Petersen <ispet...@gmail.com>  
>> wrote:
>>>
>>> Seems like this might be related to
>>> http://code.google.com/p/google-web-toolkit/issues/detail?id=2243
>>>
>>> I like the idea.
>>>
>>> Ian
>>>
>>>>>
>>>
>>
>
> >


--~--~---------~--~----~------------~-------~--~----~
http://groups.google.com/group/Google-Web-Toolkit-Contributors
-~----------~----~----~----~------~----~------~--~---

Reply via email to