int FTP_Server_Callback::handle_end_stream (void) { CORBA::ORB_var orb = TAO_AV_CORE::instance ()->orb (); orb->shutdown (); return 0; }
void shutdown_handler (void) { if (!CORBA::is_nil(mapper.in())) mapper->remove_server(mapped_hello.in()); orb->shutdown(); }
void handler(int r) { DMSG_("Stoping service... "); my_global_orb->shutdown(true); DMSG("Done"); exit(1); }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { CORBA::ORB_var orb; try { orb = CORBA::ORB_init (argc, argv); test_impl foo_i; int something = 28; foo_i.bar ((CORBA::VoidData) &something); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Caught exception:"); try { orb->shutdown (); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Caught exception while shutting down:"); return 1; } return 0; } return 0; }
int FTP_Server_Callback::handle_end_stream (void) { ACE_DEBUG ((LM_DEBUG,"FTP_SFP_Callback::end_stream\n")); CORBA::ORB_var orb = TAO_AV_CORE::instance ()->orb (); orb->shutdown (); return 0; }
ACE_THR_FUNC_RETURN killer (void *arg) { CORBA::ORB_var orb = reinterpret_cast<CORBA::ORB_ptr> (arg); ACE_DEBUG ((LM_DEBUG,"(%P|%t) server exiting\n")); orb->shutdown (1); return 0; }
void Object_A_i::shutdown (void) { int argc = 0; ACE_TCHAR **argv = 0; CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); orb->shutdown (); }
int ACE_TMAIN ( int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); MessageFactory *mf = new MessageFactory (); CORBA::String_var id = _tc_Message->id (); ACE_DEBUG ((LM_DEBUG, "Registering factory reference\n")); orb->register_value_factory (id.in (), mf); ACE_DEBUG ((LM_DEBUG, "Unregistering factory reference\n")); orb->unregister_value_factory (id.in ()); ACE_DEBUG ((LM_DEBUG, "Value factory destructor flag: %i\n", MessageFactory::destructorInvoked_)); ACE_DEBUG ((LM_DEBUG, "Actively removing reference\n")); mf->_remove_ref (); ACE_DEBUG ((LM_DEBUG, "Value factory destructor flag: %i\n", MessageFactory::destructorInvoked_)); ACE_DEBUG ((LM_DEBUG, "Shutting down / destroying ORB\n")); orb->shutdown (true); orb->destroy (); if (MessageFactory::destructorInvoked_ == 1) { ACE_DEBUG ((LM_ERROR, "Test passed: value factory destructor was invoked as expected\n")); return 0; } else { ACE_DEBUG ((LM_ERROR, "Test failed: value factory destructor was not invoked\n")); return 1; } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("CORBA exception caught during execution"); return -1; } catch (...) { ACE_DEBUG ((LM_ERROR, "Non-CORBA exception caught during execution")); return -1; } }
ACE_THR_FUNC_RETURN failsafe (void *) { test_lock.acquire(); ACE_Time_Value timeout = ACE_OS::gettimeofday() + ACE_Time_Value (10,0); cond.wait(&timeout); test_lock.release(); if (!is_ok) { ACE_DEBUG ((LM_DEBUG, "FAILURE: failsafe timed out\n")); orb->shutdown(0); ACE_OS::exit(1); } return 0; }
void TerminationSignalHandler(int) { try { // false - avoid deadlock; true would try to wait for all requests // to complete before returning, but because we are calling it from within // a request, we would be blocking it from orb->shutdown(false); } catch( CORBA::Exception &ex ) { ex._tao_print_exception("TerminationSignalHandler"); } }
int TAO_CosNotify_Service::fini (void) { if (TAO_Notify_PROPERTIES::instance()->separate_dispatching_orb()) { if (!CORBA::is_nil (TAO_Notify_PROPERTIES::instance()->dispatching_orb())) { CORBA::ORB_var dispatcher = TAO_Notify_PROPERTIES::instance()->dispatching_orb(); dispatcher->shutdown (); dispatcher->destroy (); } } TAO_Notify_Properties::instance()->close (); return 0; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); ORB_Task orb_runner (orb.in ()); if (orb_runner.activate (THR_NEW_LWP | THR_JOINABLE, 1) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "ERROR: Can not start ORB thread\n"), -1); } ACE_OS::sleep (1); Worker_Task work_runner (orb.in ()); if (work_runner.activate (THR_NEW_LWP | THR_JOINABLE, 10) == -1) { ACE_ERROR_RETURN ((LM_ERROR, "ERROR: Can not start work threads\n"), -1); } ACE_OS::sleep (1); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Shutting down / destroying ORB\n"))); orb->shutdown (false); ACE_Thread_Manager::instance ()->wait (); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return status; }
int main (int argc, char* argv[]) { CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); PortableServer::POAManager_var manager = root_poa->the_POAManager(); manager->activate(); Writer* writer = new Writer(); PortableServer::ObjectId_var oid = root_poa->activate_object(writer); rawdata::writer_var ref = writer->_this(); CORBA::String_var ior = orb->object_to_string(ref); std::cout << ior << std::endl; orb->run(); orb->shutdown(true); orb->destroy(); }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { PortableServer::POAManager_var poa_manager; CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); CORBA::Object_var poa_obj = orb->resolve_initial_references("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow(poa_obj.in()); poa_manager = root_poa->the_POAManager(); poa_manager->activate(); /*Get event_channel*/ std::cout << "Create event_channel now" << std::endl; CosNotifyChannelAdmin::EventChannel_var ec = get_event_channel(orb.in()); //Instanciating the Supplier CosNotifyComm::StructuredPushSupplier_var sps = CosNotifyComm::StructuredPushSupplier::_nil(); CosNotifyCommImpl::StructuredPushSupplier *pImpl_sps = new CosNotifyCommImpl::StructuredPushSupplier; sps = pImpl_sps->_this(); //Obtain a Supplier Admin CosNotifyChannelAdmin::SupplierAdmin_var sa = ec->default_supplier_admin(); if( sa.in() == CosNotifyChannelAdmin::SupplierAdmin::_nil() ){ std::cerr << "sa is nil!" << std::endl; return 1; } //Obtain a Proxy Consumer CosNotifyChannelAdmin::ProxyID proxy_id; CosNotifyChannelAdmin::ClientType ctype = CosNotifyChannelAdmin::STRUCTURED_EVENT; CosNotifyChannelAdmin::ProxyConsumer_var proxyCon_obj; try { proxyCon_obj = sa->obtain_notification_push_consumer(ctype, proxy_id); } catch(CosNotifyChannelAdmin::AdminLimitExceeded err) { std::cerr << "CosNotifyChannelAdmin::AdminLimitExceeded Exception!" << std::endl; throw; } CosNotifyChannelAdmin::StructuredProxyPushConsumer_var ppc = CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow(proxyCon_obj.in()); //Connecting a Supplier to a Proxy Consumer try { ppc->connect_structured_push_supplier(sps.in()); } catch (CosEventChannelAdmin::AlreadyConnected ac) { std::cerr << "CosEventChannelAdmin::AlreadyConnected" << std::endl; throw; } catch (CORBA::SystemException& se) { std::cerr << "System exception occurred during connect: " << se << std::endl; throw; } //Demo::demo_send_heart_beat(ppc); //Send a Demo Notification CosNotification::StructuredEvent event; event.header.fixed_header.event_type.domain_name = CORBA::string_dup("Test_domain"); event.header.fixed_header.event_type.type_name = CORBA::string_dup("Test_type_name"); event.header.variable_header.length(0); event.remainder_of_body <<= ""; std::cout << "Sending a demo event...," << std::endl; std::cout << "event.header.fixed_header.event_type.domain_name = " << event.header.fixed_header.event_type.domain_name << std::endl; std::cout << "event.header.fixed_header.event_type.type_name = " << event.header.fixed_header.event_type.type_name << std::endl; try{ ppc->push_structured_event(event); } catch (CORBA::SystemException& se) { std::cerr << "System exception occurred during push: " << se << std::endl; throw; } catch (CORBA::Exception&) { std::cerr << "Unknown exception occurred during push" << std::endl; throw; } try{ ppc->disconnect_structured_push_consumer(); } catch(CORBA::Exception&) { std::cerr << "Disconnect fail!" << std::endl; } orb->shutdown(); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("Supplier done.\n"))); } catch(...) { std::cerr << "Supplier: Some exceptions was caught!" << std::endl; 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; TestServer *test_impl = 0; ACE_NEW_RETURN (test_impl, TestServer (), 1); PortableServer::ServantBase_var owner_transfer(test_impl); PortableServer::ObjectId_var id = root_poa->activate_object (test_impl); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); Test::TestServer_var test = Test::TestServer::_narrow (object.in ()); CORBA::String_var ior = orb->object_to_string (test.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 (); // Run a CORBA worker thread Worker work (orb.in()); work.activate (THR_NEW_LWP | THR_JOINABLE | THR_INHERIT_SCHED, 1); ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - waiting for client to call\n")); ACE_OS::sleep (10); if (test_impl->got_callback() == false) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - client did not make call\n")); return 1; } ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - making repeated calls to client\n")); for (int i = 0; i < 10; i++) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - calling client attempt %d\n", i)); test_impl->make_callback(); } ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - stopping client\n")); test_impl->shutdown_client(); ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - test completed\n")); orb->shutdown (); // shutdown our ORB work.wait (); // wait for the worker to finish 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 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 (); poa_manager->activate (); Task task (orb.in ()); int result = task.activate (); ACE_ASSERT (result != -1); ACE_UNUSED_ARG (result); CORBA::PolicyList policies (1); policies.length (1); policies[0] = root_poa->create_id_assignment_policy (PortableServer::USER_ID); PortableServer::POA_var child_poa = root_poa->create_POA ("child_poa", poa_manager.in (), policies); test_i *base_servant = new test_i (orb.in (), child_poa.in ()); PortableServer::ServantBase_var safe_base_servant (base_servant); PortableServer::ObjectId_var base_oid = PortableServer::string_to_ObjectId ("base"); child_poa->activate_object_with_id (base_oid.in (), base_servant); PortableServer::ObjectId_var id_act = root_poa->activate_object (base_servant); CORBA::Object_var object_act = root_poa->id_to_reference (id_act.in ()); test_var base_test = test::_narrow (object_act.in ()); test_i *first_servant = new test_i (orb.in (), child_poa.in ()); PortableServer::ServantBase_var safe_first_servant (first_servant); PortableServer::ObjectId_var first_oid = PortableServer::string_to_ObjectId ("first"); child_poa->activate_object_with_id (first_oid.in (), first_servant); PortableServer::ObjectId_var id_actu = root_poa->activate_object (first_servant); object_act = root_poa->id_to_reference (id_actu.in ()); test_var first_test = test::_narrow (object_act.in ()); base_servant->set_other (first_test.in ()); base_test->method (); PortableServer::ObjectId_var second_oid = PortableServer::string_to_ObjectId ("second"); object = child_poa->create_reference_with_id (second_oid.in (), "IDL:test:1.0"); test_var second_test = test::_narrow (object.in ()); test_i *second_servant = new test_i (orb.in (), child_poa.in ()); PortableServer::ServantBase_var safe_second_servant (second_servant); child_poa->activate_object_with_id (second_oid.in (), second_servant); base_servant->set_other (second_test.in ()); base_test->method (); PortableServer::ObjectId_var third_oid = PortableServer::string_to_ObjectId ("third"); object = child_poa->create_reference_with_id (third_oid.in (), "IDL:test:1.0"); CORBA::String_var third_ior = orb->object_to_string (object.in ()); object = orb->string_to_object (third_ior.in ()); test_var third_test = test::_narrow (object.in ()); test_i *third_servant = new test_i (orb.in (), child_poa.in ()); PortableServer::ServantBase_var safe_third_servant (third_servant); child_poa->activate_object_with_id (third_oid.in (), third_servant); base_servant->set_other (third_test.in ()); base_test->method (); orb->shutdown (1); result = task.wait (); ACE_ASSERT (result != -1); ACE_UNUSED_ARG (result); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Caught exception:"); return -1; } return 0; }
int Client_Worker::test_main (int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); if (parse_args (argc, argv) != 0) ACE_ERROR_RETURN ((LM_DEBUG, ACE_TEXT ("(%P|%t) Could not parse the arguments\n")), 1); // Doing this dance to allow the server some time to come up. CORBA::Object_ptr co = 0; for (int attempts_left = 5; attempts_left > 0; --attempts_left) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Client is ready to proceed - awaiting the server ...\n"))); ACE_OS::sleep (1); try { co = orb->string_to_object (ior_file_.c_str ()); if (co == 0) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Unable to obtain object reference yet. Retrying.\n"))); continue; } CORBA::Object_var tmp (co); Test::Hello_var hello = Test::Hello::_narrow(tmp.in ()); if (CORBA::is_nil (hello.in ())) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Nil Test::Hello reference <%s>. Retrying.\n"), ior_file_.c_str ())); continue; } ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Successfuly narrowed the Hello interface\n"))); CORBA::String_var the_string = hello->get_string (); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) String returned from the server <%C>\n"), the_string.in ())); hello->shutdown (); attempts_left = 0; // We're done here! } catch (const CORBA::TRANSIENT& ex) { if (!attempts_left) throw; ex._tao_print_exception ("Temporary problem encountered"); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Client was too quick. Pausing ") ACE_TEXT ("while the server gets ready.\n"))); ACE_OS::sleep (5); } catch (const CORBA::Exception& ex) { ex._tao_print_exception("Unexpected CORBA exception caught"); if (!attempts_left) throw; ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Pausing for a while.\n"))); ACE_OS::sleep (5); } } orb->shutdown (0); orb->destroy (); } catch (const ::CORBA::Exception &e) { e._tao_print_exception("Client_Worker::test_main"); 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 (); Foo_Bar *foobar_impl; ACE_NEW_RETURN (foobar_impl, Foo_Bar (orb.in ()), 1); PortableServer::ObjectId_var id = root_poa->activate_object (foobar_impl); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); Test::Foo_var foo = Test::Foo::_narrow (object.in ()); poa_manager->activate (); // Dont unscope it or move it elsewhere.. It is here with a // purpose. If you dont understand this, please re-read the // README file. { PortableServer::ServantBase_var owner_transfer (foobar_impl); } ACE_Time_Value tv (10, 0); // Just run the ORB for a minute.. orb->run (tv); ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - shutting down the ORB\n")); orb->shutdown (1); ACE_DEBUG ((LM_DEBUG, "(%P|%t) Finished shutting down the ORB\n")); root_poa->destroy (1, 1); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } ACE_DEBUG ((LM_DEBUG, "(%P|%t) Test successful..\n")); return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); if (parse_args (argc, argv) != 0) return 1; CORBA::Object_var object = orb->string_to_object (ior); A::AMI_Test_var server = A::AMI_Test::_narrow (object.in ()); if (CORBA::is_nil (server.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "Object reference <%s> is nil.\n", ior), 1); } // Activate POA to handle the call back. 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 (); // Let the client perform the test in a separate thread Handler* handler = 0; ACE_NEW_RETURN (handler, Handler, 1); PortableServer::ServantBase_var owner_transfer(handler); PortableServer::ObjectId_var id = root_poa->activate_object (handler); CORBA::Object_var object2 = root_poa->id_to_reference (id.in ()); A::AMI_AMI_TestHandler_var hello = A::AMI_AMI_TestHandler::_narrow (object2.in ()); object2 = CORBA::Object::_nil (); server->shutdown (); // oneway, so returns here immediately but server waits 5 sec Client client (server.in (), niterations, hello.in ()); if (client.activate (THR_NEW_LWP | THR_JOINABLE, nthreads) != 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot activate client threads\n"), 1); // Main thread collects replies. It needs to collect // <nthreads*niterations> replies. number_of_replies = nthreads *niterations; if (debug) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) : Entering perform_work loop to receive <%d> replies\n", number_of_replies)); } // ORB loop. ACE_Time_Value tv (1,0); orb->run (tv); if (debug) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) : Exited perform_work loop Received <%d> replies\n", (nthreads*niterations) - number_of_replies)); } ACE_DEBUG ((LM_DEBUG, "threads finished\n")); client.wait (); tv = ACE_Time_Value (1,0); orb->run (tv); root_poa->deactivate_object (id.in ()); root_poa->destroy (1, // ethernalize objects 0); // wait for completion hello = A::AMI_AMI_TestHandler::_nil (); root_poa = PortableServer::POA::_nil (); poa_object = CORBA::Object::_nil (); object = CORBA::Object::_nil (); server = A::AMI_Test::_nil (); poa_manager = PortableServer::POAManager::_nil (); client.clear (); orb->shutdown (); orb->destroy (); CORBA::ULong ref_count = orb->_refcount(); if (ref_count > 1) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT("Refcount orb %d\n"), ref_count)); ++parameter_corruption; } else { TAO_ORB_Core* core = orb->orb_core (); if (core != 0) { ACE_DEBUG ((LM_DEBUG, ACE_TEXT("Core <> null\n"))); ++parameter_corruption; } } orb = CORBA::ORB::_nil (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Caught exception:"); return 1; } return parameter_corruption; }
int main(int argc, char* argv[]) { char aux1[1000]; time_t seconds; signal(SIGINT, TerminarEjecucion); time(&seconds); srand((unsigned int) seconds); try { // Inicializacion del ORB CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, ""); // Recoge la referencia al canal cin >> aux1; CORBA::Object_var obj = orb->string_to_object(aux1); // Obtiene el canal CosNotifyChannelAdmin::EventChannel_var channel; channel = CosNotifyChannelAdmin::EventChannel::_narrow(obj); if (CORBA::is_nil(channel)) { cerr << "[supplier2] ERROR: canal nulo " << endl; return -1; } // Obtiene el SupplierAdmin CosNotifyChannelAdmin::AdminID id; _supplier_admin = channel->new_for_suppliers(CosNotifyChannelAdmin::AND_OP, id); cerr << "[supplier2] SupplierAdminId = " << id << endl; CosNotifyChannelAdmin::ProxyID proxy_id; CosNotifyChannelAdmin::ProxyConsumer_var proxy_consumer = _supplier_admin->obtain_notification_push_consumer( CosNotifyChannelAdmin::STRUCTURED_EVENT, proxy_id); cerr << "[supplier2] ProxyId = " << proxy_id << endl; // Obtiene el StructuredProxyPushConsumer _consumer = CosNotifyChannelAdmin::StructuredProxyPushConsumer::_narrow(proxy_consumer); try{ CosNotifyComm::StructuredPushSupplier_var supplier = CosNotifyComm::StructuredPushSupplier::_nil(); _consumer->connect_structured_push_supplier(supplier); if (_consumer == NULL) cerr << "[supplier2] consumer NULO 5" << endl; } catch (CORBA::Exception& exc) { cerr << "[supplier2] Exception in _consumer->connect_push_supplier(...)"; cerr << exc << endl; } catch (...) { cerr << "[supplier2] Unknowed exception "; cerr << "in _consumer->connect_push_supplier(...)"; } #ifdef _TAO sleep(1); #elif defined _TIDORB TIDThr::Thread::sleep(1000); // 1 '' #endif cerr << "[supplier2] Crea un structured event" << flush << endl; try{ CosNotification::StructuredEvent* event = NULL; int rnd = 0; for(int i=0; i < 200; i++) { rnd = rand(); TimeBase::UtcT current_utc = TIDorb::core::util::Time::currentUtcT(); TimeBase::UtcT future_utc = TIDorb::core::util::Time::currentUtcT(); TimeBase::UtcT pass_utc = TIDorb::core::util::Time::currentUtcT(); future_utc.time += (5 * 10000000); // now + 5 '' pass_utc.time -= (5 * 10000000); // now - 5 '' // Rellenamos la informacion del evento event = new CosNotification::StructuredEvent(); event->header.fixed_header.event_name = (rnd % 2) ? CORBA::string_dup("event_name") : CORBA::string_dup("other"); event->header.fixed_header.event_type.domain_name = (rnd % 2) ? CORBA::string_dup("domain_name") : CORBA::string_dup("other"); event->header.fixed_header.event_type.type_name = (rnd % 2) ? CORBA::string_dup("type_name") : CORBA::string_dup("other"); event->header.variable_header.length(5); event->header.variable_header[0].name = CORBA::string_dup("EventReliability"); event->header.variable_header[0].value <<= (CORBA::Short) 0; event->header.variable_header[1].name = CORBA::string_dup("Priority"); event->header.variable_header[1].value <<= (CORBA::Short) 0; event->header.variable_header[2].name = CORBA::string_dup("StartTime"); event->header.variable_header[2].value <<= current_utc; event->header.variable_header[3].name = CORBA::string_dup("StopTime"); event->header.variable_header[3].value <<= pass_utc; event->header.variable_header[4].name = CORBA::string_dup("Timeout"); event->header.variable_header[4].value <<= (TimeBase::TimeT) 0; event->filterable_data.length(2); event->filterable_data[0].name = CORBA::string_dup("int"); event->filterable_data[0].value <<= ( rnd * 1000 ) ; event->filterable_data[1].name = CORBA::string_dup("string"); event->filterable_data[1].value <<= ( (rnd % 2) ? (const char*)"greater" : (const char*)"smaller" ); event->remainder_of_body <<= (const char*) "remainder_of_body"; CORBA::Long my_long; event->filterable_data[0].value >>= my_long; cout << "Enviando mensage " << my_long; cout << ": " << event->header.fixed_header.event_type.domain_name << ", "; cout << event->header.fixed_header.event_type.type_name << endl; // Envia el evento _consumer->push_structured_event(*event); delete event; event = NULL; } // for cerr << "[supplier2] Desconectando... " << flush << endl; _consumer->disconnect_structured_push_consumer(); } catch(...){ cerr << "[supplier2] Excepcion " << endl; } _supplier_admin->destroy(); cerr << "[supplier2] Terminando" << flush << endl; orb->shutdown(true); orb->destroy(); } catch(CORBA::Exception& exc) { cerr << "[supplier2] Excepcion: " << exc << endl; return 1; } }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); if (parse_args (argc, argv) != 0) return 1; CORBA::Object_var tmp = orb->string_to_object("corbaloc:iiop:1.2@localhost:9931/NameService"); CosNaming::NamingContext_var root = CosNaming::NamingContext::_narrow(tmp.in()); if (CORBA::is_nil (root.in ())) { ACE_ERROR_RETURN ((LM_DEBUG, "Nil NamingService reference\n"), 1); } ACE_DEBUG ((LM_INFO, "**** Narrowed root NamingContext\n")); CosNaming::Name name; name.length(2); name[0].id = CORBA::string_dup("example"); name[1].id = CORBA::string_dup("Hello"); try { tmp = root->resolve (name); ACE_DEBUG ((LM_INFO, "**** Resolved #example/Hello\n")); Test::Hello_var hello = Test::Hello::_narrow(tmp.in ()); if (CORBA::is_nil (hello.in ())) { ACE_ERROR_RETURN ((LM_DEBUG, "Nil Test::Hello reference\n"), 1); } CORBA::String_var the_string = hello->get_string (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) - string returned <%C>\n", the_string.in ())); hello->shutdown (); } catch (const CosNaming::NamingContext::CannotProceed&) { ACE_DEBUG ((LM_DEBUG, "Caught correct exception\n")); } if (shutdown_nsmain) { CORBA::Object_var shutdowntmp = orb->string_to_object(ior); Test::NsShutdown_var shutdown = Test::NsShutdown::_narrow(shutdowntmp.in ()); ACE_DEBUG ((LM_DEBUG, "Shutdown nsmain\n")); shutdown->shutdown (); } orb->shutdown (); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }
void ACSComponentTestClassImpl::shutdown () { ACS_SHORT_LOG((LM_INFO, "acscomponentTestImpl Shutdown")); orb->shutdown(1); }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { PortableServer::POAManager_var poa_manager; CORBA::ORB_var orb = CORBA::ORB_init(argc, argv); CORBA::Object_var poa_obj = orb->resolve_initial_references("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow(poa_obj.in()); poa_manager = root_poa->the_POAManager(); poa_manager->activate(); /*Get event_channel*/ std::cout << "Get event_channel now" << std::endl; CosNotifyChannelAdmin::EventChannel_var ec = get_event_channel(orb.in()); //Attaching a filter to pps CosNotifyFilter::FilterFactory_var dff = ec->default_filter_factory(); ACE_ASSERT(!CORBA::is_nil(dff.in())); std::cout << "Test CosNotifyFilter::Filter::match_structured" << std::endl; //Constructing a test event CosNotification::StructuredEvent event; event.header.fixed_header.event_type.domain_name = CORBA::string_dup("Test_domain"); event.header.fixed_header.event_type.type_name = CORBA::string_dup("Test_type_name"); event.header.variable_header.length(0); event.remainder_of_body <<= ""; std::cout << "Constructing a test event" << std::endl; std::cout << "\t**s header.fixed_header.event_type.domain_name=" << event.header.fixed_header.event_type.domain_name << std::endl; std::cout << "\t**s header.fixed_header.event_type.type_name=" << event.header.fixed_header.event_type.type_name << std::endl; CosNotifyFilter::Filter_var filter = dff->create_filter("EXTENDED_TCL"); update_constraints (filter, "DomainA", "TypeA", "DomainB", "TypeB"); bool expected_result = false; match_structure_test (filter, event, expected_result); update_constraints (filter, "*", "%ALL", "DomainB", "TypeB"); expected_result = true; match_structure_test (filter, event, expected_result); update_constraints (filter, "Test_domain", "%ALL", "DomainB", "TypeB"); expected_result = true; match_structure_test (filter, event, expected_result); update_constraints (filter, "*", "Test_type_name", "DomainB", "TypeB"); expected_result = true; match_structure_test (filter, event, expected_result); update_constraints (filter, "*", "*", "*", "*"); expected_result = true; match_structure_test (filter, event, expected_result); orb->shutdown(); } catch(...) { std::cerr << "Filter: Some exceptions was caught!" << std::endl; exit(1); } return 0; }
void handle_sigint ( int sig ) { #ifdef HAVE_SIGACTION struct sigaction act; /* Assign sig_chld as our SIGINT handler */ act.sa_handler = SIG_IGN; /* We don't want to block any other signals in this example */ sigemptyset(&act.sa_mask); sigaction(SIGINT,&act,0); #else signal(sig, SIG_IGN); #endif std::cout << "\nGot Crtl-C" << std::endl; std::cerr << "..... unbind in NameService" << std::endl; // // build name for name service // CORBA::Object_var obj; CosNaming::NamingContext_var nameService; CosNaming::Name name; name.length(2); name[0].id = CORBA::string_dup("Qedo"); name[0].kind = CORBA::string_dup(""); name[1].id = CORBA::string_dup("HomeFinder"); name[1].kind = CORBA::string_dup(""); // // unbind name in name service // try { // // try to get name service from config values // std::string ns = Qedo::ConfigurationReader::instance()->lookup_config_value( "/General/NameService" ); if( !ns.empty() ) { try { obj = orb->string_to_object( ns.c_str() ); } catch(...) { NORMAL_ERR2( "qassf: can't resolve NameService ", ns ); } NORMAL_OUT2( "qassf: NameService is ", ns ); } // // try to get naming service from orb // else { try { obj = orb->resolve_initial_references( "NameService" ); } catch (const CORBA::ORB::InvalidName&) { NORMAL_ERR( "qassf: can't resolve NameService from ORB" ); } if (CORBA::is_nil(obj.in())) { NORMAL_ERR( "qassf: NameService is a nil object reference" ); } } try { nameService = CosNaming::NamingContext::_narrow( obj.in() ); } catch (const CORBA::Exception&) { NORMAL_ERR( "qassf: NameService is not running" ); } if( CORBA::is_nil(nameService.in()) ) { NORMAL_ERR( "qassf: NameService is not a NamingContext object reference" ); } if (!CORBA::is_nil(nameService.in())) { nameService->unbind(name); } } catch (const CORBA::Exception&) { std::cerr << "..... could not unbind" << std::endl; } catch(...) { std::cerr << "..... error in signal handler" << std::endl; } orb->shutdown(false); }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { // Initialize the ORB first. CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); int result = parse_args (argc, argv); if (result == -1) return -1; // Make sure we have a valid <output_file> output_file = ACE_OS::fopen (output_file_name, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_DEBUG, "Cannot open output file %s\n", output_file_name), -1); else ACE_DEBUG ((LM_DEBUG, "File Opened Successfully\n")); CORBA::Object_var obj = orb->resolve_initial_references ("RootPOA"); // Get the POA_var object from Object_var. PortableServer::POA_var root_poa = PortableServer::POA::_narrow (obj.in ()); PortableServer::POAManager_var mgr = root_poa->the_POAManager (); mgr->activate (); // Initialize the AVStreams components. TAO_AV_CORE::instance ()->init (orb.in (), root_poa.in ()); Server server; result = server.init (argc, argv); if (result != 0) return result; while ( !done ) { if ( orb->work_pending( ) ) { orb->perform_work (); } } orb->shutdown( 1 ); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("server::init"); return -1; } ACE_OS::fclose (output_file); return 0; }
void TestTask::end() { orb_->shutdown(0); this->wait(); }
void TerminationSignalHandler(int) { ACE_OS::printf("Server goes down ... \n"); // ACSError::done(); orb->shutdown (true); }
int main(int argc, char* argv[]){ char aux1[1000]; try{ // // Inicializacion del ORB // CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, ""); CORBA::Object_var obj = orb->resolve_initial_references("RootPOA"); PortableServer::POA_var root_poa = PortableServer::POA::_narrow(obj); PortableServer::POAManager_var manager = root_poa->the_POAManager(); // // Obtain NamincContext reference ... // CORBA::Object_var naming_context_object; CosNaming::NamingContext_ptr naming_context; try { naming_context_object = orb->string_to_object("corbaloc:iiop:[email protected]:2809/NameService"); naming_context = CosNaming::NamingContext::_narrow (naming_context_object.in ()); } catch (...) { cerr << "Error: cannot obtain naming service initial reference" << endl; throw; } // // Crea un POA para el supplier: PERSISTENT LifespanPolicy, USER_ID policy // PortableServer::LifespanPolicy_var lifespan = root_poa->create_lifespan_policy(PortableServer::PERSISTENT); PortableServer::IdAssignmentPolicy_var idAssignment = root_poa->create_id_assignment_policy(PortableServer::USER_ID); CORBA::PolicyList policies(2); policies.length(2); policies[0] = PortableServer::IdAssignmentPolicy::_duplicate(idAssignment); policies[1] = PortableServer::LifespanPolicy::_duplicate(lifespan); PortableServer::POA_var consumer_poa = root_poa->create_POA("consumerPOA", manager.in(), policies); PortableServer::POAManager_var consumer_poa_manager = consumer_poa->the_POAManager(); idAssignment->destroy(); lifespan->destroy(); // Activa el POAManager manager->activate(); // // Crea y activa el servant del consumer // PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId("MyConsumer"); MyConsumerImpl servant_consumer; try{ consumer_poa->activate_object_with_id(oid.in(), &servant_consumer); } catch(...){ cerr << "[supplier] ERROR: activating servant_supplier " << endl; } CORBA::Object_var consumer_obj = consumer_poa->id_to_reference(oid.in()); CosEventComm::PushConsumer_var consumer = CosEventComm::PushConsumer::_narrow(consumer_obj); // // Recoge la referencia al canal // // readChannelIOR(); // obj = orb->string_to_object(ChannelIOR); CosNaming::NamingContext_var naming_context_notif = NULL; CosNaming::Name name_notif(2); name_notif.length (2); name_notif[0].id = CORBA::string_dup ("MyNotif"); name_notif[0].kind = CORBA::string_dup (""); name_notif[1].id = CORBA::string_dup ("channel"); name_notif[1].kind = CORBA::string_dup (""); obj = naming_context->resolve(name_notif); CosNotifyChannelAdmin::EventChannel_var channel; channel = CosNotifyChannelAdmin::EventChannel::_narrow(obj); if (CORBA::is_nil(channel)) { cerr << "[consumer] ERROR: canal nulo " << endl; return -1; } // cerr << "[consumer] ChannelId " << channel->get_channelID() << endl; // // Obtenemos el manager // CosNotifyChannelAdmin::ConsumerAdmin_var consumerAdmin; CosNotifyChannelAdmin::AdminID adminid; try{ consumerAdmin = channel->default_consumer_admin(); } catch(CORBA::Exception &ce){ fprintf(stderr,"(%s)%i CORBA::Exception - %s\n", __FILE__,__LINE__,ce._name()); } catch(...){ fprintf(stderr,"(%s)%i - Unexpected exception!", __FILE__,__LINE__); } // // Obtenemos el proxy // CosNotifyChannelAdmin::ProxyPushSupplier_var pushSupplier; CosNotifyChannelAdmin::ProxyID proxy_id; CosNotifyChannelAdmin::ClientType ctype = CosNotifyChannelAdmin::ANY_EVENT; try{ CosNotifyChannelAdmin::ProxySupplier_var obj = consumerAdmin->obtain_notification_push_supplier(ctype, proxy_id); pushSupplier = CosNotifyChannelAdmin::ProxyPushSupplier::_narrow(obj); // Conecta proxy pushSupplier->connect_any_push_consumer(consumer); } catch(CosEventChannelAdmin::AlreadyConnected &ac){ fprintf(stderr,"(%s)%i CosEventChannelAdmin::AlreadyConnected\n", __FILE__,__LINE__); } catch(CORBA::SystemException& se){ fprintf(stderr,"(%s)%i CORBA::SystemException\n", __FILE__,__LINE__); } catch(CosNotifyChannelAdmin::AdminLimitExceeded err){ fprintf(stderr,"(%s)%i CosNotifyChannelAdmin::AdminLimitExceeded\n", __FILE__,__LINE__); } catch(CORBA::Exception &ce){ fprintf(stderr,"(%s)%i CORBA::Exception - %s\n", __FILE__,__LINE__,ce._name()); } catch(...){ fprintf(stderr,"Unexpected exception!\n"); } // // // // Guarda la referencia en el Servicio de Nombres // // // CosNaming::NamingContext_var naming_context_notif = NULL; // CosNaming::Name name_notif(1); // name_notif.length (1); // name_notif[0].id = CORBA::string_dup ("MyNotif"); // name_notif[0].kind = CORBA::string_dup (""); // naming_context_notif = naming_context->bind_new_context(name_notif); // CosNaming::Name name_consumer(1); // name_consumer.length (1); // name_consumer[0].id = CORBA::string_dup ("consumer"); // name_consumer[0].kind = CORBA::string_dup (""); // naming_context_notif->bind(name_consumer, consumer_obj); cerr << "[consumer] Esperando eventos.... " << endl; orb->run(); cerr << "[consumer] disconnect .... " << endl; // supplier->disconnect_push_supplier(); // consumeradmin->destroy(); cerr << "[consumer] Terminando " << endl; orb->shutdown(true); orb->destroy(); } catch(CORBA::Exception& exc) { cerr << "[consumer] Excepcion: " << exc << endl; return 1; } }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); if (parse_args (argc, argv) != 0) return 1; int done = 0; test_var holder; for(int i = 0; !done; i++) { ACE_TCHAR number[64]; ACE_TString iorfile(ior); ACE_OS::sprintf (number, ACE_TEXT(".%d"), i); iorfile += number; if (ACE_OS::access(iorfile.c_str (), R_OK) == 0) { iorfile = ACE_TEXT("file://") + iorfile; CORBA::Object_var tmp = orb->string_to_object(iorfile.c_str ()); test_var test = test::_narrow(tmp.in ()); if (CORBA::is_nil (test.in ())) { ACE_ERROR_RETURN ((LM_DEBUG, "Nil test reference <%s>\n", ior), 1); } test->send_stuff ("Some stuff to send"); // Test for LFU strategy. The transport to any other // server should be removed before the first one. if (i == 0) { test->send_stuff ("Some stuff to send"); holder = test; } else if (i == 5) // let a few go by before we reuse holder { // This will test the LRU strategy // This transport should be the 6th one // removed. if (!CORBA::is_nil(holder.in ())) { holder->send_stuff ("Some stuff to send"); } } } else { done = 1; } } orb->shutdown (1); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }
int TAO_Notify_Service_Driver::fini (void) { /// Release all the _vars as the ORB about to go away. CosNotifyChannelAdmin::EventChannelFactory_var factory = this->notify_factory_._retn (); CORBA::ORB_var orb = this->orb_._retn (); CORBA::ORB_var dispatching_orb = this->dispatching_orb_._retn (); PortableServer::POA_var poa = this->poa_._retn (); CosNaming::NamingContextExt_var naming = this->naming_._retn (); // This must be called to ensure that all services shut down // correctly. Depending upon the type of service loaded, it may // or may not actually perform any actions. this->notify_service_->finalize_service (factory.in ()); factory = CosNotifyChannelAdmin::EventChannelFactory::_nil (); this->notify_service_->fini (); // Deactivate. if (this->use_name_svc_ && !CORBA::is_nil (naming.in ())) { // Unbind all event channels from the naming service if (this->register_event_channel_) { for (ACE_Unbounded_Set<ACE_CString>::const_iterator ci ( this->notify_channel_name_); !ci.done(); ci++) { CosNaming::Name_var name = naming->to_name ((*ci).c_str ()); naming->unbind (name.in ()); } } // Unbind from the naming service. CosNaming::Name_var name = naming->to_name (this->notify_factory_name_.c_str ()); naming->unbind (name.in ()); naming = CosNaming::NamingContextExt::_nil (); } if (!CORBA::is_nil (poa.in ())) { poa->destroy (true, true); poa = PortableServer::POA::_nil (); } if (this->shutdown_dispatching_orb_ && !CORBA::is_nil (dispatching_orb_.in ())) { dispatching_orb->shutdown (); } // shutdown the ORB. if (this->shutdown_orb_ && !CORBA::is_nil (orb.in ())) { orb->shutdown (); } // Make sure all worker threads are gone. this->worker_.wait (); this->logging_worker_.wait (); // Destroy the ORB if (this->shutdown_dispatching_orb_ && !CORBA::is_nil (dispatching_orb_.in ())) { dispatching_orb->destroy (); } // Destroy the ORB. if (this->shutdown_orb_ && !CORBA::is_nil (orb.in ())) { orb->destroy (); } dispatching_orb_ = CORBA::ORB::_nil (); worker_.orb (CORBA::ORB::_nil ()); orb = CORBA::ORB::_nil (); return 0; }