Archived
This forum has been archived. Please start a new discussion on GitHub.
Implement Chain Query by Self-Referential Interfaces
Hello everyone,
I want to implement a "chain query" function, in some query objects: query.filter("condition1").filter("condition2").orderBy("Attribute1").
I found "Self-Referential Interfaces" in the documentation may help me, and I define .ice like this:
interface Query{
idempotent Query* filter(string condition);
idempotent Query* orderBy(string attribute);
}
When going into coding the servant, I don't know how to return Query*(or the proxy to the Query interface).
Am I doing the right way? Can anybody help me?
Best regards!
I want to implement a "chain query" function, in some query objects: query.filter("condition1").filter("condition2").orderBy("Attribute1").
I found "Self-Referential Interfaces" in the documentation may help me, and I define .ice like this:
interface Query{
idempotent Query* filter(string condition);
idempotent Query* orderBy(string attribute);
}
When going into coding the servant, I don't know how to return Query*(or the proxy to the Query interface).
Am I doing the right way? Can anybody help me?
Best regards!
0
Comments
-
Hi,
You can use the Ice::ObjectAdapter::createProxy method to create the proxy and then cast it to a Query proxy, for example://Java public QueryPrx filter(String str, Ice.Current current) { this.filterFields.add(str); return QueryPrxHelper.uncheckedCast(current.adapter.createProxy(current.id)); }
Note however that each filter/orderBy call will end up making a remote Ice invocation... which can be costly. A better approach might be to create those Query objects locally and once created pass it over to the server for execution.
Cheers,
Benoit.0