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.

查 询 代 理public class AccountFinder {public static void main(String[] args) {try {// 初 始 化 ORB。org.omg.CORBA.ORB orb = org.omg.CORBA.ORB.init(args,null);com.inprise.vbroker.ObjLocation.Agent the_agent = null;try {the_agent =com.inprise.vbroker.ObjLocation.AgentHelper.narrow(orb.resolve_initial_references("LocationService"));} catch (org.omg.CORBA.ORBPackage.InvalidName e) {System.out.println("Not able to resolve references " +"for LocationService");System.exit(1);} catch (Exception e) {System.out.println("Unable to locate LocationService!");System.out.println("Caught exception: " + e);System.exit(1);}org.omg.CORBA.Object[] accountRefs =the_agent.all_instances("IDL:Bank/AccountManager:1.0");System.out.println("Agent returned " + accountRefs.length +" object references");for (int i=0; i < accountRefs.length; i++) {System.out.println("Stringified IOR for account #" + (i+1) + ":");System.out.println(orb.object_to_string(accountRefs[i]));System.out.println();}} catch (Exception e) {System.out.println("Caught exception: " + e);System.exit(1);}}}找 出 智 能 代 理 已 知 的 接 口 和 实 例C++:以 下 的 代 码 示 例 说 明 如 何 找 到 智 能 代 理 已 知 的 所 有 接 口 和 实 例 。 该 示 例 先 通 过 调 用all_repository_ids() 方 法 来 取 得 所 有 已 知 的 接 口 。 然 后 , 它 调 用all_instances_descs() 方 法 使 每 个 接 口 取 得 实 例 描 述 。在 C++ 找 出 智 能 代 理 已 知 的 所 有 接 口 和 实 例 :#include "corba.h"#include "locate_c.hh"// USE_STD_NS 是 由 <strong>VisiBroker</strong> 建 立 的 使 用 std namespace 的 定 义// 如 其 存 在USE_STD_NSint DisplaybyRepID(CORBA::ORB_ptr the_orb,ObjLocation::Agent_var the_agent,char * myRepId) {13-8 <strong>VisiBroker</strong> 开 发 者 指 南

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

Saved successfully!

Ooh no, something went wrong!