How is async interface connected to GWT.create?

mahonya

When I create a sample project with GWT 2.6, I end up with the following code for RPC proxy initialisation:

private final GreetingServiceAsync greetingService = GWT.create(GreetingService.class);

GreetingService is defined as:

@RemoteServiceRelativePath("greet")
public interface GreetingService extends RemoteService {
    String greetServer(String name) throws IllegalArgumentException;
}

and GreetingServiceAsync is defined as:

public interface GreetingServiceAsync {
    void greetServer(String input, AsyncCallback<String> callback)
            throws IllegalArgumentException;
}

The signature of GWT.Create is:

public static <T> T create(Class<?> classLiteral)

Given all of this, I would expect the assignment of GWT.create to greetingService to fail. Because greetingService is of type GreetingServiceAsync and GWT.create would return GreetingService which has no relation to Async version. I would expect the Java compiler to mark this assignment as invalid, but it is not doing it.

Where is the link between the Async interface and its non async version? Java compiler obviously knows this, but I could not see it in the project source code.

Thomas Broyer
  1. about the fact that it compiles without error: notice how the parameters's type to GWT.create() does not make use of the T type parameter; so what the signature says is: you can pass any class, and it can return any type of object (T is shorthand for T extends Object), there's no connection between the GreetingService.class passed as argument and the GreetingServiceAsync returned, at least not in the GWT.create() method signature.

  2. the connection is in the GWT compiler (actually, in the generator for RPC, which is triggered for every class passed to GWT.create() that extends RemoteService), and it's simply based on a naming rule: return the type whose name is the one of the argument class suffixed with Async. Of course checks are made: both have to be interfaces, and the methods in the async interface have to be the same as the one in the "non async" interface, except the return type of the non-async is moved to a type argument of an additional AsyncCallback parameter. BTW, this specific case is the only reason that GWT.create() still has this signature where the return type is not related to the parameter type.

この記事はインターネットから収集されたものであり、転載の際にはソースを示してください。

侵害の場合は、連絡してください[email protected]

編集
0

コメントを追加

0

関連記事

分類Dev

How to create generic Map interface in TypeScript

分類Dev

How to create resolution clauses for overloaded interface methods?

分類Dev

how to create a interface with unknown number of properties in typescript?

分類Dev

How can I create an interface for a collection of objects?

分類Dev

How does create_async behave on the UI thread?

分類Dev

How can we create a callcontext for async .net methods?

分類Dev

How To Create New Column Based Off of Secondary ID Column Utilizing Data Connected to Primary ID Column

分類Dev

How to check if MQ is connected

分類Dev

How are these nested vectors connected?

分類Dev

How to view that Advertiser is connected

分類Dev

How to create a custom seekTo player interface with vimeo embedded code?

分類Dev

Async Disposable.Create

分類Dev

GWT.create(Class <?>)とGIN?

分類Dev

GWT : create DOM element using JSNI

分類Dev

How to use an interface in an interface

分類Dev

How does GWT Plugin work?

分類Dev

How to export excel file in GWT?

分類Dev

Script to set IP address connected to an interface to a shell variable

分類Dev

How to create a slice of a type given as parameter in Golang? or how to give a []interface{} to Appengine datastore getAll

分類Dev

How do I properly use asyncio.create_subprocess_shell() in an async def function?

分類Dev

How to create proper queue in RxJS consisting of Observables containing both sync and async functions

分類Dev

Create generic List property in interface

分類Dev

How to create an Application Programming Interface (API) between VB.Net and Python?

分類Dev

How to add navigation interface after create a tab bar controller programmatically (Swift)

分類Dev

When will GWT.create 2015 session videos online?

分類Dev

How enable production mode in GWT 2.7 application

分類Dev

How to disable the virtual keyboard in GWT based application?

分類Dev

GWT Java - How to close the window (Log Out)

分類Dev

Trying to create a fully connected neural network for CIFAR-10

Related 関連記事

  1. 1

    How to create generic Map interface in TypeScript

  2. 2

    How to create resolution clauses for overloaded interface methods?

  3. 3

    how to create a interface with unknown number of properties in typescript?

  4. 4

    How can I create an interface for a collection of objects?

  5. 5

    How does create_async behave on the UI thread?

  6. 6

    How can we create a callcontext for async .net methods?

  7. 7

    How To Create New Column Based Off of Secondary ID Column Utilizing Data Connected to Primary ID Column

  8. 8

    How to check if MQ is connected

  9. 9

    How are these nested vectors connected?

  10. 10

    How to view that Advertiser is connected

  11. 11

    How to create a custom seekTo player interface with vimeo embedded code?

  12. 12

    Async Disposable.Create

  13. 13

    GWT.create(Class <?>)とGIN?

  14. 14

    GWT : create DOM element using JSNI

  15. 15

    How to use an interface in an interface

  16. 16

    How does GWT Plugin work?

  17. 17

    How to export excel file in GWT?

  18. 18

    Script to set IP address connected to an interface to a shell variable

  19. 19

    How to create a slice of a type given as parameter in Golang? or how to give a []interface{} to Appengine datastore getAll

  20. 20

    How do I properly use asyncio.create_subprocess_shell() in an async def function?

  21. 21

    How to create proper queue in RxJS consisting of Observables containing both sync and async functions

  22. 22

    Create generic List property in interface

  23. 23

    How to create an Application Programming Interface (API) between VB.Net and Python?

  24. 24

    How to add navigation interface after create a tab bar controller programmatically (Swift)

  25. 25

    When will GWT.create 2015 session videos online?

  26. 26

    How enable production mode in GWT 2.7 application

  27. 27

    How to disable the virtual keyboard in GWT based application?

  28. 28

    GWT Java - How to close the window (Log Out)

  29. 29

    Trying to create a fully connected neural network for CIFAR-10

ホットタグ

アーカイブ