12.07.2015 Views

VisiBroker Edition

VisiBroker Edition

VisiBroker Edition

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

Create successful ePaper yourself

Turn your PDF publications into a flip-book with our unique Google optimized e-Paper software.

C++:编 写 和 注 册 触 发 器 处 理 器如 果 触 发 器 反 注 册 自 身 , 则 该 方 法 调 用 CORBA::ORB::shutdown() 方 法 , 该 方 法 将 引导 BOA 退 出 主 程 序 的 impl_is_ready() 方 法 , 以 便 程 序 可 以 结 止 。Java: 如 果 要 反 注 册 触 发 器 , 则 该 方 法 System.exit() 以 终 止 程 序 。注 意 :TriggerHandlerImpl 类 保 存 desc 和 创 建 它 时 所 用 的 Agent 参 数 的 副 本 。unreg_trigger() 方 法 需 要 desc 参 数 。 对 Agent 参 数 进 行 了 复 制 , 以 防 主 程 序 中 而来 的 引 用 被 释 放 。在 C++ 下 实 现 触 发 器 处 理 器 :C++: // AccountTrigger.c#include "locate_s.hh"// USE_STD_NS 是 由 <strong>VisiBroker</strong> 建 立 的 使 用 std namespace 的 定 义USE_STD_NS// 如 果 该 类 为 之 而 注 册 的 事 件 发 生 , 则// 代 理 将 回 调 该 类 的 实 例 。class TriggerHandlerImpl : public _sk_ObjLocation::_sk_TriggerHandler{public:TriggerHandlerImpl(ObjLocation::Agent_var agent,const ObjLocation::TriggerDesc& initial_desc): _agent(ObjLocation::Agent::_duplicate(agent)),_initial_desc(initial_desc) {}{endl;void impl_is_ready(const ObjLocation::Desc& desc) {notification(desc, 1);}void impl_is_down(const ObjLocation::Desc& desc) {notification(desc, 0);}private:void notification(const ObjLocation::Desc& desc, CORBA::Boolean isReady)if (isReady) {cout

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

Saved successfully!

Ooh no, something went wrong!