Hi,
we have a lot of methods with same result signature, like:
(all methods actually return XML, but it does not matter now).Code:string getBanana(long id); string updateBanana(long id, string param); string findBananas();
When using AMD, three similar callback interfaces will be generated:
all three interfaces will have the same body, in Java:Code:AMD_Banana_getBanana AMD_Banana_updateBanana AMD_Banana_findBananas
We'd like to have an option to use same interface for all three callbacks. Interface methods could be specified likeCode:void ice_response(String __ret); void ice_exception(java.lang.Exception ex);
to generate single callback interface com.mycompany.proj.IceXmlCb.Code:["amd:cb_class=com.mycompany.proj.IceXmlCb"] string getBanana(long id); ["amd:cb_class=com.mycompany.proj.IceXmlCb"] string updateBanana(long id, string param); ["amd:cb_class=com.mycompany.proj.IceXmlCb"] string findBananas();
Motivation: such callback interface (because there is only one interface) could be used in framework. For example, we could have method
and then implement ICE methods as:Code:void executeQueryAsync( String sqlQuery, params, IceXmlCb cb) { ... }
In current ICE we have to explicitly convert callback interfaces to some common interface:Code:getBananas(cb) { executeQuery("SELECT * FROM banana", { }, cb); } getBanana(cb, id) { executeQuery("SELECT * FROM banana WHERE id = ?", { id }, cb); } updateBanana(cb, id, param) { executeQuery("UPDATE banana SET a = ? WHERE id = ?", { param, id }, cb); }
This solution will work fine if all methods throw same user exception.Code:getBananas(cb) { executeQuery("SELECT ...", { }, new IceXmlCb() { void ice_response(r) { cb.ice_response(r); } void ice_exeption(e) { cb.ice_exception(e); } } } getBanana(...) { /* copy-paste */ } updateBanana(...} /* copy-paste */ }
Alternative Feature Request
Ice should have base AMD callback interface like
and generated AMD callback will be:Code:interface Ice.AMD_CallbackBase<R> { void ice_response(R r); void ice_exception(Exception e); }
This is easier to implement and understand, and it sufficient to solve our problem. In this case executeQueryAsync will have signature:Code:interface AMD_Bananas_getBanana extends AMD_CallbackBase<String> { void ice_response(R r); void ice_exception(Exception e); }
Code:void executeQueryAsync( String sqlQuery, params, AMD_CallbackBase<String> cb) { ... }

Reply With Quote