GWT RPC Proxy - how to create custom own one

541 views
Skip to first unread message

Олександр Бежан

unread,
Jul 31, 2012, 9:48:31 AM7/31/12
to google-we...@googlegroups.com
AFAIK GWT generates RPC proxies using Generators. I need more control in my proxy and so want to create my custom proxy. How can I do that ?

Colin Alworth

unread,
Jul 31, 2012, 11:54:20 AM7/31/12
to google-we...@googlegroups.com
All of the source for the existing RPC proxy generation code can be found in gwt-user.jar. As with all Generators, the first step is to create a Generator or GeneratorExt subclass, and reference it in the module (this is in RemoteService.gwt.xml):
    <generate-with class="com.google.gwt.user.rebind.rpc.ServiceInterfaceProxyGenerator">
        <when-type-assignable class="com.google.gwt.user.client.rpc.RemoteService"/>
    </generate-with>

You'll need to be sure that your redefinition of this rule superceeds GWT's built in rule. This can most easily be done by placing it after any other <inherits> rule in your module.

ServiceInterfaceProxyGenerator is a pretty short class, doing some sanity checking, then passing off to the ProxyCreator class. You can extend ServiceInterfaceProxyGenerator to override createProxyCreator to make your own ProxyCreator subclass.

ProxyCreator does most of the heavy lifting - figuring out what types can go over the wire, asking for FieldSerializers for each type, and eventually building the proxy itself. This is where the bulk of your modifications will probably take place.
Reply all
Reply to author
Forward
0 new messages