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"); if (CORBA::is_nil (poa_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the POA.\n"), 1); 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; // create, activate and initialize AMI reply handler Test_Reply_i test_i_rh_srv(orb.in (), max_count, mode_flag); PortableServer::ObjectId_var id = root_poa->activate_object (&test_i_rh_srv); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); A::AMI_TestHandler_var rh = A::AMI_TestHandler::_narrow (object.in ()); test_i_rh_srv.test_handler ().set_reply_handler (rh.in ()); // create and activate test servant Test_i test_i_srv (orb.in (), rh.in (), max_count, mode_flag); id = root_poa->activate_object (&test_i_srv); object = root_poa->id_to_reference (id.in ()); A::Test_var test_var = A::Test::_narrow (object.in ()); CORBA::String_var ior = orb->object_to_string (test_var.in ()); ACE_DEBUG ((LM_DEBUG, "Servant activated\n")); // If the ior_output_file exists, output the ior to it if (ior_output_file != 0) { 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 (); A::Test_var opponent; do { if (mode_flag == A::RM_SLAVE) ACE_OS::sleep (ACE_Time_Value (0, 100)); // get object reference for opponent object = orb->string_to_object (input_ior); opponent = A::Test::_narrow (object.in ()); } while (mode_flag == A::RM_SLAVE && CORBA::is_nil (opponent.in ())); if (CORBA::is_nil (opponent.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "Cannot resolve opponent IOR: %s", input_ior), 1); } // register opponent test_i_srv.set_opponent (opponent.in ()); test_i_rh_srv.test_handler ().set_opponent (opponent.in ()); // start the show if (mode_flag == A::RM_MASTER) test_i_rh_srv.test_handler ().start (); orb->run (); root_poa->destroy (1, // ethernalize objects 0 // wait for completion ); orb->destroy (); ACE_DEBUG ((LM_DEBUG, "event loop finished\n")); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Caught exception:"); 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 poa_object = orb->resolve_initial_references("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); if (CORBA::is_nil (root_poa.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Panic: nil RootPOA\n"), 1); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); if (parse_args (argc, argv) != 0) return 1; ArrayTest_i *target_servant; ACE_NEW_RETURN (target_servant,ArrayTest_i,1); PortableServer::ServantBase_var owner_transfer(target_servant); PortableServer::ObjectId_var id = root_poa->activate_object (target_servant); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); ArrayTest_var atobj = ArrayTest::_narrow (object.in ()); ServerAdmin_i *servant; ACE_NEW_RETURN (servant, ServerAdmin_i(atobj.in()),1); // safely releases previous reference and takes ownership of this one. owner_transfer = servant; id = root_poa->activate_object (servant); object = root_poa->id_to_reference (id.in ()); ServerAdmin_var saobj = ServerAdmin::_narrow (object.in ()); CORBA::String_var ior = orb->object_to_string (saobj.in ()); // Output the IOR to the <ior_output_file> 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 (); orb->run (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n")); root_poa->destroy (1, 1); 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[]) { 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 ()); if (CORBA::is_nil (root_poa.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Panic: nil RootPOA\n"), 1); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); if (parse_args (argc, argv) != 0) return 1; CORBA::Object_var tmp = orb->string_to_object(ior); Test::Oneway_Buffering_Admin_var admin = Test::Oneway_Buffering_Admin::_narrow(tmp.in ()); if (CORBA::is_nil (admin.in ())) { ACE_ERROR_RETURN ((LM_DEBUG, "Nil Oneway_Buffering_Admin reference <%s>\n", ior), 1); } Oneway_Buffering *oneway_buffering_impl; ACE_NEW_RETURN (oneway_buffering_impl, Oneway_Buffering (orb.in (), admin.in ()), 1); PortableServer::ServantBase_var owner_transfer(oneway_buffering_impl); PortableServer::ObjectId_var id = root_poa->activate_object (oneway_buffering_impl); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); Test::Oneway_Buffering_var oneway_buffering = Test::Oneway_Buffering::_narrow (object.in ()); CORBA::String_var ior = orb->object_to_string (oneway_buffering.in ()); // If the ior_output_file exists, output the ior to it 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 (); orb->run (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n")); root_poa->destroy (1, 1); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught in server:"); return 1; } return 0; }
std::string MultiTopicDataReaderBase::topicNameFor(DDS::DataReader_ptr reader) { DDS::TopicDescription_var td = reader->get_topicdescription(); CORBA::String_var topic = td->get_name(); return topic.in(); }
int Server_Task::svc (void) { try { CORBA::Object_var poa_object = sorb_->resolve_initial_references ("RootPOA"); if (CORBA::is_nil (poa_object.in ())) { ACE_ERROR ((LM_ERROR, " (%P|%t) Unable to initialize the POA\n")); return 1; } PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); poa_manager->activate (); Bug1495_i *server_impl = 0; ACE_NEW_RETURN (server_impl, Bug1495_i (sorb_.in ()), 0); PortableServer::ServantBase_var owner_transfer (server_impl); PortableServer::ObjectId_var id = root_poa->activate_object (server_impl); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); Bug1495_Regression::Bug1495_var bug1495 = Bug1495_Regression::Bug1495::_narrow (object.in ()); CORBA::String_var ior = sorb_->object_to_string (bug1495.in ()); if (output_ != 0) { FILE *output_file = ACE_OS::fopen (output_, "w"); if (output_file == 0) { ACE_ERROR ((LM_ERROR, "Cannot open output file for writing the " "thread server IOR: %s", output_)); return 1; } ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); } // sleep for a few seconds and hope the remote server picks up the // ior. ACE_OS::sleep (5); // Signal the manual event to wake the main thread up. me_.signal (); // The ORB will run for 15 seconds and shut down. ACE_Time_Value tv (15, 0); sorb_->run (tv); ACE_DEBUG ((LM_DEBUG, "Event loop finished for the thread server.\n")); root_poa->destroy (1, 1); sorb_->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Caught an exception in server task: "); 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 poa_object = orb->resolve_initial_references("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); if (CORBA::is_nil (root_poa.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the POA.\n"), 1); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); if (parse_args (argc, argv) != 0) return 1; Simple_Server_i server_impl (orb.in ()); PortableServer::ObjectId_var id = root_poa->activate_object (&server_impl); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); Simple_Server_var server = Simple_Server::_narrow (object.in ()); CORBA::String_var ior = orb->object_to_string (server.in ()); CORBA::Object_var table_object = orb->resolve_initial_references("IORTable"); IORTable::Table_var table = IORTable::Table::_narrow (table_object.in ()); if (CORBA::is_nil (table.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the IORTable.\n"), 1); table->bind ("Simple_Server", ior.in ()); ACE_DEBUG ((LM_DEBUG, "Activated as <%C>\n", ior.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 (); orb->run (); ACE_DEBUG ((LM_DEBUG, "event loop finished\n")); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { ACE_Auto_Ptr< sig_i > sig_impl; int status = 0; try { Supplier_Client client; status = client.init (argc, argv); if (status == 0) { CosNotifyChannelAdmin::EventChannel_var ec = client.create_event_channel ("MyEventChannel", 0); CORBA::ORB_ptr orb = client.orb (); sig_impl.reset( new sig_i( orb ) ); sig_var sig = sig_impl->_this (); CORBA::String_var ior = orb->object_to_string (sig.in ()); // If the ior_output_file exists, output the ior to it if (ior_output_file != 0) { FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file %s for " "writing IOR: %C", ior_output_file, ior.in ()), 1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); } CosNotifyChannelAdmin::SupplierAdmin_var admin = create_supplieradmin (ec.in ()); if (!CORBA::is_nil (admin.in ())) { create_suppliers(admin.in (), client.root_poa ()); sig_impl->wait_for_startup(); ACE_DEBUG((LM_DEBUG, "1 supplier sending %d events...\n", max_events)); for (int i = 0; i < max_events; ++i) { SendEvent (i); } ACE_DEBUG((LM_DEBUG, "\nSupplier sent %d events.\n", max_events)); sig_impl->wait_for_completion(); ACE_OS::unlink (ior_output_file); ec->destroy(); } } } catch (const CORBA::Exception& e) { e._tao_print_exception ("Error: Supplier exception: "); status = 1; } return status; }
////////////////// // Internal method void TAO::PG_Object_Group::distribute_iogr (void) { // Check if the object group is configured to distribute if (!this->distribute_) return; // assume internals is locked CORBA::String_var iogr = this->orb_->object_to_string (this->reference_.in()); // size_t n_rep = 0; // for dump_ior below for (MemberMap_Iterator it = this->members_.begin(); it != this->members_.end (); ++it) { MemberInfo const * info = (*it).int_id_; // // Unchecked narrow means the member doesn't have to actually implement the TAO_UpdateObjectGroup interface // PortableGroup::TAO_UpdateObjectGroup_var uog = PortableGroup::TAO_UpdateObjectGroup::_unchecked_narrow ( info->member_); // but it doesn work: error message at replica is: // TAO-FT (2996|976) - Wrong version information within the interceptor [1 | 0] // TAO_Perfect_Hash_OpTable:find for operation 'tao_update_object_group' (length=23) failed // back to using _narrow PortableGroup::TAO_UpdateObjectGroup_var uog = PortableGroup::TAO_UpdateObjectGroup::_narrow ( info->member_.in ()); if (!CORBA::is_nil (uog.in ())) { try { if (TAO_debug_level > 3) { ORBSVCS_DEBUG ((LM_DEBUG, "PG (%P|%t) - Object_Group pushing " "IOGR to %s member: %s@%s.\n", (info->is_primary_ ? "Primary" : "Backup"), this->role_.c_str (), static_cast<const char *> (info->location_[0].id) )); } // dump_ior ("group", "iogr", this->tagged_component_.object_group_ref_version, iogr); // CORBA::String_var replica_ior = this->orb_->object_to_string(uog.in()); // dump_ior (info->location_[0].id, "ior", (this->tagged_component_.object_group_ref_version * 100) + n_rep++, replica_ior); uog->tao_update_object_group (iogr.in (), this->tagged_component_.object_group_ref_version, info->is_primary_); } catch (const CORBA::Exception&) { // we expect an exception // tao_update_object_group is not a real method } } else { ORBSVCS_ERROR ((LM_ERROR, "TAO::PG_Object_Group::distribute iogr can't " "narrow member reference to " "PortableGroup::TAO_UpdateObjectGroup.\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"); if (CORBA::is_nil (poa_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the POA.\n"), 1); 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; Sender_i *sender_impl; ACE_NEW_RETURN (sender_impl, Sender_i (orb.in ()), 1); PortableServer::ServantBase_var receiver_owner_transfer(sender_impl); PortableServer::ObjectId_var id = root_poa->activate_object (sender_impl); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); Test::Sender_var sender = Test::Sender::_narrow (object.in ()); CORBA::String_var ior = orb->object_to_string (sender.in ()); // If the ior_output_file exists, output the ior to it 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 (); Server_Task server_task (orb.in (), ACE_Thread_Manager::instance ()); if (server_task.activate (THR_NEW_LWP | THR_JOINABLE, 4, 1) == -1) { ACE_ERROR ((LM_ERROR, "Error activating server task\n")); } ACE_Thread_Manager::instance ()->wait (); ACE_DEBUG ((LM_DEBUG, "Now terminating test\n")); CORBA::ULong activeobjects = sender_impl->get_active_objects (); if (((number_of_oneways * activeobjects) != sender_impl->get_number_received ()) && activeobjects != 0) { ACE_ERROR ((LM_ERROR, "Error, expected %d oneways, received %d\n", number_of_oneways, sender_impl->get_number_received())); } else { if (sender_impl->get_number_received () == 0) { ACE_ERROR ((LM_ERROR, "Error: Received no calls\n")); } else { ACE_DEBUG ((LM_DEBUG, "Corrected amount received\n")); } } root_poa->destroy (1, 1); 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[]) { int status = 0; ACE_Auto_Ptr< sig_i > sig_impl; try { Supplier_Client client; status = client.init (argc, argv); if (status == 0) { static const char* ec_name = "MyEventChannel"; CosNotifyChannelAdmin::EventChannel_var ec = client.create_event_channel (ec_name, 0); static const int max = 20; int count = 0; while(ACE_OS::access(ACE_TEXT_ALWAYS_CHAR(notify2ior), R_OK) == -1 && count < max) { ACE_OS::sleep (1); count++; } if (count >= max) { ACE_ERROR_RETURN ((LM_ERROR, "ERROR: Timed out waiting for the " "second notify service\n"), 1); } ACE_OS::sleep (2); // Due to the way that connections are handled, we need to // perform the new event channel creation twice to flush out // the connection to the first notification service try { ec = client.create_event_channel (ec_name, 0); } catch (const CORBA::TRANSIENT&) { } catch (const CORBA::COMM_FAILURE&) { } ec = client.create_event_channel (ec_name, 0); CORBA::ORB_ptr orb = client.orb (); // Activate the signaler with the POA sig_impl.reset( new sig_i( orb ) ); sig_var sig = sig_impl->_this (); CORBA::String_var ior = orb->object_to_string (sig.in ()); // If the ior_output_file exists, output the ior to it if (ior_output_file != 0) { FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file %s for " "writing IOR: %C", ior_output_file, ior.in ()), 1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); } CosNotifyChannelAdmin::SupplierAdmin_var admin = create_supplieradmin (ec.in ()); if (!CORBA::is_nil (admin.in ())) { create_suppliers (admin.in (), client.root_poa ()); sig_impl->wait_for_startup(); ACE_DEBUG((LM_DEBUG, "1 supplier sending %d events...\n", max_events)); for (int i = 0; i < max_events; ++i) { ACE_DEBUG((LM_DEBUG, "+")); SendEvent (i); } ACE_DEBUG((LM_DEBUG, "\nSupplier sent %d events.\n", max_events)); sig_impl->wait_for_completion(); ACE_OS::unlink (ior_output_file); supplier_1->disconnect(); ec->destroy(); } } } catch (const CORBA::Exception& e) { e._tao_print_exception ("Error: "); status = 1; } return status; }
int ACE_TMAIN (int argc, ACE_TCHAR* argv[]) { int status = 0; #if defined (TAO_HAS_MONITOR_FRAMEWORK) && (TAO_HAS_MONITOR_FRAMEWORK == 1) try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); if (parse_args (argc, argv) != 0) { return 1; } CORBA::Object_var obj = orb->string_to_object (monitor_ior); CosNotification::NotificationServiceMonitorControl_var nsm = CosNotification::NotificationServiceMonitorControl::_narrow (obj.in ()); if (CORBA::is_nil (nsm.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "Monitor: Unable to locate the " "Notification Service Monitor\n"), 1); } MonitorTestInterface_i* mti = 0; ACE_NEW_RETURN (mti, MonitorTestInterface_i (nsm.in ()), 1); PortableServer::ServantBase_var owner_transfer (mti); CORBA::Object_var poa_object = orb->resolve_initial_references("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::ObjectId_var id = root_poa->activate_object (mti); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); MonitorTestInterface_var test = MonitorTestInterface::_narrow (object.in ()); CORBA::String_var ior = orb->object_to_string (test.in ()); // Test the case where there are no consumers or suppliers first // before we write out our IOR mti->running (MonitorTestInterface::NotifyService); FILE *output_file= ACE_OS::fopen (ACE_TEXT_ALWAYS_CHAR(ior_output_file), ACE_TEXT ("w")); if (output_file == 0) { ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file for writing IOR: %s\n", ior_output_file), 1); } ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); poa_manager->activate (); orb->run (); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("test_monitor: "); status++; } #else ACE_UNUSED_ARG (argc); ACE_UNUSED_ARG (argv); #endif /* TAO_HAS_MONITOR_FRAMEWORK==1 */ return status; }
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 ()); if (CORBA::is_nil (root_poa.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Panic: nil RootPOA\n"), 1); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); // Make all oneways "reliable." { CORBA::Object_var manager_object = orb->resolve_initial_references("ORBPolicyManager"); CORBA::PolicyManager_var policy_manager = CORBA::PolicyManager::_narrow(manager_object.in()); if (CORBA::is_nil (policy_manager.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Panic: nil PolicyManager\n"), 1); CORBA::Any policy_value; policy_value <<= Messaging::SYNC_WITH_SERVER; CORBA::PolicyList policies(1); policies.length(1); policies[0] = orb->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE, policy_value); policy_manager->set_policy_overrides (policies, CORBA::ADD_OVERRIDE); policies[0]->destroy (); } if (parse_args (argc, argv) != 0) return 1; Service *service_impl; ACE_NEW_RETURN (service_impl, Service(orb.in ()), 1); PortableServer::ServantBase_var owner_transfer(service_impl); PortableServer::ObjectId_var id = root_poa->activate_object (service_impl); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); Test::Service_var service = Test::Service::_narrow (object.in ()); CORBA::String_var ior = orb->object_to_string (service.in ()); // If the ior_output_file exists, output the ior to it 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 (); orb->run (); ACE_DEBUG ((LM_DEBUG, "Event loop finished\n")); service_impl->dump_results (); root_poa->destroy (1, 1); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }
// Initialize the server. template <class Servant> int Server<Servant>::init (const char *servant_name, int argc, ACE_TCHAR *argv[]) { // Call the init of <TAO_ORB_Manager> to initialize the ORB and // create a child POA under the root POA. if (this->orb_manager_.init_child_poa (argc, argv, "child_poa") == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("%p\n"), ACE_TEXT ("init_child_poa")), -1); this->argc_ = argc; this->argv_ = argv; int retval = this->parse_args (); if (retval != 0) return retval; CORBA::ORB_var orb = this->orb_manager_.orb (); // Stash our ORB pointer for later reference. this->servant_->orb (orb.in ()); if (this->naming_ == 1) { // Call naming service if (this->register_name (servant_name) == -1) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("\n Naming Service\n")), -1); return 0; } // Activate the servant in its own child POA. // Make sure that you check for failures here via the try?! try { CORBA::String_var str = this->orb_manager_.activate_under_child_poa (servant_name, this->servant_.in ()); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("The IOR is: <%C>\n"), str.in ())); if (this->ins_ && this->test_for_ins (str.in ()) != 0) ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("test_for_ins (): failed\n")), -1); if (this->ior_output_file_) { FILE *fh = ACE_OS::fopen (this->ior_output_file_, "w"); if (fh == 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 (fh, "%s", str.in ()); ACE_OS::fclose (fh); } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("\tException in activation of POA"); return -1; } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { Server_ORBInitializer *temp_initializer = 0; ACE_NEW_RETURN (temp_initializer, Server_ORBInitializer, -1); // No exceptions yet! PortableInterceptor::ORBInitializer_var orb_initializer = temp_initializer; PortableInterceptor::register_orb_initializer (orb_initializer.in ()); CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "Server ORB"); CORBA::Object_var poa_object = orb->resolve_initial_references ("RootPOA"); if (CORBA::is_nil (poa_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the POA.\n"), 1); 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_i servant (orb.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 ior = orb->object_to_string (obj.in ()); ACE_DEBUG ((LM_DEBUG, "Servant:\n<%C>\n", ior.in ())); poa_manager->activate (); // Write IOR to a file. FILE *output_file= ACE_OS::fopen (ior_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file <%s> for writing " "IOR: %C", ior_file, ior.in ()), 1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); // Run the ORB event loop. orb->run (); root_poa->destroy (1, 1); orb->destroy (); ACE_DEBUG ((LM_DEBUG, "Event loop finished.\n")); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Caught exception:"); return -1; } return 0; }
void Receiver_exec_i::get_one (void) { ShapeType_var shape_info; ::CCM_DDS::ReadInfo_var readinfo; try { ::Shapes::Getter_var getter = this->ciao_context_->get_connection_info_get_fresh_data (); if (! ::CORBA::is_nil (getter.in ())) { ::CORBA::Object_var cmp = getter->_get_component (); if (::CORBA::is_nil (cmp.in ())) { ACE_ERROR ((LM_ERROR, "ERROR: Receiver_exec_i::get_one - " "Unable to get component interface\n")); throw ::CORBA::INTERNAL (); } ::Shapes::CCM_DDS_Event_var conn = ::Shapes::CCM_DDS_Event::_narrow (cmp.in ()); if (::CORBA::is_nil (conn.in ())) { ACE_ERROR ((LM_ERROR, "ERROR: Receiver_exec_i::get_one - " "Unable to narrow connector interface\n")); throw ::CORBA::INTERNAL (); } CORBA::String_var topic = conn->topic_name (); if (getter->get_one (shape_info.out (), readinfo.out ())) { ACE_Time_Value time; time <<= readinfo->source_timestamp; ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("GET_ONE ReadInfo -> ") ACE_TEXT ("date = %#T\n"), &time)); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("GET_ONE ShapeType : ") ACE_TEXT ("received shape_info <%C> for <%C> at X <%u> Y <%u> size <%u>\n"), topic.in (), shape_info->color.in (), shape_info->x, shape_info->y, shape_info->shapesize)); } else { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("GET_ONE No data available for <%C>\n"), shape_info->color.in ())); } } else { ACE_ERROR ((LM_ERROR, "Receiver_exec_i::get_one - " "ERROR: Getter seems nil\n")); } } catch(const CCM_DDS::NonExistent& ) { ACE_ERROR ((LM_ERROR, ACE_TEXT ("ShapeType_Read_One: no shape_info receieved\n"))); } }
void Lorica::Proxy::configure(Config & config, const std::string &def_ior_file ) throw (InitError) { try { // This should be OK even if multiple copies of Proxy // get created as they all create the same ORB instance // and therefore the single ORB instance will get shutdown. Lorica::Proxy::this_ = this; std::auto_ptr<ACE_ARGV> arguments(config.get_orb_options()); // Create proxy ORB. int argc = arguments->argc(); if (Lorica_debug_level > 2) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%T) %N:%l - passing %d args to ORB_init:\n"), argc)); for (int i = 0; i < argc; i++) ACE_DEBUG((LM_DEBUG, ACE_TEXT("%N:%l - %s\n"), arguments->argv()[i])); } orb_ = CORBA::ORB_init(argc, arguments->argv()); // test if we have any security functionality ACE_Service_Repository * repo = orb_->orb_core()->configuration()-> current_service_repository(); config.secure_available(repo->find("SSLIOP_Factory") == 0); int attempts = 3; CORBA::Object_var obj = CORBA::Object::_nil(); resolve_again: try { obj = orb_->resolve_initial_references("RootPOA"); } catch (CORBA::Exception & ex) { if (attempts--) { ACE_DEBUG((LM_INFO, ACE_TEXT("(%T) %N:%l - Exception trying to resolve initial references\n"))); ACE_OS::sleep(10); goto resolve_again; } ACE_DEBUG((LM_ERROR, ACE_TEXT("(%T) %N:%l - %s\n"), ex._info().c_str())); throw InitError(); } root_poa_ = PortableServer::POA::_narrow(obj.in()); if (CORBA::is_nil(root_poa_.in())) { ACE_ERROR((LM_ERROR, "(%T) %N:%l - could not get root POA\n")); throw InitError(); } pmf_ = root_poa_->the_POAManagerFactory(); if (CORBA::is_nil(pmf_.in())) { ACE_ERROR((LM_ERROR, "(%T) %N:%l - could not get PMF\n")); throw InitError(); } obj = orb_->resolve_initial_references("IORTable"); iorTable_ = IORTable::Table::_narrow(obj.in()); if (CORBA::is_nil(iorTable_.in())) { ACE_ERROR((LM_ERROR, "(%T) %N:%l - could not get IORTable\n")); throw InitError(); } CORBA::PolicyList policies; EndpointPolicy::EndpointList list; CORBA::Any policy_value; // Create external POA manager Config::Endpoints ex_points = config.get_endpoints(true); policies.length(1); list.length(ex_points.size()); if (Lorica_debug_level > 2) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%T) %N:%l - setting up External POA manager with %d endpoints\n"), ex_points.size())); } for (size_t count = 0; count < ex_points.size(); count++) { std::string inter = ex_points[count].hostname_; if (!ex_points[count].alias_.empty()) inter = ex_points[count].alias_; list[count] = new IIOPEndpointValue_i(inter.c_str(), ex_points[count].port_); } policy_value <<= list; policies[0] = orb_->create_policy(EndpointPolicy::ENDPOINT_POLICY_TYPE, policy_value); outside_pm_ = pmf_->create_POAManager("OutsidePOAManager", policies); // Create internal POA manager. Config::Endpoints in_points = config.get_endpoints(false); policies.length(1); list.length(in_points.size()); if (Lorica_debug_level > 2) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%T) %N:%l - setting up Internal POA manager with %d endpoints\n"), in_points.size())); } for (size_t count = 0; count < in_points.size(); count++) { std::string inter = in_points[count].hostname_; if (!in_points[count].alias_.empty()) inter = in_points[count].alias_; list[count] = new IIOPEndpointValue_i(inter.c_str(), in_points[count].port_); } policy_value <<= list; policies[0] = orb_->create_policy(EndpointPolicy::ENDPOINT_POLICY_TYPE, policy_value); inside_pm_ = pmf_->create_POAManager("InsidePOAManager", policies); if (Lorica_debug_level > 2) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%T) %N:%l - creating admin POA with internal POA manager\n"))); } policies.length(0); admin_poa_ = root_poa_->create_POA("adminPOA", inside_pm_.in(), policies); try { ReferenceMapper_i *refMapper = new ReferenceMapper_i(orb_.in(), iorTable_.in(), config.secure_available()); PortableServer::ServantBase_var refMapperServant = refMapper; PortableServer::ObjectId_var oid = admin_poa_->activate_object(refMapperServant.in()); obj = admin_poa_->id_to_reference(oid.in()); // refMapper->allow_insecure_access (obj.in()); } catch (CORBA::Exception & ex) { ACE_DEBUG((LM_ERROR, ACE_TEXT("(%T) %N:%l - %s\n"), ex._info().c_str())); throw InitError(); } ReferenceMapper_var refMapper_obj = ReferenceMapper::_narrow(obj.in()); CORBA::String_var ior = orb_->object_to_string(refMapper_obj.in()); iorTable_->bind(Lorica::ReferenceMapper::IOR_TABLE_KEY, ior.in()); this->ior_file_ = config.get_value("IOR_FILE", def_ior_file); FILE *output_file = ACE_OS::fopen (ACE_TEXT_CHAR_TO_TCHAR (this->ior_file_.c_str()), ACE_TEXT("w")); if (!output_file) { ACE_ERROR((LM_ERROR, "(%T) %N:%l - cannot open output file for writing IOR: %s\n", this->ior_file_.c_str())); throw InitError(); } ACE_OS::fprintf(output_file, "%s", ior.in()); ACE_OS::fclose(output_file); if (!setup_shutdown_handler()) { ACE_ERROR ((LM_ERROR, "(%T) %N:%l - could not set up shutdown handler\n")); throw InitError(); } // Initialize the mapper registry Lorica_MapperRegistry *mreg = ACE_Dynamic_Service<Lorica_MapperRegistry>::instance (this->orb_->orb_core()->configuration(),"MapperRegistry"); std::string ne_ids = config.null_eval_type_ids(); if (!ne_ids.empty()) { if (Lorica_debug_level > 2) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%T) %N:%l - adding type ids for null ") ACE_TEXT("evaluator: %s\n"), ne_ids.c_str())); } size_t space = ne_ids.find(' '); size_t start = 0; while (space != std::string::npos) { mreg->add_null_mapper_type(ne_ids.substr(start,space - start)); start = space+1; space = ne_ids.find(' ',start); } mreg->add_null_mapper_type(ne_ids.substr(start)); } else if (config.null_eval_any()) { if (Lorica_debug_level > 2) ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%T) %N:%l - creating default null mapper\n"))); mreg->create_default_null_mapper(); } if (config.generic_evaluator()) { if (Lorica_debug_level > 0) { ACE_DEBUG((LM_DEBUG, ACE_TEXT("(%T) %N:%l - loading generic evaluator\n"))); } #ifdef ACE_WIN32 this->orb_->orb_core()->configuration()->process_directive (ACE_TEXT_ALWAYS_CHAR (ACE_DYNAMIC_SERVICE_DIRECTIVE("Lorica_GenericLoader", "lorica_GenericEvaluator", "_make_Lorica_GenericLoader", "") ) ); #else Lorica::GenericMapper *gen_eval = new Lorica::GenericMapper(debug_, *mreg); mreg->add_proxy_mapper(gen_eval); #endif } // add generic or other mappers... mreg->init_mappers(this->outside_pm_, this->inside_pm_, this->orb_, config.secure_available()); // last thing to do, put both POAs in the active state. outside_pm_->activate(); inside_pm_->activate(); } catch (CORBA::Exception & ex) { ACE_DEBUG((LM_ERROR, ACE_TEXT("(%T) %N:%l - %s\n"), ex._info().c_str())); throw InitError(); } catch (...) { ACE_ERROR((LM_ERROR, "%N:%l - Caught an otherwise unknown exception\n")); throw InitError(); } }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); // We do the command line parsing first if (parse_args (argc, argv) != 0) return 1; CORBA::Object_var poa_object = orb->resolve_initial_references("RootPOA"); if (CORBA::is_nil (poa_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the POA.\n"), 1); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); // Instantiate the LCD_Display implementation class Simple_Server_i display_impl (orb.in ()); Simple_Server_var server = display_impl._this (); CORBA::String_var ior = orb->object_to_string (server.in ()); ACE_DEBUG ((LM_DEBUG, "Activated as <%C>\n", ior.in ())); // If the ior_output_file exists, output the ior to it if (ior_output_file != 0) { 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 (); orb->run (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Caught exception:"); return 1; } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - ORB_init\n")); CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - Obtain RootPOA\n")); CORBA::Object_var poa_object = orb->resolve_initial_references("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); if (CORBA::is_nil (root_poa.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Panic: nil RootPOA\n"), 1); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - parse args\n")); if (parse_args (argc, argv) != 0) return 1; ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - init hello\n")); Hello *hello_impl = 0; ACE_NEW_RETURN (hello_impl, Hello (orb.in ()), 1); PortableServer::ServantBase_var owner_transfer(hello_impl); PortableServer::ObjectId_var id = root_poa->activate_object (hello_impl); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); Test::Hello_var hello = Test::Hello::_narrow (object.in ()); CORBA::String_var ior = orb->object_to_string (hello.in ()); ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - Create the forwarding loop\n")); CORBA::Object_var iorTableObj = orb->resolve_initial_references ("IORTable"); IORTable::Table_var iorTable = IORTable::Table::_narrow (iorTableObj.in ()); // We are using this test with ObjRefStyle == URL ... or at // least we better be. The IOR is therefore a corbaloc ACE_CString full_corbaloc (ior.in (), 0, 1); // Create a corbaloc for an IOR table binding that points to // itself. Acessing this will make the server reply with LOCATION_FORWARD // indefinitely. ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - Corbaloc is\n \"%C\"\n", full_corbaloc.c_str())); // Get the endpoint info only... CORBA::ULong first_slash = full_corbaloc.find ("/", 0); ACE_CString forward_forever = full_corbaloc.substring (0, first_slash); // .. add the string we are going to bind against and then bind forward_forever += "/hello"; iorTable->bind("hello", forward_forever.c_str ()); ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - Forward forever is\n \"%C\"\n", forward_forever.c_str())); // Output the IORs 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\n", ior_output_file), 1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); output_file = ACE_OS::fopen (ior_output_file2, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file for writing IOR: %s\n", ior_output_file2), 1); ACE_OS::fprintf (output_file, "%s", forward_forever.c_str ()); ACE_OS::fclose (output_file); poa_manager->activate (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - orb->run()\n")); orb->run (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n")); root_poa->destroy (1, 1); 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[]) { int priority = (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO) + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2; priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO, priority); // Enable FIFO scheduling, e.g., RT scheduling class on Solaris. if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO, priority, ACE_SCOPE_PROCESS)) != 0) { if (ACE_OS::last_error () == EPERM) { ACE_DEBUG ((LM_DEBUG, "server (%P|%t): user is not superuser, " "test runs in time-shared class\n")); } else ACE_ERROR ((LM_ERROR, "server (%P|%t): sched_params failed\n")); } try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); CORBA::Object_var poa_object = orb->resolve_initial_references("RootPOA"); if (CORBA::is_nil (poa_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the POA.\n"), 1); 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; Roundtrip *roundtrip_impl; ACE_NEW_RETURN (roundtrip_impl, Roundtrip (orb.in ()), 1); PortableServer::ServantBase_var owner_transfer(roundtrip_impl); PortableServer::ObjectId_var id = root_poa->activate_object (roundtrip_impl); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); Test::Roundtrip_var roundtrip = Test::Roundtrip::_narrow (object.in ()); CORBA::String_var ior = orb->object_to_string (roundtrip.in ()); // If the ior_output_file exists, output the ior to it 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 (); Worker_Thread worker (orb.in ()); worker.activate (THR_NEW_LWP | THR_JOINABLE, 4, 1); worker.thr_mgr ()->wait (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n")); root_poa->destroy (1, 1); 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[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); CORBA::Object_var poa_object = orb->resolve_initial_references("RootPOA"); if (CORBA::is_nil (poa_object.in ())) { ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the POA.\n"), 1); } PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); poa_manager->activate (); if (parse_args (argc, argv) != 0) { return 1; } CORBA::Object_var object = orb->string_to_object (ior); DSI_Simple_Server server_impl (orb.in (), object.in (), root_poa.in ()); PortableServer::ObjectId_var oid = root_poa->activate_object (&server_impl); CORBA::Object_var server = root_poa->id_to_reference (oid.in ()); CORBA::String_var ior = orb->object_to_string (server.in ()); ACE_DEBUG ((LM_DEBUG, "Activated as <%C>\n", ior.in ())); // If the ior_output_file exists, output the ior to it if (ior_output_file != 0) { 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); } orb->run (); ACE_DEBUG ((LM_DEBUG, "event loop finished\n")); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Gateway: exception caught - "); return 1; } return 0; }
int FactoryDriver::start (int argc, ACE_TCHAR *argv []) { try { orb_ = CORBA::ORB_init (argc, argv); if (this->parse_args (argc, argv) == -1) return -1; // Ref counted servants are on the heap.. ACE_NEW_RETURN (factory_servant_, TAO_CosEventChannelFactory_i (), -1); CORBA::Object_var poa_object = orb_->resolve_initial_references("RootPOA"); if (CORBA::is_nil (poa_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the POA.\n"), -1); root_poa_ = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::POAManager_var poa_manager = root_poa_->the_POAManager (); poa_manager->activate (); // Initialization of the naming service. if (naming_client_.init (orb_.in ()) != 0) ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) Unable to initialize " "the TAO_Naming_Client.\n"), 1); CosNaming::NamingContext_var context = naming_client_.get_context (); if (factory_servant_->init (root_poa_.in (), child_poa_name_, context.in ()) != 0) ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) Unable to initialize " "the factory.\n"), 1); // activate the factory in the root poa. factory_ = factory_servant_->_this (); // Give the ownership to the POA. factory_servant_->_remove_ref (); CORBA::String_var str = orb_->object_to_string (factory_.in ()); ACE_DEBUG ((LM_DEBUG, "CosEvent_Service: The Cos Event Channel Factory IOR is <%s>\n", str.in ())); CosNaming::Name name (1); name.length (1); name[0].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(factoryName_)); naming_client_->rebind (name, factory_.in ()); ACE_DEBUG ((LM_DEBUG, "Registered with the naming service as %s\n", factoryName_)); orb_->run (); } catch (const CORBA::UserException& ue) { ue._tao_print_exception ("cosecfactory: "); return 1; } catch (const CORBA::SystemException& se) { se._tao_print_exception ("cosecfactory: "); return 1; } return 0; }
int TAO_Naming_Server::init_new_naming (CORBA::ORB_ptr orb, PortableServer::POA_ptr poa, const ACE_TCHAR *persistence_location, void *base_addr, size_t context_size, int enable_multicast, int use_storable_context, int round_trip_timeout, int use_round_trip_timeout) { try { #if defined (CORBA_E_MICRO) ACE_UNUSED_ARG (persistence_location); ACE_UNUSED_ARG (base_addr); ACE_UNUSED_ARG (use_storable_context); #else if (use_storable_context) { // In lieu of a fully implemented service configurator version // of this Reader and Writer, let's just take something off the // command line for now. TAO::Storable_Factory* pf = 0; ACE_CString directory (ACE_TEXT_ALWAYS_CHAR (persistence_location)); ACE_NEW_RETURN (pf, TAO::Storable_FlatFileFactory (directory), -1); auto_ptr<TAO::Storable_Factory> persFactory(pf); // Use an auto_ptr to ensure that we clean up the factory in the case // of a failure in creating and registering the Activator. TAO_Storable_Naming_Context_Factory* cf = this->storable_naming_context_factory (context_size); // Make sure we got a factory if (cf == 0) return -1; auto_ptr<TAO_Storable_Naming_Context_Factory> contextFactory (cf); // This instance will either get deleted after recreate all or, // in the case of a servant activator's use, on destruction of the // activator. // Was a location specified? if (persistence_location == 0) { // No, assign the default location "NameService" persistence_location = ACE_TEXT ("NameService"); } // Now make sure this directory exists if (ACE_OS::access (persistence_location, W_OK|X_OK)) { ORBSVCS_ERROR_RETURN ((LM_ERROR, "Invalid persistence directory\n"), -1); } #if (TAO_HAS_MINIMUM_POA == 0) && !defined (CORBA_E_COMPACT) if (this->use_servant_activator_) { ACE_NEW_THROW_EX (this->servant_activator_, TAO_Storable_Naming_Context_Activator (orb, persFactory.get(), contextFactory.get (), persistence_location), CORBA::NO_MEMORY ()); this->ns_poa_->set_servant_manager(this->servant_activator_); } #endif /* TAO_HAS_MINIMUM_POA */ try { // The following might throw an exception. this->naming_context_ = TAO_Storable_Naming_Context::recreate_all (orb, poa, TAO_ROOT_NAMING_CONTEXT, context_size, 0, contextFactory.get (), persFactory.get (), use_redundancy_); } catch (const CORBA::Exception& ex) { // The activator already took over the factories so we need to release the auto_ptr if (this->use_servant_activator_) { // The context factory is now owned by the activator // so we should release it contextFactory.release (); // If using a servant activator, the activator now owns the // factory, so we should release it persFactory.release (); } // Print out the exception and return failure ex._tao_print_exception ( "TAO_Naming_Server::init_new_naming"); return -1; } // Kind of a duplicate of the above here, but we must also release the // factory autoptrs in the good case as well. if (this->use_servant_activator_) { // The context factory is now owned by the activator // so we should release it contextFactory.release (); // If using a servant activator, the activator now owns the // factory, so we should release it persFactory.release (); } } else if (persistence_location != 0) // // Initialize Persistent Naming Service. // { // Create Naming Context Implementation Factory to be used for the creation of // naming contexts by the TAO_Persistent_Context_Index TAO_Persistent_Naming_Context_Factory *naming_context_factory = this->persistent_naming_context_factory (); // Make sure we got a factory. if (naming_context_factory == 0) return -1; // Allocate and initialize Persistent Context Index. ACE_NEW_RETURN (this->context_index_, TAO_Persistent_Context_Index (orb, poa, naming_context_factory), -1); if (this->context_index_->open (persistence_location, base_addr) == -1 || this->context_index_->init (context_size) == -1) { if (TAO_debug_level >0) ORBSVCS_DEBUG ((LM_DEBUG, "TAO_Naming_Server: context_index initialization failed\n")); return -1; } // Set the root Naming Context reference. this->naming_context_ = this->context_index_->root_context (); } else #endif /* CORBA_E_MICRO */ { // // Initialize Transient Naming Service. // this->naming_context_ = TAO_Transient_Naming_Context::make_new_context (poa, TAO_ROOT_NAMING_CONTEXT, context_size); } #if !defined (CORBA_E_MICRO) // Register with the ORB's resolve_initial_references() // mechanism. Primarily useful for dynamically loaded Name // Services. orb->register_initial_reference ("NameService", this->naming_context_.in ()); #endif /* CORBA_E_MICRO */ // Set the ior of the root Naming Context. this->naming_service_ior_= orb->object_to_string (this->naming_context_.in ()); CORBA::Object_var table_object = orb->resolve_initial_references ("IORTable"); IORTable::Table_var adapter = IORTable::Table::_narrow (table_object.in ()); if (CORBA::is_nil (adapter.in ())) { ORBSVCS_ERROR ((LM_ERROR, "Nil IORTable\n")); } else { CORBA::String_var ior = orb->object_to_string (this->naming_context_.in ()); adapter->bind ("NameService", ior.in ()); } #if defined (ACE_HAS_IP_MULTICAST) if (enable_multicast) { // @@ Marina: is there anyway to implement this stuff // without using ORB_Core_instance()? For example can you // pass the ORB as an argument? // // Install ior multicast handler. // // Get reactor instance from TAO. ACE_Reactor *reactor = orb->orb_core()->reactor (); // See if the -ORBMulticastDiscoveryEndpoint option was specified. ACE_CString mde (orb->orb_core ()->orb_params ()->mcast_discovery_endpoint ()); // First, see if the user has given us a multicast port number // on the command-line; u_short port = orb->orb_core ()->orb_params ()->service_port (TAO::MCAST_NAMESERVICE); if (port == 0) { // Check environment var. for multicast port. const char *port_number = ACE_OS::getenv ("NameServicePort"); if (port_number != 0) port = static_cast<u_short> (ACE_OS::atoi (port_number)); } // Port wasn't specified on the command-line or in environment - // use the default. if (port == 0) port = TAO_DEFAULT_NAME_SERVER_REQUEST_PORT; // Instantiate a handler which will handle client requests for // the root Naming Context ior, received on the multicast port. ACE_NEW_RETURN (this->ior_multicast_, TAO_IOR_Multicast (), -1); if (mde.length () != 0) { if (this->ior_multicast_->init (this->naming_service_ior_.in (), mde.c_str (), TAO_SERVICEID_NAMESERVICE) == -1) return -1; } else { if (this->ior_multicast_->init (this->naming_service_ior_.in (), port, #if defined (ACE_HAS_IPV6) ACE_DEFAULT_MULTICASTV6_ADDR, #else ACE_DEFAULT_MULTICAST_ADDR, #endif /* ACE_HAS_IPV6 */ TAO_SERVICEID_NAMESERVICE) == -1) return -1; } // Register event handler for the ior multicast. if (reactor->register_handler (this->ior_multicast_, ACE_Event_Handler::READ_MASK) == -1) { if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG, "TAO_Naming_Server: cannot register Event handler\n")); return -1; } if (TAO_debug_level > 0) ORBSVCS_DEBUG ((LM_DEBUG, "TAO_Naming_Server: The multicast server setup is done.\n")); } #else ACE_UNUSED_ARG (enable_multicast); #endif /* ACE_HAS_IP_MULTICAST */ #if defined (TAO_HAS_CORBA_MESSAGING) && TAO_HAS_CORBA_MESSAGING != 0 if (use_round_trip_timeout == 1) { TimeBase::TimeT roundTripTimeoutVal = round_trip_timeout; CORBA::Any anyObjectVal; anyObjectVal <<= roundTripTimeoutVal; CORBA::PolicyList polList (1); polList.length (1); polList[0] = orb->create_policy (Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE, anyObjectVal); // set a timeout on the orb // CORBA::Object_var orbPolicyManagerObj = orb->resolve_initial_references ("ORBPolicyManager"); CORBA::PolicyManager_var orbPolicyManager = CORBA::PolicyManager::_narrow (orbPolicyManagerObj.in ()); orbPolicyManager->set_policy_overrides (polList, CORBA::SET_OVERRIDE); polList[0]->destroy (); polList[0] = CORBA::Policy::_nil (); } #else ACE_UNUSED_ARG (use_round_trip_timeout); ACE_UNUSED_ARG (round_trip_timeout); #endif /* TAO_HAS_CORBA_MESSAGING */ } catch (const CORBA::Exception& ex) { ex._tao_print_exception ( "TAO_Naming_Server::init_new_naming"); return -1; } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { // Initialize the ORB. CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "Mighty ORB"); // Get the Root POA. CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow (obj.in ()); // Activate the POA manager. PortableServer::POAManager_var mgr = poa->the_POAManager (); mgr->activate (); // Create the Iterator_Factory servant and object. // It activates and deactivates the Content_Iterator object. Iterator_Factory_i factory_servant; Web_Server::Iterator_Factory_var factory = factory_servant._this (); // Get a reference to the Name Service. obj = orb->resolve_initial_references ("NameService"); // Narrow to a Naming Context CosNaming::NamingContext_var nc = CosNaming::NamingContext::_narrow (obj.in ()); // Create a name. CosNaming::Name name; name.length (1); name[0].id = CORBA::string_dup ("Iterator_Factory"); name[0].kind = CORBA::string_dup (""); nc->bind (name, factory.in ()); // Some debugging output. CORBA::String_var IOR = orb->object_to_string (factory.in ()); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Bound <%s> to <%s> in Name Service.\n"), name[0].id.in (), IOR.in ())); ACE_DEBUG ((LM_INFO, ACE_TEXT ("Accepting requests.\n"))); // Accept requests. orb->run (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception (ACE_TEXT ("Caught unexpected exception:")); return -1; } return 0; }
void _0RL_cd_969e6a9bf2804fc9_00000000::unmarshalArguments(cdrStream& _n) { arg_0_ = _n.unmarshalString(0); arg_0 = arg_0_.in(); }
void listContents(const CORBA::ContainedSeq& repoContents) { // // List the contents of each element. // for(unsigned int i = 0; i < repoContents.length(); ++i) { CORBA::Contained::Description_var desc = repoContents[i]->describe(); switch(desc->kind) { case CORBA::dk_Constant: ACE_DEBUG((LM_INFO, ACE_TEXT("%s: element[%d] is a constant definition.\n"), programLabel, i + 1 )); break; case CORBA::dk_Typedef: ACE_DEBUG((LM_INFO, ACE_TEXT("%s: element[%d] is a typedef definition.\n"), programLabel, i + 1 )); break; case CORBA::dk_Exception: ACE_DEBUG((LM_INFO, ACE_TEXT("%s: element[%d] is an exception definition.\n"), programLabel, i + 1 )); break; case CORBA::dk_Interface: { ACE_DEBUG((LM_INFO, ACE_TEXT("%s: element[%d] is an interface definition.\n") ACE_TEXT("%s: listing element[%d]...\n"), programLabel, i + 1, programLabel, i + 1 )); CORBA::InterfaceDef_var interfaceDef = CORBA::InterfaceDef::_narrow(repoContents[i]); listInterface(interfaceDef.in()); break; } case CORBA::dk_Module: { ACE_DEBUG((LM_INFO, ACE_TEXT("%s: element[%d] is a module definition.\n"), programLabel, i + 1 )); CORBA::ModuleDef_var moduleDef = CORBA::ModuleDef::_narrow(repoContents[i]); CORBA::ContainedSeq_var moduleContents = moduleDef->contents(CORBA::dk_all,1); CORBA::String_var moduleId = moduleDef->id(); CORBA::String_var moduleName = moduleDef->name(); ACE_DEBUG((LM_INFO, ACE_TEXT("%s:\n// %s\nmodule %s\n{\n") ACE_TEXT("%s: the module contains %d elements.\n"), programLabel, moduleId.in(), moduleName.in(), programLabel, moduleContents->length() )); listContents(moduleContents.in()); ACE_DEBUG((LM_INFO, ACE_TEXT("}\n"))); break; } default: break; } } }
int main (int argc, char **argv) #endif { try { // create logging proxy LoggingProxy *m_logger = new LoggingProxy(0, 0, 31, 0); LoggingProxy::init(m_logger); LoggingProxy::ProcessName(argv[0]); LoggingProxy::ThreadName("main"); ACS_TEST_INIT_LOGGING; // // Initialysation of CORBA, POA and related CORBA internals // ACE_CString g_strCmdLn; for (int i=argc-1; i>=0; i--) g_strCmdLn = ACE_CString(argv[i])+ " " + g_strCmdLn; if (g_strCmdLn.find("-ORBDottedDecimalAddresses")==ACE_CString::npos) g_strCmdLn += " -ORBDottedDecimalAddresses 1"; ACE_TCHAR **m_argv = argv; int m_argc = argc; ACE_OS::string_to_argv((ACE_TCHAR*)g_strCmdLn.c_str(), m_argc, m_argv); BACI_CORBA::InitCORBA(m_argc, m_argv); std::string readIOR; int result = read_IOR_from_file ("BACIALARM", readIOR); if (result != 0) { ACS_SHORT_LOG((LM_ERROR, "Cannot read IOR from file")); return -1; } // Get an object reference from the argument string. CORBA::Object_var object = BACI_CORBA::getORB()->string_to_object (readIOR.c_str()); if (CORBA::is_nil(object.in())) { ACS_SHORT_LOG ((LM_DEBUG, "Cannot create OBJ from IOR")); return -1; } // Try to narrow the object reference to a BaciTestAlarmClass reference. BACI_TEST::BaciTestAlarmClass_var comp = BACI_TEST::BaciTestAlarmClass::_narrow(object.in()); CORBA::String_var ior = BACI_CORBA::getORB()->object_to_string (comp.in()); ACS_SHORT_LOG((LM_INFO,"baciTestAlarmClient: Connecting to: %s", ior.in())); /********************* pattern alarm subscription ******************/ ACS::ROpattern_var roPattern = comp->roPatternProperty(); ACS::RWpattern_var rwPattern = comp->rwPatternProperty(); //create an instance of our alarm class MyAlarmpattern macb("roPatternProperty"); //activate it as a CORBA object ACS::Alarmpattern_var acb = macb._this(); //create the actual BACI double alarm ACS::CBDescIn desc; ACS::Subscription_var alarmSub = roPattern->new_subscription_Alarm(acb.in(), desc); ACS_SHORT_LOG((LM_INFO,"Alarmpattern subscription created")); // create the thread WorkerThreadPattern threadPattern_p ("actionThreadPattern", comp, ThreadBase::defaultResponseTime, ThreadBase::defaultSleepTime*10 /*=1s*/); // by default threads that are not created using a thread manager are creatd suspended so we have to resume them!! threadPattern_p.resume(); //--------------------------------------------------------------- //Enter main loop and stays there for a fixed amount of time. Really we are //just allowing the thread we just created to run for awhile before exiting out //of this example. ACS_SHORT_LOG((LM_INFO,"baciTestAlarmClient: main thread, entering ORB loop to sleep...")); ACE_Time_Value tv(25); BACI_CORBA::getORB()->run(tv); //Must cleanly destroy the alarm ACS_SHORT_LOG((LM_INFO,"Alarm subscriptions deleted")); alarmSub->destroy(); ACS_SHORT_LOG((LM_INFO,"baciTestAlarmClient: main thread, shutting down...")); comp->shutdown(); sleep(10); BACI_CORBA::DoneCORBA(); // Delete the logger last. delete m_logger; } catch(CORBA::Exception &ex) { ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,"Error!"); return -1; } ACE_CHECK_RETURN (-1); // Wait for the servant to complete cleanup before exiting. sleep(2); return 0; } /* end main() */
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 ()); if (CORBA::is_nil (root_poa.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Panic: nil RootPOA\n"), 1); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); if (parse_args (argc, argv) != 0) return 1; TAO_DTP_Definition dtp_config; set_parms(&dtp_config); //dtp_config.min_threads_ = -1; //dtp_config.init_threads_ = 5; //dtp_config.max_threads_ = -1; //dtp_config.stack_size_ = (40 * 1024); //dtp_config.timeout_.set(10,0); //dtp_config.queue_depth_ = 10; ACE_DEBUG((LM_INFO,ACE_TEXT("TAO (%P|%t) - Server : min_threads_ = %d\n"),dtp_config.min_threads_)); ACE_DEBUG((LM_INFO,ACE_TEXT("TAO (%P|%t) - Server : init_threads_ = %d\n"),dtp_config.init_threads_)); ACE_DEBUG((LM_INFO,ACE_TEXT("TAO (%P|%t) - Server : max_threads_ = %d\n"),dtp_config.max_threads_)); ACE_DEBUG((LM_INFO,ACE_TEXT("TAO (%P|%t) - Server : stack_size_ = %d\n"),dtp_config.stack_size_)); ACE_DEBUG((LM_INFO,ACE_TEXT("TAO (%P|%t) - Server : timeout_ = %d\n"),dtp_config.timeout_.sec())); ACE_DEBUG((LM_INFO,ACE_TEXT("TAO (%P|%t) - Server : queue_depth_ = %d\n"),dtp_config.queue_depth_)); ACE_DEBUG((LM_INFO,ACE_TEXT("TAO (%P|%t) - Server : sleep_sec = %d\n"),sleep_sec)); // Create the thread pool servant dispatching strategy object, and // hold it in a (local) smart pointer variable. TAO_Intrusive_Ref_Count_Handle<TAO_DTP_POA_Strategy> csd_strategy = new TAO_DTP_POA_Strategy(&dtp_config, false); // Tell the strategy to apply itself to the child poa. if (csd_strategy->apply_to(root_poa.in()) == false) { ACE_ERROR((LM_ERROR, "Failed to apply CSD strategy to root poa.\n")); return -1; } Hello *hello_impl; ACE_NEW_RETURN (hello_impl, Hello (orb.in ()), 1); PortableServer::ServantBase_var owner_transfer(hello_impl); PortableServer::ObjectId_var id = root_poa->activate_object (hello_impl); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); Test::Hello_var hello = Test::Hello::_narrow (object.in ()); CORBA::String_var ior = orb->object_to_string (hello.in ()); ACE_DEBUG ((LM_DEBUG,"Server calling poa_manager::activate()\n")); poa_manager->activate (); // Output the IOR to the <ior_output_file> FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file %s for writing IOR: %C", ior_output_file, ior.in ()), 1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); ACE_DEBUG ((LM_DEBUG,"Server calling hello->sleep_sec()\n")); // Set the sleep time for the Hello object hello->sleep_sec(sleep_sec); ACE_DEBUG ((LM_DEBUG,"Server calling orb::run()\n")); orb->run (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n")); // Wait for all CSD task threads exit. ACE_Thread_Manager::instance ()->wait (); root_poa->destroy (1, 1); 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 ()); if (CORBA::is_nil (root_poa.in ())) ACE_ERROR_RETURN ((LM_ERROR, "ERROR: Panic <RootPOA> is nil\n"), -1); 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 ()); // Create POA with CLIENT_PROPAGATED PriorityModelPolicy, // and register Test object with it. CORBA::PolicyList poa_policy_list; poa_policy_list.length (1); poa_policy_list[0] = rt_orb->create_priority_model_policy (RTCORBA::CLIENT_PROPAGATED, 0); PortableServer::POA_var child_poa = root_poa->create_POA ("Child_POA", poa_manager.in (), poa_policy_list); Test_i server_impl (this->orb_.in ()); PortableServer::ObjectId_var id = child_poa->activate_object (&server_impl); CORBA::Object_var server = child_poa->id_to_reference (id.in ()); // Print Object IOR. CORBA::String_var ior = this->orb_->object_to_string (server.in ()); ACE_DEBUG ((LM_DEBUG, "Activated as <%s>\n\n", ior.in ())); if (ior_output_file != 0) { 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); } // Get the initial priority of the current thread. // Note that it is an error to access the priority via the current in a thread that it // where it hasn't been set following the fix for tao681. CORBA::Short initial_thread_priority = get_implicit_thread_CORBA_priority (this->orb_.in ()); current->the_priority (initial_thread_priority); // Run ORB Event loop. poa_manager->activate (); this->orb_->run (); ACE_DEBUG ((LM_DEBUG, "Server ORB event loop finished\n")); // Get the final priority of the current thread. CORBA::Short final_thread_priority = current->the_priority (); if (final_thread_priority != initial_thread_priority) ACE_DEBUG ((LM_DEBUG, "ERROR: Priority of the servant thread " "has been permanently changed!\n" "Initial priority: %d Final priority: %d\n", initial_thread_priority, final_thread_priority)); else ACE_DEBUG ((LM_DEBUG, "Final priority of the servant thread" " = its initial priority\n")); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); 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 poa_object = orb->resolve_initial_references("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); if (CORBA::is_nil (root_poa.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Panic: nil RootPOA\n"), 1); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); if (parse_args (argc, argv) != 0) return 1; interface_3_i *if_3_impl = 0; ACE_NEW_RETURN (if_3_impl, interface_3_i (orb.in ()), 1); PortableServer::ServantBase_var owner_transfer(if_3_impl); PortableServer::ObjectId_var id = root_poa->activate_object (if_3_impl); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); ::Skeleton_Inheritance::Interface_3_var if_3 = ::Skeleton_Inheritance::Interface_3::_narrow (object.in ()); CORBA::String_var ior = orb->object_to_string (if_3.in ()); // Output the IOR to the <ior_output_file> 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\n", ior_output_file), 1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); poa_manager->activate (); orb->run (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n")); root_poa->destroy (1, 1); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }
int ECT_Throughput::run (int argc, ACE_TCHAR* argv[]) { try { // Calibrate the high resolution timer *before* starting the // test. ACE_High_Res_Timer::calibrate (); this->orb_ = CORBA::ORB_init (argc, argv); CORBA::Object_var poa_object = this->orb_->resolve_initial_references("RootPOA"); if (CORBA::is_nil (poa_object.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to initialize the POA.\n"), 1); PortableServer::POA_var root_poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::POAManager_var poa_manager = root_poa->the_POAManager (); poa_manager->activate (); if (this->parse_args (argc, argv)) return 1; if (TAO_debug_level > 0) { ACE_DEBUG ((LM_DEBUG, "Execution parameters:\n" " consumers = <%d>\n" " suppliers = <%d>\n" " burst count = <%d>\n" " burst size = <%d>\n" " event size = <%d>\n" " burst pause = <%d>\n" " consumer type start = <%d>\n" " consumer type count = <%d>\n" " consumer type shift = <%d>\n" " supplier type start = <%d>\n" " supplier type count = <%d>\n" " supplier type shift = <%d>\n" " pid file name = <%s>\n" " concurrency HWM = <%d>\n", this->n_consumers_, this->n_suppliers_, this->burst_count_, this->burst_size_, this->event_size_, this->burst_pause_, this->consumer_type_start_, this->consumer_type_count_, this->consumer_type_shift_, this->supplier_type_start_, this->supplier_type_count_, this->supplier_type_shift_, this->pid_file_name_?this->pid_file_name_:ACE_TEXT("nil"), this->ec_concurrency_hwm_ ) ); } if (this->pid_file_name_ != 0) { FILE* pid = ACE_OS::fopen (this->pid_file_name_, "w"); if (pid != 0) { ACE_OS::fprintf (pid, "%ld\n", static_cast<long> (ACE_OS::getpid ())); ACE_OS::fclose (pid); } } int priority = (ACE_Sched_Params::priority_min (ACE_SCHED_FIFO) + ACE_Sched_Params::priority_max (ACE_SCHED_FIFO)) / 2; priority = ACE_Sched_Params::next_priority (ACE_SCHED_FIFO, priority); // Enable FIFO scheduling, e.g., RT scheduling class on Solaris. if (ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO, priority, ACE_SCOPE_PROCESS)) != 0) { if (ACE_OS::last_error () == EPERM) { ACE_DEBUG ((LM_DEBUG, "%s: user is not superuser, " "so remain in time-sharing class\n", argv[0])); this->thr_create_flags_ = THR_NEW_LWP; } else ACE_ERROR ((LM_ERROR, "%s: ACE_OS::sched_params failed\n", argv[0])); } if (ACE_OS::thr_setprio (priority) == -1) { ACE_ERROR ((LM_ERROR, "(%P|%t) main thr_setprio failed," "no real-time features\n")); } #if 1 ACE_Config_Scheduler scheduler_impl; #else #include "ECT_Scheduler_Info.h" ACE_Runtime_Scheduler scheduler_impl ( runtime_configs_size, runtime_configs, runtime_infos_size, runtime_infos); #endif RtecScheduler::Scheduler_var scheduler = scheduler_impl._this (); #if 0 CORBA::Object_var naming_obj = this->orb_->resolve_initial_references ("NameService"); if (CORBA::is_nil (naming_obj.in ())) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Unable to get the Naming Service.\n"), 1); CosNaming::NamingContext_var naming_context = CosNaming::NamingContext::_narrow (naming_obj.in ()); // This is the name we (potentially) register the Scheduling // Service in the Naming Service. CosNaming::Name schedule_name (1); schedule_name.length (1); schedule_name[0].id = CORBA::string_dup ("ScheduleService"); CORBA::String_var str = this->orb_->object_to_string (scheduler.in ()); ACE_DEBUG ((LM_DEBUG, "The (local) scheduler IOR is <%s>\n", str.in ())); // Register the servant with the Naming Context.... naming_context->rebind (schedule_name, scheduler.in ()); ACE_Scheduler_Factory::use_config (naming_context.in ()); #endif /* 0 */ auto_ptr<POA_RtecEventChannelAdmin::EventChannel> ec_impl; TAO_EC_Event_Channel_Attributes attr (root_poa.in (), root_poa.in ()); TAO_EC_Event_Channel *ec = new TAO_EC_Event_Channel (attr); ec->activate (); auto_ptr<POA_RtecEventChannelAdmin::EventChannel> auto_ec_impl (ec); ec_impl = auto_ec_impl; RtecEventChannelAdmin::EventChannel_var channel = ec_impl->_this (); this->connect_consumers (scheduler.in (), channel.in ()); ACE_DEBUG ((LM_DEBUG, "connected consumer(s)\n")); this->connect_suppliers (scheduler.in (), channel.in ()); ACE_DEBUG ((LM_DEBUG, "connected supplier(s)\n")); this->activate_suppliers (); ACE_DEBUG ((LM_DEBUG, "suppliers are active\n")); // Wait for the supplier threads... if (ACE_Thread_Manager::instance ()->wait () == -1) { ACE_ERROR ((LM_ERROR, "Thread_Manager wait failed\n")); return 1; } ACE_DEBUG ((LM_DEBUG, "suppliers finished\n")); this->dump_results (); this->disconnect_consumers (); ACE_DEBUG ((LM_DEBUG, "consumers disconnected\n")); this->disconnect_suppliers (); ACE_DEBUG ((LM_DEBUG, "suppliers disconnected\n")); channel->destroy (); ACE_DEBUG ((LM_DEBUG, "channel destroyed\n")); { // Deactivate the EC PortableServer::POA_var poa = ec_impl->_default_POA (); PortableServer::ObjectId_var id = poa->servant_to_id (ec_impl.get ()); poa->deactivate_object (id.in ()); ACE_DEBUG ((LM_DEBUG, "EC deactivated\n")); } { // Deactivate the Scheduler PortableServer::POA_var poa = scheduler_impl._default_POA (); PortableServer::ObjectId_var id = poa->servant_to_id (&scheduler_impl); poa->deactivate_object (id.in ()); ACE_DEBUG ((LM_DEBUG, "scheduler deactivated\n")); } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("ECT_Throughput::run"); } catch (...) { ACE_ERROR ((LM_ERROR, "non-corba exception raised\n")); } return 0; }