网站大量收购独家精品文档,联系QQ:2885784924

ice系列培训楼(一).ppt

  1. 1、本文档共81页,可阅读全部内容。
  2. 2、有哪些信誉好的足球投注网站(book118)网站文档一经付费(服务费),不意味着购买了该文档的版权,仅供个人/单位学习、研究之用,不得用于商业用途,未经授权,严禁复制、发行、汇编、翻译或者网络传播等,侵权必究。
  3. 3、本站所有内容均由合作方或网友上传,本站不对文档的完整性、权威性及其观点立场正确性做任何保证或承诺!文档内容仅供研究参考,付费前请自行鉴别。如您付费,意味着您自己接受本站规则且自行承担风险,本站不退款、不进行额外附加服务;查看《如何避免下载的几个坑》。如果您已付费下载过本站文档,您可以点击 这里二次下载
  4. 4、如文档侵犯商业秘密、侵犯著作权、侵犯人身权等,请点击“版权申诉”(推荐),也可以打举报电话:400-050-0827(电话支持时间:9:00-18:30)。
查看更多
ice系列培训楼(一)

2.7 Interfaces,Operations,and Exceptions (6) Exception Inheritance 异常是可以继承的,例如: Exception ErrorBase { string reason; } Exception RuntimeError extends ErrorBase { … }; 方法的异常规范列表中可以只列出基类异常,这样方法内可以抛出所有基类和子类异常;异常只支持单继承。 2.7 Interfaces,Operations,and Exceptions (7) Ice Run-Time Exceptions 2.7 Interfaces,Operations,and Exceptions (8) Interface Semantics and Proxies interface经过编译后会自动生成客户端proxy和服务端骨架,在Slice中interface后跟“*”表示proxy,例如: module Demo{ exception BadZoneName{…}; interface Clock { … }; interface WorldTime { idempotent void addZone(string zoneName, Clock* zoneClock); idempotent Clock* findZone(string zoneName) throws BadZoneName; … };}; “*”表示proxy operator,其左边必须为一个interface。 Clock* 表示Clock接口的代理。上述Slice编译成C++后是: 2.7 Interfaces,Operations,and Exceptions (8) Interface Semantics and Proxies namespace IceProxy { namespace Demo { class Clock : virtual public ::IceProxy::Ice::Object {…}; class WorldTime : virtual public ::IceProxy::Ice::Object {…}; } } namespace Demo { typedef ::IceInternal::ProxyHandle ::IceProxy::Demo::Clock ClockPrx; typedef ::IceInternal::ProxyHandle ::IceProxy::Demo::WorldTime WorldTimePrx; } 上述生成代码为客户端proxy,客户端通过ClockPrx和WorldTimePrx访问服务端对象。 2.7 Interfaces,Operations,and Exceptions (8) Interface Semantics and Proxies namespace Demo { class Clock : virtual public ::Ice::Object {…}; class WorldTime : virtual public ::Ice::Object { public: … virtual void addZone(const ::std::string, const ::Demo::ClockPrx, const ::Ice::Current = ::Ice::Current()) = 0; virtual ::Demo::ClockPrx findZone(const ::std::string, const ::Ice::Current = ::Ice::Current()) = 0; … }; } 上述生成代码为服务端skeleton,需要从Clock和WorldTime继承,实现其接口。 2.7 Interfaces,Operations,and Exceptions (9) Interface Inheriance 接口支持继承,也支持多继承,菱形继承也是允许的。例如: interface B{/*…*/}; interface I1 extends B {/*…*/}; interface I2 extends B {/*…*/}; interface D extends I1, I2{/*…*/}; 接口继承的限制是,多个基类中不能有同名的方法。 所有接口隐式继承于Ice::Object接口,不允许显示从其继承。因此Object可以作为任何接口使用,例如: interface ProxyStore { idempotent void putProxy(string

文档评论(0)

150****4233 + 关注
实名认证
内容提供者

该用户很懒,什么也没介绍

1亿VIP精品文档

相关文档