CPP   101
contMAIN
Guest on 24th June 2022 02:58:04 AM


  1. CORBA::ORB_var orb = CORBA::ORB_init (argc, argv);
  2.  
  3. cout << "Obtain a reference to RootPOA and its Manager" << endl;
  4.  
  5. CORBA::Object_var poaobj = orb->resolve_initial_references ("RootPOA");
  6. PortableServer::POA_var poa = PortableServer::POA::_narrow (poaobj);
  7. PortableServer::POAManager_var mgr = poa->the_POAManager();
  8.  
  9. cout<< "Create an Account" << endl;
  10.  
  11. PortableServer::Servant account_servant = new Account_impl;
  12.  
  13. cout <<"Activate the Account" << endl;
  14.  
  15. CORBA::Object_var the_account = account_servant->_this();
  16.  
  17. cout << "Obtain a reference to the naming service object" << endl;
  18.  
  19. CORBA::Object_var nsobj = orb->resolve_initial_references("NameService");
  20.  
  21. cout << "Obtain a NamingCOntext" << endl;
  22.  
  23. CosNaming::NamingContext_var nc = CosNaming::NamingContext::_narrow (nsobj);
  24.  
  25. cout << "Export the account IOR to the naming service" << endl:
  26.  
  27. CosNaming::Name name;
  28. name.length (1);
  29. name[0].id = (const char*) "myAccount";
  30. name[0].kind = (const char *) "";
  31.  
  32. nc->rebind (name, the_account);
  33.  
  34. cout<<"Activate the POA and start serving requests" << endl;
  35. cout<<"Runing." <<endl;
  36.  
  37. mgr->activate();
  38. orb->run();
  39.  
  40. cout <<"Shutdown (never reached)" << endl;
  41.  
  42. poa->destroy(TRUE,TRUE);
  43. delete account_servant;
  44.  
  45. return 0;

Raw Paste

Login or Register to edit or fork this paste. It's free.