gwt rpc - GWT how can I reduce the size of code serializers for RPC calls -


i found more 60% of javascript code generated gwt on application rpc serializers. found serializers not shared between service interfaces, mean if have example accountdto type referenced on 2 rpc service interfaces, 2 serializer classes instead of 1 same type. in order reduce size of compiled code thinking maybe use deferred binding in order replacement of services interfaces have 1 big interface. if possible, maybe gwtcompiler produce 1 accountdto serializer instead of 2.

i'm not sure idea or if there better solution problem.

what trying implement this:

// define new interface extends service interfaces public interface genericservice extends remoteservice,                     accountingservice,                     financialservice,..., { }  public interface genericserviceasync extends accountingserviceasync,                          financialserviceasync, ..., { }  // @ application.gwt.xml do:  <module> ... ...     <replace-with class="com.arballon.gwt.core.client.genericservice">         <when-this-is class="com.arballon.gwt.core.client.accountingservice>     </replace-with>     <replace-with class="com.arballon.gwt.core.client.genericservice">         <when-this-is class="com.arballon.gwt.core.client.financialservice>     </replace-with>     ...     ... 

but @ moment receiving error:

[error] errors in 'file:/c:/users/daniel/eclipseworkspace/adk/src/com/arballon/gwt/core/client/financialservice.java' [error] line 31: rebind result 'com.arballon.gwt.core.client.genericservice' not found

any thoughts issue appreciated. regards

daniel

gwt's rpc generation code builds several classes work you've noted: *_fieldserializer each type goes on wire, , *_proxy class remoteservice async type. proxy type requires *_typeserializer, root of problem - reason, gwt wires of serialization/deserialization methods in string->js function map, facilitate fast lookups - setup code comes @ cost of lines of code need in final build. more optimized approach have each fieldserializer have registration method adds methods static map owned proxy - plagued, however, gwt's optimization of attempting not reference instantiate(), deserialize() , serialize() methods if doesnt appear called.

your issue stems having many types can serialized, , having attempted build out remoteservice types each describe specific units of functionality, re-use many model types. admirable goal, make server-side code nicer, apparently gwt bites it.

the solution attempted offer on freenode (as niloc132) build single large remoteservice type, named generalservice, , matching generalserviceasync, each extending of existing rpc service types. first thought use <replace-with> tell generator system when want each remoteservice type replace generalservice, tahir points out, doesn't make sense - gwt doesn't pass rebind results keep doing lookups. instead, suggest when want service async type, following:

accountingserviceasync service = (accountingserviceasync) gwt.create(generalservice.class) 

the rebind result generalservice implement generalserviceasync, assignable accountingserviceasync. if memory serves, said have static methods/fields provide these services - change sites create generalserviceasync instance. long not invoke gwt.create on remoteservice subtype generalservice, limit number of typeserializers one.

as side note, remoteserviceproxy subtypes stateless, ensuring create 1 instance might make easier build consistently, saves no runtime memory or time, compiled out static methods. *_typeserializer classes have state however, there 1 instance of each, combining of remoteservices might save small amount of working memory.


Comments

Popular posts from this blog

linux - Using a Cron Job to check if my mod_wsgi / apache server is running and restart -

actionscript 3 - TweenLite does not work with object -

jQuery Ajax Render Fragments OR Whole Page -