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:
- create a derived class "Special开发者_JS百科Quote", fill in specialSymbol
- upcast to the base class "Quote", fill in symbol
- send over CORBA interface using "sendQuote"
- 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?
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.
精彩评论