test_ptr test_factory_i::create_test (void) { test_i *servant = new test_i (this->orb_.in ()); PortableServer::ServantBase_var safe_servant (servant); ACE_UNUSED_ARG (safe_servant); CORBA::Object_var poa_object = this->orb_->resolve_initial_references("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::ObjectId_var id_act = root_poa->activate_object (servant); CORBA::Object_var object = root_poa->id_to_reference (id_act.in ()); test_var test = test::_narrow (object.in ()); return test._retn (); }
int Object_Activator::svc (void) { try { test_i *servant = new test_i (this->poa_.in ()); PortableServer::ServantBase_var safe_servant (servant); PortableServer::ObjectId_var id = this->poa_->activate_object (servant); this->object_activated_.signal (); this->poa_->deactivate_object (id.in ()); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ( "Exception caught in activator thread"); return -1; } return 0; }
int create_POA_and_register_servant (CORBA::Policy_ptr threadpool_policy, const char *poa_name, PortableServer::POAManager_ptr poa_manager, PortableServer::POA_ptr root_poa, CORBA::ORB_ptr orb, RTCORBA::RTORB_ptr rt_orb) { // Policies for the firstPOA to be created. CORBA::PolicyList policies (3); policies.length (3); // Implicit_activation policy. policies[0] = root_poa->create_implicit_activation_policy (PortableServer::IMPLICIT_ACTIVATION); // Thread pool policy. policies[1] = CORBA::Policy::_duplicate (threadpool_policy); // Priority Model policy. policies[2] = rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED, 0); // Create the POA under the RootPOA. PortableServer::POA_var poa = root_poa->create_POA (poa_name, poa_manager, policies); // Creation of POAs is over. Destroy the Policy objects. for (CORBA::ULong i = 0; i < policies.length (); ++i) { policies[i]->destroy (); } test_i *servant = new test_i (orb, poa.in (), nap_time); PortableServer::ServantBase_var safe_servant (servant); ACE_UNUSED_ARG (safe_servant); PortableServer::ObjectId_var id = poa->activate_object (servant); CORBA::Object_var object = poa->id_to_reference (id.in ()); test_var test = test::_narrow (object.in ()); int const result = write_ior_to_file (orb, test.in ()); return result; }
PortableServer::Servant Servant_Activator::incarnate (const PortableServer::ObjectId &, PortableServer::POA_ptr) { test_i *servant = new test_i (this->poa_.in ()); PortableServer::ServantBase_var safe_servant (servant); this->id_ = this->poa_->activate_object (servant); this->poa_->deactivate_object (this->id_.in ()); int result = global_object_activator->activate (); ACE_ASSERT (result != -1); ACE_Time_Value timeout (5); result = global_object_activator->object_activated_.wait (&timeout, 0); if (result == 0) { ACE_DEBUG ((LM_DEBUG, "Object Activator was able to make progress during " "recursive non-servant upcall: test failed\n")); ACE_ASSERT (0); } else if (result == -1 && errno == ETIME) { ACE_DEBUG ((LM_DEBUG, "Object Activator was not able to make progress during " "recursive non-servant upcall: test succeeded\n")); } else { ACE_DEBUG ((LM_DEBUG, "Unexpected error during event.wait (): %d\n", result)); ACE_ASSERT (0); } return new test_i (this->poa_.in ()); }
ENW::TSession_ptr Impl::TSEC_CheckPoint_exec_i::createSession ( ) { static long cnt = 0L; ENW::TSession_var session = ENW::TSession::_nil(); ACE_DEBUG( ( LM_DEBUG, "(%P|%t@%T) TSEC_CheckPoint_exec_i::createSession...\n" ) ); TSEC_Session_impl* p_sessionImpl = new TSEC_Session_impl( *this, ++cnt ); PortableServer::ServantBase_var safe_servant( p_sessionImpl ); CORBA::Object_var obj = this->installServant( p_sessionImpl ); session = ENW::TSession::_narrow ( obj.in () ); ACE_DEBUG( ( LM_DEBUG, "(%P|%t@%T) TSEC_CheckPoint_exec_i::createSession...[DONE]\n" ) ); return session._retn(); }
void Impl::TSEC_CheckPoint_exec_i::ccm_activate ( ) { ACE_DEBUG( ( LM_DEBUG, "Impl::TSEC_CheckPoint_exec_i::ccm_activate\n" ) ); TSEC_Session_impl* p_sessionImpl = 0; for( CORBA::Long i = 0; i < TSEC_SESSION_MAX_IDENT; ++i ) { p_sessionImpl = new TSEC_Session_impl( *this, i + 1 ); PortableServer::ServantBase_var safe_servant( p_sessionImpl ); CORBA::Object_var obj = this->installServant( p_sessionImpl ); ENW::TSession_var session = ENW::TSession::_narrow ( obj.in () ); sessionVector[i] = TSEC_SessionEntry( p_sessionImpl, session.in () ); } _isActivated = true; }
int Time_Date_Servant::init (int argc, ACE_TCHAR *argv[]) { try { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("\n\tTime_Date servant\n\n"))); this->parse_args (argc, argv); DLL_ORB *orb = ACE_Dynamic_Service<DLL_ORB>::instance (this->orb_.c_str ()); if (orb == 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("can't find %C in the Service Repository\n"), this->orb_.c_str ()), -1); Time_Date_i * servant = 0; ACE_NEW_THROW_EX (servant, Time_Date_i, CORBA::NO_MEMORY ()); PortableServer::ServantBase_var safe_servant (servant); servant->orb (orb->orb_.in ()); CORBA::Object_var poa_object = orb->orb_->resolve_initial_references("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::ObjectId_var id = root_poa->activate_object (servant); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); CORBA::Object_var obj = CORBA::Object::_narrow (object.in ()); CORBA::String_var str = orb->orb_->object_to_string (obj.in ()); if (this->ior_output_file_) { FILE *output_file = ACE_OS::fopen (this->ior_output_file_, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("Unable to open %s for writing (%p)\n"), this->ior_output_file_, ACE_TEXT ("fopen")), -1); ACE_OS::fprintf (output_file, "%s", str.in ()); ACE_OS::fclose (output_file); } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("DLL_ORB::init"); return -1; } return 0; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); CORBA::Object_var object = orb->resolve_initial_references ("RTORB"); RTCORBA::RTORB_var rtorb = RTCORBA::RTORB::_narrow (object.in ()); object = orb->resolve_initial_references ("ORBPolicyManager"); CORBA::PolicyManager_var policy_manager = CORBA::PolicyManager::_narrow (object.in ()); int parse_args_result = parse_args (argc, argv); if (parse_args_result != 0) return parse_args_result; object = orb->resolve_initial_references ("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); object = orb->string_to_object (ior); test_var receiver = test::_narrow (object.in ()); test_i *servant = new test_i (orb.in (), root_poa.in (), rtorb.in (), policy_manager.in (), receiver.in ()); PortableServer::ServantBase_var safe_servant (servant); ACE_UNUSED_ARG (safe_servant); test_var test = servant->_this (); CORBA::String_var ior = orb->object_to_string (test.in ()); FILE *output_file = ACE_OS::fopen (ior_file, "w"); ACE_ASSERT (output_file != 0); u_int result = ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_ASSERT (result == ACE_OS::strlen (ior.in ())); ACE_UNUSED_ARG (result); ACE_OS::fclose (output_file); poa_manager->activate (); orb->run (); ACE_OS::sleep(1); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught"); return -1; } return 0; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { DANCE_DISABLE_TRACE (); int retval = 0; try { DAnCE::Logger_Service * dlf = ACE_Dynamic_Service<DAnCE::Logger_Service>::instance ("DAnCE_Logger"); if (dlf) { dlf->init (argc, argv); } DANCE_TRACE_LOG (DANCE_LOG_TRACE, (LM_TRACE, DLINFO ACE_TEXT("PL_Daemon - initializing ORB\n"))); CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); DANCE_TRACE_LOG (DANCE_LOG_TRACE, (LM_TRACE, DLINFO ACE_TEXT("PL_Daemon - initializing module instance\n"))); TAO::Utils::ORB_Destroyer safe_orb (orb); CORBA::Object_var poa_obj = orb->resolve_initial_references ("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow (poa_obj.in ()); PortableServer::POAManager_var mgr = poa->the_POAManager (); PortableServer::POA_var persistent_poa; TAO::Utils::PolicyList_Destroyer policies (2); policies.length (2); try { DANCE_TRACE_LOG (DANCE_LOG_TRACE, (LM_TRACE, DLINFO ACE_TEXT("PL_Daemon - ") ACE_TEXT("before creating the \"Managers\" POA.\n"))); policies[0] = poa->create_id_assignment_policy (PortableServer::USER_ID); policies[1] = poa->create_lifespan_policy (PortableServer::PERSISTENT); persistent_poa = poa->create_POA ("Managers", mgr.in(), policies); } catch (const PortableServer::POA::AdapterAlreadyExists &) { persistent_poa = poa->find_POA ("Managers", 0); } DAnCE::Plan_Launcher_Daemon_i *pl_daemon (0); ACE_NEW_RETURN (pl_daemon, DAnCE::Plan_Launcher_Daemon_i (orb.in ()), 0); PortableServer::ServantBase_var safe_servant (pl_daemon); PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId ("Plan_Launcher_Daemon"); persistent_poa->activate_object_with_id (oid, pl_daemon); CORBA::Object_var pl_obj = persistent_poa->id_to_reference (oid.in ()); CORBA::String_var pl_ior = orb->object_to_string (pl_obj.in ()); DAnCE::Utility::write_IOR (ACE_TEXT ("PL_Daemon.ior"), pl_ior.in ()); orb->run (); DANCE_TRACE_LOG (DANCE_LOG_TRACE, (LM_TRACE, DLINFO ACE_TEXT("PL_Daemon - destroying ORB\n"))); orb->destroy (); } catch (const CORBA::Exception& ex) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_EMERGENCY, DLINFO "PL_Daemon - Error - CORBA Exception :%C\n", ex._info ().c_str ())); retval = -1; } catch (...) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, "PL_Daemon - Error: Unknown exception.\n")); retval = -1; } return retval; }
void FooServantList::create_and_activate(CORBA::ORB_ptr orb, PortableServer::POA_ptr poa) { poa_ = PortableServer::POA::_duplicate (poa); for (unsigned i = 0; i < this->num_servants_; i++) { ACE_TCHAR buf[32]; ACE_OS::sprintf(buf, ACE_TEXT("%02d"), i + 1); ACE_TString servant_name = this->prefix_ + ACE_TEXT("_") + buf; this->servants_[i] = new Foo_i(ACE_TEXT_ALWAYS_CHAR(servant_name.c_str()),this); this->safe_servants_[i] = this->servants_[i]; PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId(ACE_TEXT_ALWAYS_CHAR(servant_name.c_str())); poa->activate_object_with_id(id.in(), this->safe_servants_[i].in()); CORBA::Object_var obj = poa->id_to_reference(id.in()); if (CORBA::is_nil(obj.in())) { ACE_ERROR((LM_ERROR, "(%P|%t) Failed to activate servant (%s).\n", servant_name.c_str())); throw TestException(); } // create the collocated object reference. if (this->collocated_test_ && i == 0) { Foo_var collocated = Foo::_narrow (obj.in ()); // Create the servant object. Callback_i* servant = new Callback_i (); // local smart pointer variable to deal with releasing the reference // to the servant object when the smart pointer object falls out of scope. PortableServer::ServantBase_var safe_servant(servant); PortableServer::ObjectId_var id = PortableServer::string_to_ObjectId("callback"); poa->activate_object_with_id(id.in(), safe_servant.in()); CORBA::Object_var obj = poa->id_to_reference(id.in()); if (CORBA::is_nil(obj.in())) { ACE_ERROR((LM_ERROR, "(%P|%t) Failed to activate servant (%s).\n", servant_name.c_str())); throw TestException(); } Callback_var callback = Callback::_narrow (obj.in ()); collocated_client_ = new ClientTask(orb, collocated.in (), callback.in (), true); if (collocated_client_->open() != 0) { ACE_ERROR((LM_ERROR, "(%P|%t) Failed to open the collocated client.\n")); throw TestException(); } } CORBA::String_var ior = this->orb_->object_to_string(obj.in()); ACE_TString filename = servant_name + ACE_TEXT(".ior"); FILE* ior_file = ACE_OS::fopen(filename.c_str(), "w"); if (ior_file == 0) { ACE_ERROR((LM_ERROR, "(%P|%t) Cannot open output file (%s) for writing IOR.", filename.c_str())); throw TestException(); } else { ACE_DEBUG((LM_DEBUG, "(%P|%t) writing IOR to file %s\n", filename.c_str())); } ACE_OS::fprintf(ior_file, "%s", ior.in()); ACE_OS::fclose(ior_file); } }
void ImR_Client_Adapter_Impl::imr_notify_startup (TAO_Root_POA* poa ) { CORBA::Object_var imr = poa->orb_core ().implrepo_service (); if (CORBA::is_nil (imr.in ())) { if (TAO_debug_level > 0) { TAOLIB_ERROR ((LM_ERROR, ACE_TEXT ("TAO_ImR_Client (%P|%t) - ERROR: No usable IMR initial reference ") ACE_TEXT ("available but use IMR has been specified.\n"))); } throw ::CORBA::TRANSIENT ( CORBA::SystemException::_tao_minor_code (TAO_IMPLREPO_MINOR_CODE, 0), CORBA::COMPLETED_NO); } if (TAO_debug_level > 0) { if (TAO_debug_level > 1) { CORBA::ORB_ptr orb = poa->orb_core ().orb (); CORBA::String_var ior = orb->object_to_string (imr.in ()); TAOLIB_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO_ImR_Client (%P|%t) - Notifying ImR of startup IMR IOR <%C>\n"), ior.in ())); } } ImplementationRepository::Administration_var imr_locator; { // ATTENTION: Trick locking here, see class header for details TAO::Portable_Server::Non_Servant_Upcall non_servant_upcall (*poa); ACE_UNUSED_ARG (non_servant_upcall); imr_locator = ImplementationRepository::Administration::_narrow (imr.in ()); } if (CORBA::is_nil (imr_locator.in ())) { if (TAO_debug_level > 0) { TAOLIB_ERROR ((LM_ERROR, ACE_TEXT ("TAO_ImR_Client (%P|%t) - ERROR: Narrowed IMR initial reference ") ACE_TEXT ("is nil but use IMR has been specified.\n"))); } throw ::CORBA::TRANSIENT ( CORBA::SystemException::_tao_minor_code (TAO_IMPLREPO_MINOR_CODE, 0), CORBA::COMPLETED_NO); } TAO_Root_POA *root_poa = poa->object_adapter ().root_poa (); ACE_NEW_THROW_EX (this->server_object_, ServerObject_i (poa->orb_core ().orb (), root_poa), CORBA::NO_MEMORY ()); PortableServer::ServantBase_var safe_servant (this->server_object_); ACE_UNUSED_ARG (safe_servant); // Since this method is called from the POA constructor, there // shouldn't be any waiting required. Therefore, // <wait_occurred_restart_call_ignored> can be ignored. bool wait_occurred_restart_call_ignored = false; // Activate the servant in the root poa. PortableServer::ObjectId_var id = root_poa->activate_object_i (this->server_object_, poa->server_priority (), wait_occurred_restart_call_ignored); CORBA::Object_var obj = root_poa->id_to_reference_i (id.in (), false); ImplementationRepository::ServerObject_var svr = ImplementationRepository::ServerObject::_narrow (obj.in ()); if (!svr->_stubobj () || !svr->_stubobj ()->profile_in_use ()) { if (TAO_debug_level > 0) { TAOLIB_ERROR ((LM_ERROR, "TAO_ImR_Client (%P|%t) - Invalid ImR ServerObject, bailing out.\n")); } return; } CORBA::ORB_var orb = root_poa->_get_orb (); CORBA::String_var full_ior = orb->object_to_string (obj.in ()); TAO_Profile& profile = *(svr->_stubobj ()->profile_in_use ()); CORBA::String_var ior = profile.to_string(); if (TAO_debug_level > 0) { TAOLIB_DEBUG((LM_INFO, "TAO_ImR_Client (%P|%t) - full_ior <%C>\nior <%C>\n", full_ior.in(), ior.in())); } char* const pos = find_delimiter (ior.inout (), profile.object_key_delimiter ()); const ACE_CString partial_ior (ior.in (), (pos - ior.in ()) + 1); if (TAO_debug_level > 0) { CORBA::String_var poaname = poa->the_name (); TAOLIB_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO_ImR_Client (%P|%t) - Informing IMR that <%C> is running at <%C>\n"), poaname.in(), partial_ior.c_str ())); } try { // ATTENTION: Trick locking here, see class header for details TAO::Portable_Server::Non_Servant_Upcall non_servant_upcall (*poa); ACE_UNUSED_ARG (non_servant_upcall); ACE_CString const serverId = poa->orb_core ().server_id (); ACE_CString name; if (serverId.empty ()) { name = poa->name (); } else { name = serverId + ":" + poa->name (); } imr_locator->server_is_running (name.c_str (), partial_ior.c_str (), svr.in ()); } catch (const ::CORBA::SystemException&) { throw; } catch (const ::CORBA::Exception&) { throw ::CORBA::TRANSIENT ( CORBA::SystemException::_tao_minor_code (TAO_IMPLREPO_MINOR_CODE, 0), CORBA::COMPLETED_NO); } if (TAO_debug_level > 0) { TAOLIB_DEBUG ((LM_DEBUG, ACE_TEXT ("TAO_ImR_Client (%P|%t) - Successfully notified ImR of Startup\n"))); } }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc,argv); CORBA::Object_var poa_object = orb->resolve_initial_references ("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); if (parse_args (argc, argv) != 0) return -1; { test_factory_i *servant = new test_factory_i (orb.in ()); PortableServer::ServantBase_var safe_servant (servant); ACE_UNUSED_ARG (safe_servant); PortableServer::ObjectId_var id_act = root_poa->activate_object (servant); CORBA::Object_var object = root_poa->id_to_reference (id_act.in ()); test_factory_var test_factory = test_factory::_narrow (object.in ()); CORBA::String_var ior = orb->object_to_string (test_factory.in ()); FILE *output_file = ACE_OS::fopen (ior_output_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file for writing IOR: %s", ior_output_file), -1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); } poa_manager->activate (); TAO_Root_POA *tao_poa = dynamic_cast <TAO_Root_POA*> (root_poa.in ()); while (!done) { CORBA::ULong outstanding_requests = tao_poa->outstanding_requests (); ACE_DEBUG ((LM_DEBUG, "Number of outstanding requests before ORB::perform_work(): %d\n", outstanding_requests)); ACE_ASSERT (outstanding_requests == 0); orb->perform_work (); // On some systems this loop must yield or else the other threads // will not get a chance to run. ACE_OS::thr_yield (); } } catch (...) { ACE_ERROR_RETURN ((LM_ERROR, "Failure: Unexpected exception caught\n"), -1); } return 0; }
int Task::svc (void) { try { CORBA::Object_var object = this->orb_->resolve_initial_references ("RTORB"); RTCORBA::RTORB_var rt_orb = RTCORBA::RTORB::_narrow (object.in ()); object = this->orb_->resolve_initial_references ("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); CORBA::PolicyList policies; int result = get_priority_bands ("server", bands_file, rt_orb.in (), policies, debug); if (result != 0) return result; result = get_priority_lanes ("server", lanes_file, rt_orb.in (), stacksize, static_threads, dynamic_threads, allow_request_buffering, max_buffered_requests, max_request_buffer_size, allow_borrowing, policies, debug); if (result != 0) return result; CORBA::Policy_var priority_model_policy = rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED, 0); // Implicit_activation policy. CORBA::Policy_var implicit_activation_policy = root_poa->create_implicit_activation_policy (PortableServer::IMPLICIT_ACTIVATION); policies.length (policies.length () + 1); policies[policies.length () - 1] = priority_model_policy; policies.length (policies.length () + 1); policies[policies.length () - 1] = implicit_activation_policy; PortableServer::POA_var poa = root_poa->create_POA ("child", poa_manager.in (), policies); test_i *servant = 0; ACE_NEW_THROW_EX (servant, test_i (this->orb_.in (), poa.in ()), CORBA::NO_MEMORY ()); PortableServer::ServantBase_var safe_servant (servant); PortableServer::ObjectId_var id = poa->activate_object (servant); CORBA::Object_var object_act = poa->id_to_reference (id.in ()); test_var test = test::_narrow (object_act.in ()); write_iors_to_file (test.in (), this->orb_.in (), ior); poa_manager->activate (); this->orb_->run (); this->orb_->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught"); return -1; } return 0; }
int Task::svc (void) { try { CORBA::Object_var object = this->orb_->resolve_initial_references ("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); object = this->orb_->resolve_initial_references ("RTORB"); RTCORBA::RTORB_var rt_orb = RTCORBA::RTORB::_narrow (object.in ()); object = this->orb_->resolve_initial_references ("RTCurrent"); RTCORBA::Current_var current = RTCORBA::Current::_narrow (object.in ()); default_thread_priority = current->the_priority (); int result = 0; CORBA::ULong stacksize = 0; CORBA::Boolean allow_request_buffering = 0; CORBA::ULong max_buffered_requests = 0; CORBA::ULong max_request_buffer_size = 0; CORBA::PolicyList policies; CORBA::Boolean allow_borrowing = 0; if (number_of_lanes != 0) { get_auto_priority_lanes_and_bands (number_of_lanes, rt_orb.in (), stacksize, static_threads, dynamic_threads, allow_request_buffering, max_buffered_requests, max_request_buffer_size, allow_borrowing, policies, 1); } else if (ACE_OS::strcmp (lanes_file, ACE_TEXT("empty-file")) != 0) { result = get_priority_lanes ("server", lanes_file, rt_orb.in (), stacksize, static_threads, dynamic_threads, allow_request_buffering, max_buffered_requests, max_request_buffer_size, allow_borrowing, policies, 1); if (result != 0) return result; result = get_priority_bands ("server", bands_file, rt_orb.in (), policies, 1); if (result != 0) return result; } else { if (pool_priority == ACE_INT16_MIN) pool_priority = default_thread_priority; RTCORBA::ThreadpoolId threadpool_id = rt_orb->create_threadpool (stacksize, static_threads, dynamic_threads, pool_priority, allow_request_buffering, max_buffered_requests, max_request_buffer_size); policies.length (policies.length () + 1); policies[policies.length () - 1] = rt_orb->create_threadpool_policy (threadpool_id); if (ACE_OS::strcmp (bands_file, ACE_TEXT("empty-file")) != 0) { result = get_priority_bands ("server", bands_file, rt_orb.in (), policies, 1); if (result != 0) return result; } } policies.length (policies.length () + 1); policies[policies.length () - 1] = root_poa->create_implicit_activation_policy (PortableServer::IMPLICIT_ACTIVATION); policies.length (policies.length () + 1); policies[policies.length () - 1] = rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED, default_thread_priority); PortableServer::POA_var poa = root_poa->create_POA ("RT POA", poa_manager.in (), policies); test_i *servant = new test_i (this->orb_.in (), poa.in ()); PortableServer::ServantBase_var safe_servant (servant); ACE_UNUSED_ARG (safe_servant); test_var test = servant->_this (); result = write_ior_to_file (ior_output_file, this->orb_.in (), test.in ()); if (result != 0) return result; poa_manager->activate (); this->orb_->run (); this->orb_->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { DANCE_DISABLE_TRACE (); int retval = 0; try { DAnCE::Logger_Service * dlf = ACE_Dynamic_Service<DAnCE::Logger_Service>::instance ("DAnCE_Logger"); if (dlf) { dlf->init (argc, argv); } DANCE_DEBUG (DANCE_LOG_EVENT_TRACE, (LM_TRACE, DLINFO ACE_TEXT("SHS_Deamon - initializing ORB\n"))); CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); DANCE_DEBUG (DANCE_LOG_EVENT_TRACE, (LM_TRACE, DLINFO ACE_TEXT("SHS_Deamon - initializing module instance\n"))); TAO::Utils::ORB_Destroyer safe_orb (orb); CORBA::Object_var tmp = orb->resolve_initial_references ("NameService"); CosNaming::NamingContext_var domain_nc = CosNaming::NamingContext::_narrow (tmp); if (CORBA::is_nil (domain_nc.in ())) { ACE_ERROR ((LM_EMERGENCY, "SHS_Daemon - Unable to register with the"\ " CORBA Naming Service\n")); return -1; } CORBA::Object_var poa_obj = orb->resolve_initial_references ("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow (poa_obj.in ()); PortableServer::POAManager_var mgr = poa->the_POAManager (); PortableServer::POA_var persistent_poa; TAO::Utils::PolicyList_Destroyer policies (2); policies.length (2); try { DANCE_DEBUG (DANCE_LOG_TRACE, (LM_TRACE, DLINFO ACE_TEXT("SHS_Deamon - ") ACE_TEXT("before creating the \"SHS\" POA.\n"))); policies[0] = poa->create_id_assignment_policy ( PortableServer::USER_ID); policies[1] = poa->create_lifespan_policy ( PortableServer::PERSISTENT); persistent_poa = poa->create_POA ("SHS", mgr.in(), policies); } catch (const PortableServer::POA::AdapterAlreadyExists &) { persistent_poa = poa->find_POA ("Managers", 0); } DAnCE::SHS_Daemon_i *shs_daemon (0); ACE_NEW_RETURN (shs_daemon, DAnCE::SHS_Daemon_i (orb.in ()), 0); PortableServer::ServantBase_var safe_servant (shs_daemon); PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId ("SHS_Daemon"); persistent_poa->activate_object_with_id (oid, shs_daemon); CORBA::Object_var shs_obj = persistent_poa->id_to_reference (oid.in ()); CORBA::String_var shs_ior = orb->object_to_string (shs_obj.in ()); DAnCE::Utility::write_IOR (ACE_TEXT ("SHS_Daemon.ior"), shs_ior.in ()); CosNaming::Name name (1); name.length (1); name[0].id = "DAnCE.SystemHealthDaemon"; domain_nc->rebind (name, shs_obj.in ()); mgr->activate (); orb->run (); DANCE_DEBUG (DANCE_LOG_EVENT_TRACE, (LM_TRACE, DLINFO ACE_TEXT("SHS_Daemon - destroying ORB\n"))); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("SHS_Daemon"); retval = -1; } catch (...) { DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, "SHS_Daemon - Error: Unknown exception.\n")); retval = -1; } return retval; }