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.

使 用 服 务 对 象 和 服 务 对 象 管 理 器rootPOA.the_POAManager(),policies );// 创 建 服 务 对 象 激 活 器 服 务 对 象 并 取 得 它 的 引 用ServantActivator sa = new AccountManagerActivator()._this(orb);// 在 我 们 的 POA 上 设 置 服 务 对 象 激 活 器myPOA.set_servant_manager(sa);org.omg.CORBA.Object ref;// 激 活 POA 管 理 器rootPOA.the_POAManager().activate();// 生 成 并 写 出 引 用 。 支 票 和储 蓄// 帐 户 类 型 各 一 。 注 意 : 这 里 我 们 没 有 在 创 建 任 何 服 务 对 象// 只 是 在 制 作 服 务 对 象 尚 不 支 持 的// 引 用try {ref =myPOA.create_reference_with_id("CheckingAccountManager".getBytes(),"IDL:Bank/AccountManager:1.0");// 写 出 支 票 对 象 IDjava.io.PrintWriter pw =new java.io.PrintWriter( new java.io.FileWriter("cref.dat"));pw.println(orb.object_to_string(ref));pw.close();ref =myPOA.create_reference_with_id("SavingsAccountManager".getBytes(),"IDL:Bank/AccountManager:1.0");// 写 出 储 蓄 对 象 IDpw = new java.io.PrintWriter( new java.io.FileWriter("sref.dat") );System.gc();pw.println(orb.object_to_string(ref));pw.close();} catch ( java.io.IOException e ) {System.out.println("Error writing the IOR to file ");return;}System.out.println("Bank Manager is ready.");// 等 待 进 入 的 请 求 。orb.run();} catch (Exception e) {e.printStackTrace();}}}本 例 的 服 务 对 象 管 理 器 如 下 。C++:// 服 务 对 象 激 活 器class AccountManagerActivator : public PortableServer::ServantActivator {public:virtual PortableServer::Servant incarnate (constPortableServer::ObjectId&oid,PortableServer::POA_ptr poa) {CORBA::String_var s = PortableServer::ObjectId_to_string (oid);cout

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

Saved successfully!

Ooh no, something went wrong!