Monday, August 29, 2011

Re: Help! Some confusing problems about gwt rpc with generics!

Are you sure you need a generic RemoteService? Like Jeff stated, RPC proxyCreator needs to ensure all subtypes of the types specified in your RemoteService need to be serialized (that way, server & client can communicate without problems). This will bloat the size of generated code. Moreover, having T & K can only reduce the code-size by 100 bytes or so, like this:

public interface GenericsRpcService<T,K> extends RemoteService{ 
  T callServer(List<K> id); 
  T callServer(K id); 


public interface UserRpcService extends GenericsRpcService<User, Long> {
  // Other (additional methods).
}

Notice the 2 methods from GenericsRpcService are already present in the subinterface. This is the only advantage you can get. Besides, you need a type literal for GWT.create so there's no way to call GWT.create (GenericRpcService<A, B>.class) (same goes with dependency injection -- you can't bind a generics interface).

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To view this discussion on the web visit https://groups.google.com/d/msg/google-web-toolkit/-/zx_oR4chgLUJ.
To post to this group, send email to google-web-toolkit@googlegroups.com.
To unsubscribe from this group, send email to google-web-toolkit+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/google-web-toolkit?hl=en.

No comments:

Post a Comment