12.07.2015 Views

VisiBroker Edition

VisiBroker Edition

VisiBroker Edition

SHOW MORE
SHOW LESS
  • No tags were found...

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

用 户 违 例C++: class UserException: public Exception {public:...static const char *_id;virtual ~UserException();static UserException *_downcast(Exception *);};Java: public abstract class UserException extends java.lang.Exception {protected UserException();protected UserException(String reason);}定 义 用 户 违 例假 定 您 要 改 进 帐 户 应 用 ( 如 第 4 章 " 使 用 <strong>VisiBroker</strong> <strong>Edition</strong> 开 发 实 例 应 用 " 中所 述 ) 以 便 account 对 象 可 以 掷 出 一 个 违 例 。 如 果 account 对 象 中 的 资 金 不 足 时 ,您 希 望 掷 出 一 个 命 名 为 AccountFrozen 的 用 户 违 例 。 将 用 户 违 例 添 加 到 Account 接口 的 IDL 规 范 时 所 需 要 用 的 新 增 程 序 部 分 用 粗 体 表 示 。// Bank.idlmodule Bank {interface Account {exception AccountFrozen {};float balance() raises(AccountFrozen);};};The idl2cpp) (C++) 或 idl2java (Java) 编 译 器 将 为 AccountFrozen 违 例 类生 成 以 下 的 代 码 。class Account : public virtual CORBA::Object {...class AccountFrozen: public CORBA_UserException {public:static const CORBA_Exception::Description description;AccountFrozen() {}static CORBA::Exception *_factory() {return new AccountFrozen();}~AccountFrozen() {}virtual const CORBA_Exception::Description& _desc() const;static AccountFrozen *_downcast(CORBA::Exception *exc);CORBA::Exception *_deep_copy() const {return new AccountFrozen(*this);}void _raise() const {raise *this;}...}由 idl2java 编 译 器 生 成 的 AccountFrozen 类 :处 理 违 例 5-7

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!