Archived

This forum has been archived. Please start a new discussion on GitHub.

Polymorphism in IceGrid

In IceGrid, the registry knows type information of objects according to the node descriptor(.xml file). It is also the only information the registry holds.

So in the complete develop-deployment-invocation circle, there are 3 steps in which the type of objects would be expicitly denoted, described in the following example:

Say we have :
module Demo{
interface Hello{
void sayHello();
};
interface MyHello extends Hello{
void sayHi();
};
}

1. In the service implementation. An servant will be added into the adapter:
adapter.add(new MyHelloI(), id);
2. In the node deployment, in the xml file:
...
<server id="SimpleServer" exe="java" activation="on-demand">
<option>Server</option>
<adapter name="Hello" endpoints="tcp" register-process="true">
<object identity="hello" type="::Demo::Hello"/>
</adapter>
<property name="Identity" value="hello"/>
</server>

3. In the client code, initialize a proxy with IceGrid::Query according to the type information: Demo::Hello.

Assume that a generic base interface is defined in Slice and published to several developer groups. Those groups would like to extend the base interface into new Slice definitions.
In the central administration application, the administrator may want to retrieve all objects as the base interface type to perform some generic operations; or he/she may want to retrieve all objects with a certain extended interface to perform some other operations.

Since the IceGrid::Query would only retrieve what is defined in the node's .xml file, the administrator must firstly define all well-known objects as the base type in the node's .xml file, then retrieve them all according to the base type, and finally filter out whatever he wants with Object.ice_ids().

If all stated above is correct. Is there some easier/more flexible way, or I've missed something?

Comments

  • benoit
    benoit Rennes, France
    Hi,

    That's correct, there's currently no easier way to do this. We're planning to improve this in the future however and allow the registration of several types with an object.

    Cheers,
    Benoit.