0

Consider the very simple IDL code that specifies a base and derived interface in CORBA:

module test{    
    interface Quote{
        attribute string symbol;
    };

    interface SpecialQuote:Quote{
        attribute string specialSymbol;
    };

    interface QuoteSender{
        void sendQuote(in Quote stock_quote);
    }
};

(This assumes CORBA but should be similar for other middleware). I am interested in being able to:

  1. create a derived class "SpecialQuote", fill in specialSymbol
  2. upcast to the base class "Quote", fill in symbol
  3. send over CORBA interface using "sendQuote"
  4. on the receiving end, downcast to SpecialQuote to retrieve specialSymbol

I'm having a hard time performing this because the attributes essentially just translate to empty setters/getters in Java rather than their Primitive Data Types. Thus it requires both the client and server ends to re-implement the setters/getters.

So in short, is inheritance of interface members possible across middleware? If so in CORBA, any recommendations? If in another middleware, which one?

rkeeler78
  • 117
  • 1
  • 2
  • 5

1 Answers1

0

You can do everything you ask for in CORBA without any modification. CORBA was designed to achieve this kind of polymorphism. However, take into account that in CORBA you have a separated client and server parts, so you have to implement the get and set methods in the server. As for the client, it only uses the get and set methods that cause a remote call to the implementation object.

Diego Sevilla
  • 28,636
  • 4
  • 59
  • 87
  • Thanks Diego. I was interested in having a way such that getters and setters were not needed since the members are primitive data types. That way only the server needs to implement sendQuote. And a client would only need the idl to understand what a Quote or SpecialQuote object is. So the client can call the server's sendQuote function, receive a Quote object by-value, and access all it's members directly rather than through remote getters and setters. Is that possible? – rkeeler78 Jun 07 '11 at 02:59
  • You can do that using object-by-value, as you say, as it is also supported by CORBA. However, it is a little bit more messy. If you cano "simulate" inheritance, using structs is the way to go. They're always sent by value. – Diego Sevilla Jun 07 '11 at 08:38
  • Tried both direct inheritance along with manual inheritance after generating CORBA code (using structs rather than interfaces). For both cases, I think the problem I'm running into is that I'm running into object slicing when going across the CORBA interface. I upcast from SpecialQuote to Quote. Then I pass Quote across CORBA using QuoteSender.sendQuote. But on the receiving end, the derived-class data member specialSymbol is null after downcasting back to SpecialQuote. So I think it gets sliced pre-transmission. Does that make sense? – rkeeler78 Jun 07 '11 at 17:45