On Tuesday, July 5, 2011 1:46:50 PM UTC+2, Elhanan wrote:
actually i allready took a look at the dev guide, that's where i got the idea from
i wish i had some example on how to use the RPC class in this way, i understand i still gonna need to create a servlet to extend a remote servlet only this time it would without any interfaces or async interfaces.
i don't see any reason why i should decide at runtime which protocol to use , mainly i don't want to couple a the application programmer to one specific api. which requests different implementations.
You can very well use the GWT-RPC way and provide other implementations using <replace-with> or <generate-with> (with your own generator), or if you're using GIN, with a bind(MyServiceAsync.class).to(MyServiceAsyncImplJsonRpc.class).
I did that in my earlier project: everyone coded using the GWT-RPC pattern, but we didn't ever used GWT-RPC, all Async interfaces were coded by hand, doing "REST-like" calls to our server using RequestBuilder. The hard part, of course, is serialization, but here piriti or similar projects can help (we did it all by hand, and our "domain objects" were actually JavaScriptObject so we could simply use JsonUtils for the deserialization part; for serialization, we only had "simple" objects so we did it by hand, on a case-by-case basis).
You could do the same using RequestFactory interfaces, though it's probably a bit more complex (you can overcome this by just adding a few constraints though, such as "no more than one method invocation per RequestContext", FWIW that's how the current @JsonRpc "facet" of RF –introduced in 2.3– works, but it's client-side only: it allows you to easily consume existing JsonRpc services from your client code, not to build them on the server-side)
I mean: they're just interfaces, most of which *you* do write, so you're free to implement them the way you want (including using the "default" GWT generator).