PageRenderTime 55ms CodeModel.GetById 20ms RepoModel.GetById 1ms app.codeStats 0ms

/src/org/gwt_websocketrpc/rebind/WsRpcServiceGenerator.java

http://gwt-websocketrpc.googlecode.com/
Java | 53 lines | 38 code | 11 blank | 4 comment | 0 complexity | 416f4391a1c3fb978806e2c8b4322fe0 MD5 | raw file
  1. package org.gwt_websocketrpc.rebind;
  2. import org.gwt_websocketrpc.client.ServerPushEnabled;
  3. import org.gwt_websocketrpc.client.WsRpcProxy;
  4. import com.google.gwt.core.ext.typeinfo.JClassType;
  5. import com.google.gwt.core.ext.typeinfo.JMethod;
  6. import com.google.gwt.rpc.rebind.RpcProxyCreator;
  7. import com.google.gwt.rpc.rebind.RpcServiceGenerator;
  8. import com.google.gwt.user.client.rpc.impl.RemoteServiceProxy;
  9. import com.google.gwt.user.rebind.SourceWriter;
  10. import com.google.gwt.user.rebind.rpc.ProxyCreator;
  11. import com.google.gwt.user.rebind.rpc.SerializableTypeOracle;
  12. public class WsRpcServiceGenerator extends RpcServiceGenerator {
  13. public static class WsRpcProxyCreator extends RpcProxyCreator {
  14. public WsRpcProxyCreator(JClassType type) {
  15. super(type);
  16. }
  17. @Override
  18. protected Class<? extends RemoteServiceProxy> getProxySupertype() {
  19. return WsRpcProxy.class;
  20. }
  21. @Override
  22. protected void generateProxyMethod(SourceWriter w,
  23. SerializableTypeOracle serializableTypeOracle,
  24. JMethod syncMethod, JMethod asyncMethod) {
  25. super.generateProxyMethod(
  26. // If this a handler method replace the
  27. // "return doInvoke(" (asyncMethod return Request), with
  28. // "return doHandlerInvoke("
  29. // TODO: Figure out a way around NASTY, NaSTy, Nasty Hijack hack
  30. (syncMethod.getAnnotation(ServerPushEnabled.class)!=null)
  31. ? new SourceWriterHijack(w, "return doInvoke(", "return doHandlerInvoke(")
  32. : w,
  33. serializableTypeOracle,
  34. syncMethod,
  35. asyncMethod);
  36. }
  37. }
  38. @Override
  39. protected ProxyCreator createProxyCreator(JClassType remoteService) {
  40. return new WsRpcProxyCreator(remoteService);
  41. }
  42. }