中间件(例如 CORBA)- 对象成员的继承。是否可以?
考虑一下非常简单的 IDL 代码,它指定 CORBA 中的基本接口和派生接口:(
module test{
interface Quote{
attribute string symbol;
};
interface SpecialQuote:Quote{
attribute string specialSymbol;
};
interface QuoteSender{
void sendQuote(in Quote stock_quote);
}
};
这假定是 CORBA,但对于其他中间件应该类似)。我感兴趣的是能够:
- 创建派生类“SpecialQuote”,将specialSymbol向上转换
- 使用“sendQuote”填充
- 通过CORBA接口发送的
- 为基类“Quote”,在接收端
符号,向下转换为SpecialQuote以检索specialSymbol我很难执行此操作,因为属性本质上只是转换为 Java 中的空 setter/getter,而不是它们的原始数据类型。因此需要客户端和服务器端重新实现setter/getter。
简而言之,接口成员的继承是否可以跨中间件实现?如果是 CORBA,有什么建议吗?如果在另一个中间件中,是哪个?
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 "SpecialQuote", 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?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您可以在 CORBA 中完成您要求的所有操作,无需任何修改。 CORBA 就是为了实现这种多态性而设计的。但是,请考虑到在 CORBA 中您有分开的客户端和服务器部分,因此您必须在服务器中实现 get 和 set 方法。对于客户端来说,它只使用 get 和 set 方法来引起对实现对象的远程调用。
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.