Go Back   ZeroC Forums > Comments

Reply
 
LinkBack Thread Tools Rate Thread Display Modes
  #1 (permalink)  
Old 01-30-2008
stepancheg stepancheg is offline
Registered User
 
Name: Stepan Koltsov
Organization: Yandex
Project: Test
 
Join Date: Jan 2008
Posts: 3
FR (slice, amd, java): ability to specify callback class name

Hi,

we have a lot of methods with same result signature, like:

Code:
string getBanana(long id);
string updateBanana(long id, string param);
string findBananas();
(all methods actually return XML, but it does not matter now).

When using AMD, three similar callback interfaces will be generated:

Code:
AMD_Banana_getBanana
AMD_Banana_updateBanana
AMD_Banana_findBananas
all three interfaces will have the same body, in Java:

Code:
void ice_response(String __ret);
void ice_exception(java.lang.Exception ex);
We'd like to have an option to use same interface for all three callbacks. Interface methods could be specified like

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();
to generate single callback interface com.mycompany.proj.IceXmlCb.

Motivation: such callback interface (because there is only one interface) could be used in framework. For example, we could have method

Code:
void executeQueryAsync(
  String sqlQuery, params, IceXmlCb cb) { ... }
and then implement ICE methods as:

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); }
In current ICE we have to explicitly convert callback interfaces to some common interface:

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 */ }
This solution will work fine if all methods throw same user exception.

Alternative Feature Request

Ice should have base AMD callback interface like

Code:
interface Ice.AMD_CallbackBase<R> {
  void ice_response(R r);
  void ice_exception(Exception e);
}
and generated AMD callback will be:

Code:
interface AMD_Bananas_getBanana extends AMD_CallbackBase<String> {
  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:
void executeQueryAsync(
  String sqlQuery, params, AMD_CallbackBase<String> cb) { ... }
Reply With Quote
  #2 (permalink)  
Old 01-30-2008
mes's Avatar
mes mes is online now
ZeroC Staff
 
Name: Mark Spruiell
Organization: ZeroC, Inc.
Project: Ice Developer
 
Join Date: Feb 2003
Location: California
Posts: 971
Stephan,

Welcome to the forum.

Thanks for the suggestion, we'll consider it for a future release. We've had internal discussions about doing something similar for C#, but it would be easier in C# with the language's delegate feature.

Take care,
- Mark
Reply With Quote
  #3 (permalink)  
Old 02-04-2008
mefoster mefoster is offline
Registered User
 
Name: Mary Ellen Foster
Organization: Technical University of Munich
Project: JAST human-robot dialogue system
 
Join Date: Jun 2006
Posts: 78
I would also love something like this in Java. Even the second suggestion -- implementing a common super-interface -- would greatly clean up some of my code. At one point, I have a large number of callback-response classes that are pretty much identical, and it would be much nicer if I only had to write that code once.
__________________
Mary Ellen Foster
Technical University of Munich
JAST human-robot dialogue system
Maintainer of Fedora Ice packages
Reply With Quote
Reply



Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On

Similar Threads
Thread Thread Starter Forum Replies Last Post
How to make abstract SLICE class peterlspot Help Center 2 01-17-2008 02:14 AM
enumerate derived class names of a given slice class peterlspot Comments 1 11-29-2007 08:26 AM
Slice class data members -> private in Java/C++? sasho2 Help Center 3 04-09-2007 04:28 PM
Intializing members of a slice generated class Venkat Seeth Help Center 3 02-22-2005 01:31 PM
May slice struct contain class? minifat Help Center 1 08-09-2004 10:16 PM


All times are GMT -4. The time now is 02:42 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Search Engine Optimization by vBSEO 3.0.0
(c) 2008 ZeroC, Inc.