int DynServer_Loader::init (int argc, ACE_TCHAR* argv[]) { try { orb_ = ORB_init(argc, argv, "DynServer"); Object_var obj = orb_->resolve_initial_references("RootPOA"); root_poa_ = POA::_narrow(obj.in()); POAManager_var poaman = root_poa_->the_POAManager(); obj = this->orb_->resolve_initial_references ("IORTable"); IORTable::Table_var ior_table = IORTable::Table::_narrow (obj.in()); ACE_ASSERT(! is_nil(ior_table.in())); ACE_DEBUG((LM_DEBUG, "dynserver: creating poas. (Registers with ImR)\n")); POA_var poa1 = createPersistPOA("DynObject1", root_poa_.in(), poaman.in()); POA_var poa2 = createPersistPOA("DynObject2", root_poa_.in(), poaman.in()); ACE_DEBUG((LM_DEBUG, "dynserver: activating objects.\n")); DynServer* svt1 = new DynServer; ServantBase_var scoped_svt1(svt1); DynServer* svt2 = new DynServer; ServantBase_var scoped_svt2(svt2); ObjectId_var id = string_to_ObjectId("myobject"); poa1->activate_object_with_id(id.in(), svt1); poa2->activate_object_with_id(id.in(), svt2); TAO_Root_POA* tmp_poa = dynamic_cast<TAO_Root_POA*>(poa1.in()); obj = tmp_poa->id_to_reference_i (id.in(), false); String_var ior = orb_->object_to_string(obj.in()); ior_table->bind ("DynObject1", ior.in()); tmp_poa = dynamic_cast<TAO_Root_POA*>(poa2.in()); obj = tmp_poa->id_to_reference_i (id.in(), false); ior = orb_->object_to_string(obj.in()); ior_table->bind ("DynObject2", ior.in()); poaman->activate(); runner_.reset(new DynServer_ORB_Runner(orb_.in())); runner_->activate(); ACE_DEBUG((LM_DEBUG, "dynserver: running.\n")); } catch (Exception& e) { e._tao_print_exception ("DynServer::init()"); } return 0; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { ORB_var orb = ORB_init (argc, argv); Object_var obj = orb->resolve_initial_references("RootPOA"); POA_var root_poa = POA::_narrow(obj.in()); POAManager_var poaman = root_poa->the_POAManager(); obj = orb->resolve_initial_references ("IORTable"); IORTable::Table_var ior_table = IORTable::Table::_narrow (obj.in()); ACE_ASSERT(! is_nil(ior_table.in())); ACE_DEBUG((LM_DEBUG, "test_server: creating poas. (Registers with ImR)\n")); POA_var poa1 = createPersistPOA("TestObject1", root_poa.in(), poaman.in()); POA_var poa2 = createPersistPOA("TestObject2", root_poa.in(), poaman.in()); ACE_DEBUG((LM_DEBUG, "test_server: activating objects.\n")); test_i svt1, svt2; ObjectId_var id = string_to_ObjectId("myobject"); poa1->activate_object_with_id(id.in(), &svt1); poa2->activate_object_with_id(id.in(), &svt2); TAO_Root_POA* tmp_poa = dynamic_cast<TAO_Root_POA*>(poa1.in()); obj = tmp_poa->id_to_reference_i (id.in(), false); String_var ior = orb->object_to_string(obj.in()); ior_table->bind ("TestObject1", ior.in()); tmp_poa = dynamic_cast<TAO_Root_POA*>(poa2.in()); obj = tmp_poa->id_to_reference_i (id.in(), false); ior = orb->object_to_string(obj.in()); ior_table->bind ("TestObject2", ior.in()); poaman->activate(); ACE_DEBUG((LM_DEBUG, "test_server: Running...\n")); orb->run(); ACE_DEBUG((LM_DEBUG, "test_server: Shutting down...\n")); root_poa->destroy(1, 1); orb->destroy(); } catch (CORBA::Exception& e) { e._tao_print_exception ("TestServer::init()"); } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { ORB_var orb = ORB_init (argc, argv); Object_var obj = orb->resolve_initial_references ("Test"); test_var test = test::_narrow (obj.in ()); assertTrue (!is_nil (test.in ())); Long n = test->get (); Long m = test->get (); assertTrue (m == (n + 1)); ACE_DEBUG ((LM_DEBUG, "All tests ran successfully.\n")); return 0; } catch (const CORBA::Exception& e) { e._tao_print_exception ("test:"); } return 1; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { ORB_var orb = ORB_init(argc, argv); Object_var obj = orb->resolve_initial_references("Test"); test_var test = test::_narrow(obj.in()); ACE_ASSERT(! is_nil(test.in())); Long n = test->get(); Long m = test->get(); if (m == n + 1) ACE_DEBUG((LM_DEBUG, "Client: All tests ran successfully.\n")); else ACE_DEBUG((LM_DEBUG, "Error: Client Expected %d = %d + 1.\n", m, n)); return 0; } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("client:"); } return -1; }
int ACE_TMAIN (int ac, ACE_TCHAR *av[]) { try { ORB_var orb = ORB_init (ac, av); if (!parse_command_line (ac, av)) { return 1; } POA_var poa = create_poa (orb.in ()); ACE_ASSERT (! is_nil (poa.in ())); Tester_i svt (orb.in ()); ObjectId_var id = string_to_ObjectId ("tester"); poa->activate_object_with_id (id.in (), &svt); Object_var obj = poa->id_to_reference (id.in ()); String_var ior = orb->object_to_string (obj.in ()); WriteIOR (ior.in ()); cout << "Servants registered and activated." << endl; if (activate_delay > 0) { ACE_OS::sleep (ACE_Time_Value (0, activate_delay * 1000)); } POAManager_var man = poa->the_POAManager (); man->activate (); cout << "POAManager activated." << endl; if (run_delay > 0) { ACE_OS::sleep (ACE_Time_Value (0, run_delay * 1000)); } cout << "Running orb..." << endl; orb->run (); if (svt.failed ()) { return 1; } return 0; } catch (CORBA::Exception &ex) { ex._tao_print_exception ("server:"); } return 1; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { ACE_Service_Config config; config.open (argc, argv); ORB_var orb = ORB_init (argc, argv); Object_var obj = orb->resolve_initial_references("RootPOA"); POA_var poa = POA::_narrow(obj.in()); ACE_ASSERT(! is_nil(poa.in())); POAManager_var poaman = poa->the_POAManager(); SvcConf svt(config); ObjectId_var id = poa->activate_object(&svt); obj = poa->id_to_reference(id.in()); ACE_ASSERT(! is_nil(obj.in())); String_var ior = orb->object_to_string(obj.in()); poaman->activate(); { ofstream out("combined.ior"); out << ior; } ACE_DEBUG((LM_DEBUG, "Combined service started.\n")); orb->run(); ACE_DEBUG((LM_DEBUG, "Combined service shutdown.\n")); poa->destroy(1, 1); orb->destroy(); } catch (const CORBA::Exception& e) { e._tao_print_exception ("Combined Service:"); } return 0; }
void SetUp() override { int no_args{0}; orb = CORBA::ORB_init(no_args, NULL); CIAO::Client_init(orb.in()); poa_object = orb->resolve_initial_references("RootPOA"); root_poa = PortableServer::POA::_narrow(poa_object.in()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager(); poa_manager->activate(); //a_container.reset( new Session_Container_i(orb, root_poa.in()) ); }
void PersistentServantBase::create_user_persistent_POA(const char* POAname) { Object_var poaObj = orb_->resolve_initial_references("RootPOA"); PortableServer::POA_var rootPOA = PortableServer::POA::_narrow(poaObj.in()); PortableServer::POAManager_var poaManager = rootPOA->the_POAManager(); poaManager->activate(); PolicyList policyList; policyList.length(2); policyList[0] = rootPOA->create_lifespan_policy(PortableServer::PERSISTENT); policyList[1] = rootPOA->create_id_assignment_policy(PortableServer::USER_ID); defaultPOA_ = rootPOA->create_POA( POAname, poaManager, policyList ); }
virtual Short number () { // Prepare state update. // Any state; CORBA::Long number = 5; state <<= number; Object_var obj (orb_->resolve_initial_references ("PICurrent")); PortableInterceptor::Current_var pic ( PortableInterceptor::Current::_narrow (obj.in ())); pic->set_slot (slot_id, state); return 1; }