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++:orb.run();}catch (Exception e) {e.printStackTrace();}}}在 C++ 下 , 客 户 和 服 务 器 将 使 用PortableInterceptor::register_orb_initalizer() 方 法 来 注 册 各 个ORBInitializer 类 。 其 中 是 要 注 册 的 类 的 名 称 。 在 本 实 例 中 , 我 们也 说 明 了 另 外 一 种 方 法 , 即 将 接 收 器 类 注 册 为 动 态 链 接 库 的 (DLL)。 这 种 注 册 方法 的 好 处 是 应 用 不 需 要 改 变 任 何 代 码 , 只 需 要 改 变 执 行 方 式 。 请 参 阅 有 关 应 用 开 发或 执 行 的 小 节 。 请 注 意 这 是 一 个 <strong>VisiBroker</strong> 属 性 方 式 的 注 册 。 如 果 您 想 完 全 遵 从OMG, 请 不 要 使 用 以 下 方 式 。如 果 您 选 择 将 接 收 器 类 作 为 DLL ( 即 使 用 <strong>VisiBroker</strong> 属 性 方 式 ) 来 装 载 , 则 不需 要 给 客 户 和 服 务 器 应 用 加 入 额 外 的 代 码 。 在 本 实 例 中 , 您 将 会 看 到 未 指 定 DLL编 译 和 链 接 , 则 部 分 代 码 被 宏 代 换 掉 。客 户 应 用 的 完 整 实 现 如 下 。// Client.C#include "Bank_c.hh"// USE_STD_NS 是 由 <strong>VisiBroker</strong> 建 立 的 使 用 std namespace 的 定 义USE_STD_NS#if !defined( DLL_COMPILE )#include "SampleClientLoader.C"#endifint main(int argc, char* const* argv){try {// 在 orb 初 始 化 * 前 *, 将 装 载 器 (Loader) 实 例 化// 如 果 选 择 不 使 用 DLL 装 载 方 式#if !defined( DLL_COMPILE )SampleClientLoader* loader = new SampleClientLoader;PortableInterceptor::register_orb_initializer(loader);#endif// 初 始 化 ORB。CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);// 取 得 管 理 器 IdPortableServer::ObjectId_var managerId =PortableServer::string_to_ObjectId("BankManager");// 找 到 一 个 帐 户 管 理 器 。 Give the full POA name and the servant ID.Bank::AccountManager_var manager =Bank::AccountManager::_bind("/bank_agent_poa", managerId);// 使 用 argv[1] 作 account 名 称 , 或 使 用 默 认 值 。const char* name = argc > 1 ? argv[1] : "Jack B. Quick";使 用 可 移 植 接 收 器 20-35

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

Saved successfully!

Ooh no, something went wrong!