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.

实 例 程 序_rel = release;}CORBA::Boolean _is_owner() { return _rel; }void _is_owner(CORBA::Boolean b) { _rel = b; }CORBA::Float balance() {return _ptr->balance();}PortableServer::POA_ptr _default_POA() {if ( !CORBA::is_nil(_poa) ) {return _poa;} else {return PortableServer_ServantBase::_default_POA();}}};修 改 服 务 器 使 其 使 用 _tie_account 类C++: 以 下 代 码 样 本 显 示 对 使 用 _tie_account 类 所 需 修 改 的 Server.C 文 件 的 修 改 。#include "Bank_s.hh"#include . . .int main(int argc, char* const* argv) {try{// 初 始 化 ORB。CORBA::ORB_var orb = CORBA::ORB_init(argc, argv);// 取 得 根 POA 的 引 用PortableServer::POA_var rootPOA = PortableServer::POA::_narrow(orb->resolve_initial_references("RootPOA"));CORBA::PolicyList policies;policies.length(1);policies[(CORBA::ULong)0] = rootPOA->create_lifespan_policy(PortableServer::PERSISTENT};// 取 到 POA 管 理 器PortableServer::POAManager_var poa_manager = rootPOA->the_POAManager();// 用 正 确 的 策 略 创 建 myPOAPortableServer::POA_var myPOA = rootPOA->create_POA("bank_agent_poa",poa_manager, policies);// 创 建 服 务 对 象AccountManagerImpl managerServant(rootPOA);// 创 建 委 托 者POA_Bank_AccountManager_tie tieServer(managerServant);// 确 定 服 务 对 象 IDPortableServer::ObjectId_var managerId =PortableServer::string_to_ObjectId("BankManager");// 用 myPOA 上 的 ID 激 活 服 务 对 象myPOA->activate_object_with_id(managerId, &tieServer);// 激 活 POA 管 理 器poa_manager->activate();cout servant_to_reference(&tieServer)

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

Saved successfully!

Ooh no, something went wrong!