int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { ACE_TString env (ACE_TEXT ("SSL_CERT_FILE=")); env += cert_file; ACE_OS::putenv ( ACE_TEXT_ALWAYS_CHAR(env.c_str ())); // // Initialize the ORB // CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); if (parse_args (argc, argv) != 0) return 1; // // Get the Root POA. // CORBA::Object_var obj = orb->resolve_initial_references ( "RootPOA" ); PortableServer::POA_var poa = PortableServer::POA::_narrow (obj.in ()); // // Get a reference to the server. // obj = orb->string_to_object ( ior ); if (CORBA::is_nil (obj.in ())) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P) orb->string_to_object ") ACE_TEXT ("(\"file://server.ior\") failed.\n")), -1); } // // Downcast the IOR to the appropriate object type. // server_var server_obj = server::_narrow (obj.in ()); if (CORBA::is_nil (server_obj.in ())) { ACE_ERROR_RETURN ((LM_ERROR, ACE_TEXT ("(%P) server::_narrow(obj) failed.\n")), -1); } // // Create and activate the client. // client_i *servant = 0; ACE_NEW_RETURN (servant, client_i (server_obj.in ()), -1); PortableServer::ServantBase_var theClient = servant; client_var client_ref = servant->_this (); // // Activate the POA manager. // PortableServer::POAManager_var mgr = poa->the_POAManager (); mgr->activate (); // // Set the server's callback and invoke the test request. // server_obj->set_client (client_ref.in ()); server_obj->test_request ("first secure callback to client"); // // Repeat the callback test. // server_obj->set_client (client_ref.in ()); server_obj->test_request ("second secure callback to client"); server_obj->shutdown (); poa->destroy (1, 1); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception (ACE_TEXT ("Caught exception\n")); return -1; } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { int status = 0; bool set_cert_file = true; try { // This has to be done before calling CORBA::ORB_init() and // parse_args() has to be called after CORBA::ORB_init(), so we // will look at argv manually. for(int i = 0; i < argc; i++) { if (ACE_OS::strcmp(argv[i], ACE_TEXT("-n")) == 0) { set_cert_file = false; break; } } ACE_CString env ("SSL_CERT_FILE="); env += cert_file; if (set_cert_file) { ACE_OS::putenv (env.c_str ()); } 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); if (set_cert_file) { // This test sets creates a Security::QOPPolicy with the // Quality-of-Protection set to "no protection." It then // invokes a method on the server (insecurely), which should // then result in a CORBA::NO_PERMISSION exception. // // The server is not shutdown by this test. status = insecure_invocation_test (orb.in (), object.in ()); ACE_DEBUG ((LM_DEBUG, "insecure_invocation_test returned <%d>\n", status)); } // This test uses the default secure SSLIOP settings to securely // invoke a method on the server. No exception should occur. // // The server *is* shutdown by this test. try { status = secure_invocation_test (object.in ()); ACE_DEBUG ((LM_DEBUG, "secure_invocation_test returned <%d>\n", status)); } catch (CORBA::Exception const &ex) { if (set_cert_file) { ex._tao_print_exception ("Caught unexpected exception " "(probable failure):"); status = 1; } else { ACE_DEBUG ((LM_DEBUG, "Caught an exception as expected due " "to the SSL_CERT_FILE environment " "variable not being set.\n")); } } orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception in main:"); return 1; } if (status == 0) { ACE_DEBUG ((LM_DEBUG, "\n" "Bug_1107_Regression test passed.\n")); } 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"); 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); Simple_Server_var server = Simple_Server::_narrow (object.in ()); if (CORBA::is_nil (server.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "Object reference <%s> is nil.\n", ior), 1); } Callback_i callback_impl (orb.in ()); PortableServer::ObjectId_var id = root_poa->activate_object (&callback_impl); CORBA::Object_var object_act = root_poa->id_to_reference (id.in ()); Callback_var callback = Callback::_narrow (object_act.in ()); for (int i = 0; i != niterations; ++i) { CORBA::Long r = server->test_method (0, 0, callback.in ()); if (r != 0) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) unexpected result = %d for %d", r, i)); } } if (do_abort) { try { server->shutdown_now (0); } catch (const CORBA::COMM_FAILURE&) { // Expected exception, continue.... } } else if (do_crash) { try { server->shutdown_now (1); } catch (const CORBA::COMM_FAILURE&) { // Expected exception, continue.... } } else if (do_suicide) { (void) server->test_method (1, 0, callback.in ()); // The shutdown callback could arrive after this twoway invocation // returned. Wait for it shutdown callback and abort, // otherwise it will timeout (in run_test.pl). ACE_OS::sleep (120); } else if (do_self_shutdown) { (void) server->test_method (1, 1, callback.in ()); } if (do_shutdown) { server->shutdown (); } root_poa->destroy (1, 1); } catch (const CORBA::COMM_FAILURE& x) { // For other case this is expected. if (do_self_shutdown == 0) { x._tao_print_exception ("ERROR: Unexpected exception\n"); } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught in client:"); return -1; } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { int status = 0; try { #if TAO_HAS_INTERCEPTORS == 1 PortableInterceptor::ORBInitializer_ptr temp_initializer = PortableInterceptor::ORBInitializer::_nil (); ACE_NEW_RETURN (temp_initializer, Client_ORBInitializer, -1); // No exceptions yet! PortableInterceptor::ORBInitializer_var orb_initializer = temp_initializer; PortableInterceptor::register_orb_initializer (orb_initializer.in ()); #endif /* TAO_HAS_INTERCEPTORS == 1 */ CORBA::ORB_var orb = CORBA::ORB_init (argc, argv, "Client ORB"); if (::parse_args (argc, argv) != 0) return -1; CORBA::Object_var object = orb->string_to_object (ior1); RedirectionTest::test_var server = RedirectionTest::test::_narrow (object.in ()); if (CORBA::is_nil (server.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "Object reference <%s> is nil.\n", ior1), 1); } CORBA::Short number = 0; for (int i = 1; i <= 9; ++i) { ACE_DEBUG ((LM_INFO, "CLIENT: Issuing request %d.\n", i)); number = server->number (); ACE_DEBUG ((LM_INFO, "CLIENT: Request %d handled by object %d.\n", i, number)); } server->shutdown (); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Caught exception:"); return -1; } if (status != -1) ACE_DEBUG ((LM_INFO, "PortableInterceptor::Redirection test passed.\n")); return status; }
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; Worker worker (orb.in ()); if (worker.activate (THR_NEW_LWP | THR_JOINABLE, nthreads) != 0) ACE_ERROR_RETURN ((LM_ERROR, "(%P|%t) Cannot activate worker threads\n"), 1); int timeout = 30; int now = 0; while (now < timeout && ((expect_ex_kind != TAO::FOE_NON && worker.received_ex_kind () != expect_ex_kind && worker.num_received_ex () != expect_num_ex) || expect_ex_kind == TAO::FOE_NON)) { std::cout << "."; now += 1; ACE_Time_Value tv (1, 0); orb->run (tv); } std::cout << std::endl; worker.done (); if (do_shutdown) { CORBA::Object_var object = orb->string_to_object (ior); Simple_Server_var server = Simple_Server::_narrow (object.in ()); server->shutdown (); } ACE_OS::sleep (1); orb->destroy (); worker.thr_mgr ()->wait (); if (worker.received_ex_kind () != expect_ex_kind || worker.num_received_ex () != expect_num_ex) { ACE_ERROR_RETURN ((LM_ERROR, ("(%P|%t)client: test failed - expected is different from received. " "expected %d/%d received %d/%d.\n"), expect_ex_kind, expect_num_ex, worker.received_ex_kind (), worker.num_received_ex()), 1); } ACE_DEBUG ((LM_DEBUG, "(%P|%t)client: test passed.\n")); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught in main:"); return 1; } 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 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 (); 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 ()); // 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 (); CORBA::Object_var tmp = orb->string_to_object(server_ior); Test::Hello_var server = Test::Hello::_narrow(tmp.in ()); if (CORBA::is_nil (server.in ())) { ACE_ERROR_RETURN ((LM_DEBUG, "Nil Test::Hello reference <%s>\n", ior.in ()), 1); } ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Sending client obj ref to the server and requesting a callback.\n")); server->request_callback (hello.in ()); ACE_DEBUG ((LM_DEBUG, "(%P|%t) - Test (client) Succeeded !!!\n")); orb->destroy (); } catch (const CORBA::Exception& ex) { ACE_DEBUG ((LM_ERROR, "(%P|%t) - Test (client) Failed !!!\n")); ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { Fixed_Priority_Scheduler* scheduler=0; RTScheduling::Current_var current; int prio; int max_prio; ACE_Sched_Params::Policy sched_policy = ACE_SCHED_RR; int sched_scope = ACE_SCOPE_THREAD; long flags; if (sched_policy == ACE_SCHED_RR) flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_RR; else flags = THR_NEW_LWP | THR_BOUND | THR_JOINABLE | THR_SCHED_FIFO; ACE_hthread_t main_thr_handle; ACE_Thread::self (main_thr_handle); max_prio = ACE_Sched_Params::priority_max (sched_policy, sched_scope); //FUZZ: disable check_for_lack_ACE_OS ACE_Sched_Params sched_params (sched_policy, max_prio); //FUZZ: enable check_for_lack_ACE_OS ACE_OS::sched_params (sched_params); if (ACE_Thread::getprio (main_thr_handle, prio) == -1) { if (errno == ENOTSUP) { ACE_ERROR((LM_ERROR, ACE_TEXT ("getprio not supported\n") )); } else { ACE_ERROR ((LM_ERROR, ACE_TEXT ("%p\n") ACE_TEXT ("thr_getprio failed"))); } } ACE_DEBUG ((LM_DEBUG, "(%t): main thread prio is %d\n", prio)); try { RTScheduling::Scheduler_var sched_owner; 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); Simple_Server_var server = Simple_Server::_narrow (object.in ()); if (CORBA::is_nil (server.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "Object reference <%s> is nil.\n", ior), 1); } if (enable_dynamic_scheduling) { ACE_DEBUG ((LM_DEBUG, "Dyn Sched enabled\n")); CORBA::Object_var manager_obj = orb->resolve_initial_references ("RTSchedulerManager"); TAO_RTScheduler_Manager_var manager = TAO_RTScheduler_Manager::_narrow (manager_obj.in ()); Kokyu::DSRT_Dispatcher_Impl_t disp_impl_type; if (enable_yield) { disp_impl_type = Kokyu::DSRT_CV_BASED; } else { disp_impl_type = Kokyu::DSRT_OS_BASED; } ACE_NEW_RETURN (scheduler, Fixed_Priority_Scheduler (orb.in (), disp_impl_type, sched_policy, sched_scope), -1); sched_owner = scheduler; manager->rtscheduler (scheduler); CORBA::Object_var object = orb->resolve_initial_references ("RTScheduler_Current"); current = RTScheduling::Current::_narrow (object.in ()); } Worker worker1 (orb.in (), server.in (), current.in (), scheduler, 10, 15); if (worker1.activate (flags, 1, 0, max_prio) != 0) { ACE_ERROR ((LM_ERROR, "(%t|%T) cannot activate worker thread.\n")); } ACE_OS::sleep(2); Worker worker2 (orb.in (), server.in (), current.in (), scheduler, 12, 5); if (worker2.activate (flags, 1, 0, max_prio) != 0) { ACE_ERROR ((LM_ERROR, "(%t|%T) cannot activate scheduler thread in RT mode.\n")); } worker1.wait (); worker2.wait (); ACE_DEBUG ((LM_DEBUG, "(%t): wait for worker threads done in main thread\n")); if (do_shutdown) { if (enable_dynamic_scheduling) { FP_Scheduling::SegmentSchedulingParameter sched_param; sched_param.base_priority = 0; CORBA::Policy_var sched_param_policy = scheduler->create_segment_scheduling_parameter (sched_param); CORBA::Policy_ptr implicit_sched_param = 0; current->begin_scheduling_segment (0, sched_param_policy.in (), implicit_sched_param); } ACE_DEBUG ((LM_DEBUG, "(%t): about to call server shutdown\n")); server->shutdown (); ACE_DEBUG ((LM_DEBUG, "after shutdown call in main thread\n")); if (enable_dynamic_scheduling) { current->end_scheduling_segment (0); } } scheduler->shutdown (); ACE_DEBUG ((LM_DEBUG, "scheduler shutdown done\n")); 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); if (parse_args (argc, argv) == -1) return -1; CORBA::Object_var obj = orb->string_to_object (proxy_ior); if (obj.in () == 0) { ACE_ERROR_RETURN ((LM_ERROR, "The received object is nil\n"), -1); } Simple_Server_var server = Simple_Server::_narrow (obj.in ()); if (CORBA::is_nil (server.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "Object reference is nil\n"), -1); } try { while (true) { // Make a remote call server->remote_call (); ACE_OS::sleep (2); } } catch (CORBA::TRANSIENT& ex) { CORBA::ULong m = ex.minor () & 0x00000F80u; if (m == TAO_INVOCATION_LOCATION_FORWARD_MINOR_CODE && ex.completed () == CORBA::COMPLETED_NO) { ACE_DEBUG ((LM_DEBUG, "TRANSIENT caught in client as it was expected.\n")); } else { ex._tao_print_exception ("Unexpected TRANSIENT caught in client:"); return 2; } } obj = orb->string_to_object (control_ior); if (obj.in () == 0) { ACE_ERROR_RETURN ((LM_ERROR, "The received objref is NULL\n"), -1); } server = Simple_Server::_narrow (obj.in ()); server->shutdown (); orb->destroy (); } catch (const CORBA::Exception & ex) { ex._tao_print_exception ("Exception caught in client:"); return 1; } return 0; }
RtecEventChannelAdmin::EventChannel_ptr get_event_channel(int argc, ACE_TCHAR** argv) { FtRtecEventChannelAdmin::EventChannel_var channel; ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("hi:nt:?")); int opt; int use_gateway = 1; while ((opt = get_opt ()) != EOF) { switch (opt) { case 'i': { CORBA::Object_var obj = orb->string_to_object(get_opt.opt_arg ()); channel = FtRtecEventChannelAdmin::EventChannel::_narrow(obj.in()); } break; case 'n': use_gateway = 0; break; case 't': timer_interval.set(ACE_OS::atof(get_opt.opt_arg ())); case 'h': case '?': ACE_DEBUG((LM_DEBUG, ACE_TEXT("Usage: %s ") ACE_TEXT("-i ftrt_eventchannel_ior\n") ACE_TEXT("-n do not use gateway\n") ACE_TEXT("-t time Time interval in seconds between events (default 1.0)\n") ACE_TEXT("\n"), argv[0])); return 0; } } if (CORBA::is_nil(channel.in())) { /// Find the FTRTEC from the Naming Service CosNaming::Name name(1); name.length(1); name[0].id = CORBA::string_dup("FT_EventService"); CosNaming::NamingContext_var naming_context = resolve_init<CosNaming::NamingContext>(orb.in(), "NameService"); channel = resolve<FtRtecEventChannelAdmin::EventChannel> (naming_context.in (), name); } if (use_gateway) { // use local gateway to communicate with FTRTEC ACE_auto_ptr_reset (gateway, new TAO_FTRTEC::FTEC_Gateway (orb.in (), channel.in ())); return gateway->_this (); } else return channel._retn (); }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { // initialize the ORB _orb = CORBA::ORB_init (argc, argv); // Get the "RootPOA" CORBA::Object_var obj = _orb->resolve_initial_references("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow(obj.in ()); // activate its managers so it can handle incoming requests poa->the_POAManager()->activate(); // get a thread going to handle incoming requests ACE_Thread::spawn(RunFunc); // we could also use the c_orbaloc syntax to get a reference to the // object. This will cause the _orb to talk directly to the other // _orb with no name service or common file involved. obj = _orb->string_to_object("c_orbaloc::localhost:9999/Simple"); if (CORBA::is_nil(obj.in ())) { ACE_ERROR ((LM_ERROR, "could not get reference\n")); return 1; } // narrow the reference to the particular type we wish to deal with Simple_var simple = Simple::_narrow(obj.in ()); if (CORBA::is_nil(simple.in ())) { ACE_ERROR ((LM_ERROR, "could not get reference\n")); return 1; } // create an object reference that has a bogus value for the first // profile obj = _orb->resolve_initial_references("IORManipulation"); TAO_IOP::TAO_IOR_Manipulation_var iorm = TAO_IOP::TAO_IOR_Manipulation::_narrow(obj.in()); // Status: The following scenarios appear to work: // - first profile invalid host name, second profile valid. // - first profile invalid ip number, second profiel valid. // - first profiel invalid port number, second profile valid. // // The following causes a core dump of the server: // - first and second invalid // // Note that he iormanip is being used since it is not practical // to have a test case that depends on a VPN being present. // CORBA::Object_var name1 = _orb->string_to_object ("c_orbaloc:iiop:10.0.2.3:6060/xyz"); CORBA::Object_var name2 = _orb->string_to_object ("c_orbaloc:iiop:daisnot:7070/xyz"); CORBA::String_var name1_ior = _orb->object_to_string(name1.in()); CORBA::String_var name2_ior = _orb->object_to_string(name2.in()); // create a callback object Callee_i * callee_i = new Callee_i; // get the CORBA reference PortableServer::ObjectId_var id = poa->activate_object (callee_i); CORBA::Object_var object_act = poa->id_to_reference (id.in ()); Callee_var callee = Callee::_narrow (object_act.in ()); if (CORBA::is_nil(callee.in ())) { ACE_ERROR ((LM_ERROR, "could not get callback object\n")); return 1; } else { CORBA::String_var str = _orb->object_to_string(callee.in ()); FILE *output_file= ACE_OS::fopen ("ior", "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file for writing IOR: ior\n"), 1); ACE_OS::fprintf (output_file, "%s", str.in ()); ACE_OS::fclose (output_file); } // create a reference with two profiles with the first on being // bogus. If things work as they should the callback should be // succesful with the ORB trying the second profile. TAO_IOP::TAO_IOR_Manipulation::IORList iors (2); iors.length (2); iors [0] = name1; iors [1] = name2; CORBA::Object_var merged = iorm->merge_iors(iors); Callee_var doubleCallee = Callee::_unchecked_narrow(merged.in()); ACE_DEBUG ((LM_DEBUG, "Profile count is %d\n", iorm->get_profile_count(merged.in()))); simple->registerCallee(doubleCallee.in ()); ACE_OS::sleep(120); ACE_DEBUG ((LM_DEBUG, "done sleeping\n")); _orb->shutdown(1); } catch (const ::CORBA::Exception &ex) { ex._tao_print_exception("Caught unexpected CORBA exception :"); } return 0; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { char str [255]; // Initialize the ORB try { ACE_OS::strcpy (str, "CORBA::ORB_init"); CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); // Parse the command-line arguments to get the location of the // IOR if (parse_args (argc, argv) == -1) return -1; if (IOR == 0) { int result = read_IOR_from_file (); if (result != 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot read IOR from %s\n", IOR_file), -1); } ACE_OS::strcpy (str, "CORBA::ORB::string_to_object"); // Get the object reference with the IOR CORBA::Object_var object = orb->string_to_object (IOR); ACE_OS::strcpy (str, "Database::Agent::_narrow"); // Narrow the object reference to a Database::Agent Database::Agent_var database_agent = Database::Agent::_narrow (object.in ()); Database::NVPairSequence employee_attributes (2); employee_attributes.length (2); Database::NamedValue &first = employee_attributes[0]; Database::NamedValue &second = employee_attributes[1]; const char *name = "irfan"; CORBA::Long id = 555; first.name = CORBA::string_dup ("name"); first.value <<= name; second.name = CORBA::string_dup ("id"); second.value <<= id; ACE_OS::strcpy (str, "Database::Agent::create_entry"); // Create an employee Database::Entry_var entry = database_agent->create_entry ("irfan", "Employee", employee_attributes); ACE_OS::strcpy (str, "Database::Employee::_narrow"); Database::Employee_var employee = Database::Employee::_narrow (entry.in ()); /* * * NOT IMPLEMENTED YET * * */ #if 0 // Reset the id ACE_OS::strcpy (str, "Database::Employee::id"); employee->id (666); #endif /* 0 */ ACE_OS::strcpy (str, "Database::Entry::find"); // Find the employee entry = database_agent->find_entry ("irfan", "Employee"); ACE_OS::strcpy (str, "Database::Entry::destroy"); // Destroy the employee database_agent->destroy_entry ("irfan", "Employee"); ACE_OS::strcpy (str, "Shutdown server"); if (shutdown_server) { database_agent->shutdown (); } ACE_OS::free (IOR); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception (str); 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; // Create client callback CORBA object TestCallback *test_impl = 0; ACE_NEW_RETURN (test_impl, TestCallback (orb.in()), 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::TestCallback_var client = Test::TestCallback::_narrow (object.in ()); poa_manager->activate (); // Get server CORBA object and call it CORBA::Object_var tmp = orb->string_to_object(ior); Test::TestServer_var server = Test::TestServer::_narrow(tmp.in ()); if (CORBA::is_nil (server.in ())) { ACE_ERROR_RETURN ((LM_DEBUG, "Nil Test::TestServer reference <%s>\n", ior), 1); } ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - calling server\n")); server->pass_callback (client.in()); ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - call failed to block\n")); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - not stopped by server\n")); return 1; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { // Initialize the ORB, resolve references and parse arguments. // ORB. CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); // Parse arguments. if (parse_args (argc, argv) != 0) return -1; // Test object 1. CORBA::Object_var object = orb->string_to_object (ior1); Test_var server1 = Test::_narrow (object.in ()); if (check_for_nil (server1.in (), "server1") == -1) return -1; // Test object 2. object = orb->string_to_object (ior2); Test_var server2 = Test::_narrow (object.in ()); if (check_for_nil (server2.in (), "server2") == -1) return -1; // Check that test objects are configured with SERVER_DECLARED // PriorityModelPolicy, and get their server priorities. // Test object 1. CORBA::Short server1_priority = check_policy (server1.in ()); if (server1_priority == -1) return -1; // Test object 2. CORBA::Short server2_priority = check_policy (server2.in ()); if (server2_priority == -1) return -1; // Testing: make several invocations on test objects. for (int i = 0; i < 5; ++i) { server1->test_method (server1_priority); server2->test_method (server2_priority); } // Testing over. Shut down Server ORB. server1->shutdown (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ( "Unexpected exception in Server_Declared test client:"); return -1; } 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); UDP_var udp_var = UDP::_narrow (object.in ()); if (CORBA::is_nil (udp_var.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 (); // Instantiate reply handler UDP_i udp_i (orb.in ()); PortableServer::ObjectId_var id = root_poa->activate_object (&udp_i); CORBA::Object_var object_act = root_poa->id_to_reference (id.in ()); UDP_var udpHandler_var = UDP::_narrow (object_act.in ()); // Instantiate client UDP_Client_i *client = new UDP_Client_i (orb.in (), udp_var.in (), udpHandler_var.in (), msec, iterations); // let the client run in a separate thread client->activate (); // ORB loop, will be shut down by our client thread orb->run (); ACE_DEBUG ((LM_DEBUG, "event loop finished\n")); root_poa->destroy (1, // ethernalize objects 0); // wait for completion orb->destroy (); client->wait (); // it is save to delete the client, because the client was actually // the one calling orb->shutdown () triggering the end of the ORB // event loop. delete client; } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Caught exception:"); return 1; } return 0; }
int ACE_TMAIN (int argc, ACE_TCHAR* argv[]) { try { // First initialize the ORB, that will remove some arguments... CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); // There must be at least two arguments, the first is the factory // name, the rest are the names of the stock symbols we want to // get quotes for. if (argc < 3) { cerr << "Usage: " << argv[0] << " Factory_IOR symbol symbol..." << endl; return 1; } CORBA::Object_var poa_object = orb->resolve_initial_references ("RootPOA"); PortableServer::POA_var poa = PortableServer::POA::_narrow (poa_object.in ()); PortableServer::POAManager_var poa_manager = poa->the_POAManager (); poa_manager->activate (); // Use the first argument to create the factory object reference, // in real applications we use the naming service, but let's do // the easy part first! CORBA::Object_var factory_object = orb->string_to_object (argv[1]); // Now downcast the object reference to the appropriate type Quoter::Stock_Factory_var factory = Quoter::Stock_Factory::_narrow (factory_object.in ()); // Create and activate the handler... int response_count = 0; Single_Query_Stock_Handler_i handler_i (&response_count); Quoter::AMI_Single_Query_StockHandler_var handler = handler_i._this (); // Send all the requests, careful with error handling int request_count = 0; for (int i = 2; i != argc; ++i) { try { // Get the stock object Quoter::Stock_var tmp = factory->get_stock (ACE_TEXT_ALWAYS_CHAR (argv[i])); Quoter::Single_Query_Stock_var stock = Quoter::Single_Query_Stock::_narrow (tmp.in ()); if (CORBA::is_nil (stock.in ())) { cerr << "Cannot get single query interface for <" << argv[i] << ">" << endl; } stock->sendc_get_price_and_names (handler.in ()); request_count++; } catch (Quoter::Invalid_Stock_Symbol &) { cerr << "Invalid stock symbol <" << argv[i] << ">" << endl; } } while (response_count < request_count && orb->work_pending ()) { orb->perform_work (); } // Destroy the POA, waiting until the destruction terminates poa->destroy (1, 1); orb->destroy (); } catch (const CORBA::Exception &) { cerr << "CORBA exception raised!" << endl; } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { CORBA::ORB_var orb = CORBA::ORB::_nil(); PortableServer::POA_var root_poa = PortableServer::POA::_nil(); Callback_i *servant = 0; try { 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 (); // Policies for the childPOA to be created. CORBA::PolicyList policies (1); policies.length (1); CORBA::Any pol; pol <<= BiDirPolicy::BOTH; policies[0] = orb->create_policy (BiDirPolicy::BIDIRECTIONAL_POLICY_TYPE, pol); // Create POA as child of RootPOA with the above policies. This POA // will receive request in the same connection in which it sent // the request PortableServer::POA_var child_poa = root_poa->create_POA ("childPOA", poa_manager.in (), policies); // Creation of childPOA is over. Destroy the Policy objects. for (CORBA::ULong i = 0; i < policies.length (); ++i) { policies[i]->destroy (); } poa_manager->activate (); if (parse_args (argc, argv) != 0) return 1; CORBA::Object_var object = orb->string_to_object (ior); Simple_Server_var server = Simple_Server::_narrow (object.in ()); if (CORBA::is_nil (server.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "Object reference <%s> is nil\n", ior), 1); } servant = new Callback_i (orb.in ()); Callback_var callback = servant->_this (); // Send the calback object to the server server->callback_object (callback.in ()); // A method to kickstart callbacks from the server CORBA::Long r = server->test_method (1); if (r != 0) { ACE_DEBUG ((LM_DEBUG, "(%P|%t) unexpected result = %d ", r)); } orb->run (); root_poa->destroy (1, 1); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Caught exception:"); return 1; } if (!CORBA::is_nil(root_poa.in())) root_poa->destroy (1,1); delete servant; 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; // Primary server CORBA::Object_var object_primary = orb->string_to_object (ior); //Secondary server CORBA::Object_var object_secondary = orb->string_to_object (name); // Get an object reference for the ORBs IORManipultion object! CORBA::Object_var IORM = orb->resolve_initial_references (TAO_OBJID_IORMANIPULATION, 0); TAO_IOP::TAO_IOR_Manipulation_var iorm = TAO_IOP::TAO_IOR_Manipulation::_narrow (IORM.in ()); TAO_IOP::TAO_IOR_Manipulation::IORList iors (2); iors.length(2); iors [0] = object_primary; iors [1] = object_secondary; CORBA::Object_var merged = iorm->merge_iors (iors); CORBA::Object_var object = orb->resolve_initial_references ("PolicyCurrent"); CORBA::PolicyCurrent_var policy_current = CORBA::PolicyCurrent::_narrow (object.in ()); CORBA::Any timeout_as_any; timeout_as_any <<= timeout_period; CORBA::PolicyList policy_list (1); policy_list.length (1); policy_list[0] = orb->create_policy (TAO::CONNECTION_TIMEOUT_POLICY_TYPE, timeout_as_any); policy_current->set_policy_overrides (policy_list, CORBA::ADD_OVERRIDE); for (CORBA::ULong l = 0; l != policy_list.length (); ++l) { policy_list[l]->destroy (); } // Combined IOR stuff Simple_Server_var server = Simple_Server::_narrow (merged.in ()); if (CORBA::is_nil (server.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "Object reference <%s> is nil.\n", ior), 1); } CORBA::ULongLong freq = run_test (server.in ()); if (freq != 919263) ACE_ERROR ((LM_ERROR, ACE_TEXT ("(%P|%t) ERROR in the test\n"))); ACE_DEBUG ((LM_DEBUG, ACE_TEXT ("(%P|%t) Shutting server down\n"))); server->shutdown (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Caught an exception\n"); 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; ACE_OS::sched_params (ACE_Sched_Params (ACE_SCHED_FIFO, priority, ACE_SCOPE_PROCESS)); int n = 50000; int insertion = 1; try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); ACE_Get_Opt get_opt (argc, argv, ACE_TEXT("dien:")); int opt; while ((opt = get_opt ()) != EOF) { switch (opt) { case 'd': TAO_debug_level++; break; case 'i': insertion = 1; break; case 'e': insertion = 0; break; case 'n': n = ACE_OS::atoi (get_opt.opt_arg ()); break; case '?': default: ACE_DEBUG ((LM_DEBUG, "Usage: %s " "-d debug" "-n <num> " "\n", argv[0])); return -1; } } CORBA::Boolean result = 0; int j; { CORBA::Object_var obj = orb->string_to_object ("corbaloc:iiop:localhost:1234/Foo/Bar"); Param_Test_var param_test = TAO::Narrow_Utils<Param_Test>::unchecked_narrow (obj.in ()); TAO_Stub *stub = param_test->_stubobj (); stub->type_id = CORBA::string_dup ("IDL:Param_Test:1.0"); ACE_Sample_History history (n); ACE_hrtime_t test_start = ACE_OS::gethrtime (); for (j = 0; j != n; ++j) { CORBA::Any any; if (insertion == 1) { ACE_hrtime_t start = ACE_OS::gethrtime (); any <<= param_test.in (); ACE_hrtime_t now = ACE_OS::gethrtime (); history.sample (now - start); Param_Test_ptr o; result = any >>= o; } else { any <<= param_test.in (); Param_Test_ptr o; ACE_hrtime_t start = ACE_OS::gethrtime (); result = any >>= o; ACE_hrtime_t now = ACE_OS::gethrtime (); history.sample (now - start); } } ACE_hrtime_t test_end = ACE_OS::gethrtime (); if (insertion == 1) { ACE_DEBUG ((LM_DEBUG, "Objref insertion test finished\n")); } else { ACE_DEBUG ((LM_DEBUG, "Objref extraction test finished\n")); } ACE_DEBUG ((LM_DEBUG, "High resolution timer calibration....")); ACE_High_Res_Timer::global_scale_factor_type gsf = ACE_High_Res_Timer::global_scale_factor (); ACE_DEBUG ((LM_DEBUG, "done\n")); ACE_Basic_Stats stats; history.collect_basic_stats (stats); stats.dump_results (ACE_TEXT("Total"), gsf); ACE_Throughput_Stats::dump_throughput (ACE_TEXT("Total"), gsf, test_end - test_start, stats.samples_count ()); }
int main(int argc, char *argv[]) { if (argc<4){ ACE_OS::printf ("usage: testClient <server_name> <depth> <isError> [iteration]\n"); return -1; }//if // create logging proxy LoggingProxy m_logger (0, 0, 31, 0); LoggingProxy::init (&m_logger); CORBA::ORB_var orb; ACS_TEST_INIT_CORBA; // init ACS error system ACSError::init (orb.ptr()); /**************************************/ acserrTest_var test; int depth; sscanf (argv[2], "%d", &depth); bool isErr = *argv[3]-'0'; int iteration=1, i=1; const int size = 20; // max value 1.84 x 10^19 char printBuf[size+1]; if (argc>4) sscanf (argv[4], "%d", &iteration); ACS_DEBUG("main", "****** Test Block *****"); try { ACS_DEBUG("acserrTestClient", "Getting object reference ... "); char fileName[64]; sprintf(fileName, "file://%s.ior", argv[1]); CORBA::Object_var testObj = orb->string_to_object (fileName); ACS_DEBUG("acserrTestClient", "Narrowing it .... "); test = acserrTest::_narrow (testObj.in()); unsigned long long numToPrint; while( iteration >= i ) { ACS_SHORT_LOG((LM_INFO, "Performing test1 (remote call)... (%d/%d)", i, iteration)); ACSErr::ErrorTrace *corbaErrorTrace=0; ErrorTraceHelper *errorTrace=0; // here is also test for converting Completion_var to CompletionImpl CompletionImpl comp; ACSErr::Completion_var tc = test->test (depth, isErr); comp = tc; if (comp.isErrorFree()) { ACS_SHORT_LOG((LM_INFO, "Completion does not contain an error trace")); comp.log(); return 0; } ACS_SHORT_LOG((LM_INFO, "We got Completion that is equal to ACSErrTest0Completion: %d", ACSErrTest0Completion::isEqual(tc))); ACS_SHORT_LOG((LM_INFO, "We got Completion that is NOT equal to ACSErrTest1Completion: %d", ACSErrTest1Completion::isEqual(tc))); errorTrace = comp.getErrorTraceHelper(); ACS_SHORT_LOG((LM_INFO, "Stack depth: %d", errorTrace->getDepth())); comp.log(); ACE_OS::printf( "%s", errorTrace->toString().c_str() ); corbaErrorTrace = &(errorTrace->getErrorTrace()); do { ACS_SHORT_LOG((LM_INFO, "FileName: \"%s\"",errorTrace->getFileName())); ACS_SHORT_LOG((LM_INFO, "LineNumber: \"%d\"",errorTrace->getLineNumber())); ACS_SHORT_LOG((LM_INFO, "Routine: \"%s\"",errorTrace->getRoutine())); ACS_SHORT_LOG((LM_INFO, "HostName: \"%s\"",errorTrace->getHostName())); ACS_SHORT_LOG((LM_INFO, "Process: \"%s\"",errorTrace->getProcessName())); ACS_SHORT_LOG((LM_INFO, "Thread: \"%s\"",errorTrace->getThread())); for (int ii = 0; ii < size; ii++) printBuf[ii] = ' '; printBuf[size] = '\0'; numToPrint = errorTrace->getTimeStamp(); for (int ii = size - 1; ii >= 0; ii--) { printBuf[ii] = numToPrint % 10 + '0'; numToPrint /= 10; if (numToPrint == 0) break; } ACS_SHORT_LOG((LM_INFO, "TimeStamp: \"%s\"",printBuf)); ACS_SHORT_LOG((LM_INFO, "ErrorType: \"%d\"",errorTrace->getErrorType())); ACS_SHORT_LOG((LM_INFO, "ErrorCode: \"%d\"",errorTrace->getErrorCode())); ACS_SHORT_LOG((LM_INFO, "Severity: \"%d\"", errorTrace->getSeverity())); ACS_SHORT_LOG((LM_INFO, "Description: \"%s\"",errorTrace->getDescription())); } while (errorTrace->getNext()!=NULL); i++; } // while iterator >= i } catch( CORBA::Exception &ex ) { ACE_PRINT_EXCEPTION (ex, "EXCEPTION CAUGHT"); return -1; } ACS_SHORT_LOG((LM_INFO, "Test1 performed.")); //test2 i=1; while (i<=iteration) { try { ACS_SHORT_LOG((LM_INFO, "Performing test2 (remote call - exceptions) ... (%d/%d)", i, iteration)); test->testExceptions (depth, isErr); } catch (ACSErr::ACSException &acse) { ACS_SHORT_LOG((LM_INFO, "Catch ACSException !")); ACSError exception (acse); // put CORBA exception (ACSException) into ACSError wrapper exception.log(); } catch (ACSErrTypeTest::ACSErrTest0Ex &_ex) { ACS_SHORT_LOG((LM_INFO, "Catch ACSErrTest0Ex !")); ACSErrTest0ExImpl exorg(_ex); ACE_CString buf = exorg.getMember3(); ACS_SHORT_LOG((LM_INFO, "Members of the caught exception are: %d, %f, %s, %d", exorg.getMember1(), exorg.getMember2(), buf.c_str(), exorg.getMember4())); ACS_SHORT_LOG((LM_INFO, "Caught an exception that is equal to ACSErrTest0ExImpl: %d", ACSErrTest0ExImpl::isEqual(exorg))); ACS_SHORT_LOG((LM_INFO, "Caught an exception that is NOT equal to ACSErrTest1ExImpl: %d", ACSErrTest1ExImpl::isEqual(exorg))); ACSErrTest0ExImpl *ex = new ACSErrTest0ExImpl(_ex, __FILE__, __LINE__, "testClient::main"); ex->log(); // ACSErrTest0Completion c(_ex.errorTrace, __FILE__, __LINE__, "testClient::main-convertion"); // c.log(); delete ex; } catch(CORBA::Exception &__ex) { ACE_PRINT_EXCEPTION (__ex, "EXCEPTION CAUGHT"); return -1; } i++; }//while ACS_SHORT_LOG((LM_INFO, "Test2 performed.")); // test3 (no error) i=1; while (i<=iteration) { try { ACS_SHORT_LOG((LM_INFO, "Performing test3 (no error) ... (%d/%d)", i, iteration)); CompletionImpl comp = test->testNoError (); comp.log(); // test CompletionImpl copy constructor where there is no error CompletionImpl c1(comp); c1.log(); } catch( CORBA::Exception &ex ) { ACE_PRINT_EXCEPTION (ex, "EXCEPTION CAUGHT"); return -1; } i++; }//while ACS_SHORT_LOG((LM_INFO, "Test3 performed.")); // test4 (default error and operator=) try { ACS_SHORT_LOG((LM_INFO, "Performing test4 (default error and operator=)" )); CompletionImpl defaultComp = test->testDefaultError (); defaultComp.log(); CompletionImpl OKComp = test->testNoError (); OKComp.log(); defaultComp = OKComp; defaultComp.log(); } catch( CORBA::Exception &ex ) { ACE_PRINT_EXCEPTION (ex, "EXCEPTION CAUGHT"); return -1; } ACS_SHORT_LOG((LM_INFO, "Test4 performed.")); // test5 ( error completion, assignment and copy constructor) try { ACS_SHORT_LOG((LM_INFO, "Performing test5" )); CompletionImpl comp = test->test(depth, isErr); comp.log(); ACS_SHORT_LOG((LM_INFO, "Performing test5 - copy constructor" )); // test CompletionImpl copy constructor where there is no error CompletionImpl c1(comp); c1.log(); ACS_SHORT_LOG((LM_INFO, "Performing test5 - assignment constructor" )); CompletionImpl OKComp = test->testNoError (); comp = OKComp; comp.log(); comp = c1; comp.log(); } catch( CORBA::Exception &ex ) { ACE_PRINT_EXCEPTION (ex, "EXCEPTION CAUGHT"); return -1; } ACS_SHORT_LOG((LM_INFO, "Test5 performed.")); // test 6 (completion out) try { ACS_SHORT_LOG((LM_INFO, "Performing test6 (completion out)" )); ACSErr::CompletionImpl comp; ACSErr::Completion_var c; // CORBA completion test->testCompletionOut(depth, isErr, c.out()); comp = c; comp.log(); } catch( CORBA::Exception &ex ) { ACE_PRINT_EXCEPTION (ex, "EXCEPTION CAUGHT"); return -1; } ACS_SHORT_LOG((LM_INFO, "Test6 performed (completion out).")); test->shutdown(); ACE_OS::sleep(5); LoggingProxy::done(); 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 (); // 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; CORBA::Object_var tmp = orb->string_to_object(ior); Test::Service_var service = Test::Service::_narrow(tmp.in ()); if (CORBA::is_nil (service.in ())) { ACE_ERROR_RETURN ((LM_DEBUG, "Nil service reference <%s>\n", ior), 1); } Callback *callback_impl; ACE_NEW_RETURN (callback_impl, Callback(orb.in ()), 1); PortableServer::ServantBase_var owner_transfer(callback_impl); PortableServer::ObjectId_var id = root_poa->activate_object (callback_impl); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); Test::Callback_var callback = Test::Callback::_narrow (object.in ()); poa_manager->activate (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - starting test\n")); service->run_test (callback.in ()); ACE_DEBUG ((LM_DEBUG, "(%P|%t) client - running ORB\n")); orb->run (); 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; // 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, "client (%P|%t): user is not superuser, " "test runs in time-shared class\n")); } else ACE_ERROR ((LM_ERROR, "client (%P|%t): sched_params failed\n")); } 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); Test::Roundtrip_var roundtrip = Test::Roundtrip::_narrow (object.in ()); if (CORBA::is_nil (roundtrip.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "Nil Test::Roundtrip reference <%s>\n", ior), 1); } /// Begin the test ACE_DEBUG ((LM_DEBUG, "Starting threads\n")); Client_Task task0 (data_type, sz, roundtrip.in (), niterations); Client_Task task1 (data_type, sz, roundtrip.in (), niterations); Client_Task task2 (data_type, sz, roundtrip.in (), niterations); Client_Task task3 (data_type, sz, roundtrip.in (), niterations); ACE_hrtime_t test_start = ACE_OS::gethrtime (); task0.activate (THR_NEW_LWP | THR_JOINABLE); task1.activate (THR_NEW_LWP | THR_JOINABLE); task2.activate (THR_NEW_LWP | THR_JOINABLE); task3.activate (THR_NEW_LWP | THR_JOINABLE); task0.thr_mgr()->wait (); ACE_hrtime_t test_end = ACE_OS::gethrtime (); ACE_DEBUG ((LM_DEBUG, "Threads finished\n")); ACE_DEBUG ((LM_DEBUG, "High resolution timer calibration....")); ACE_High_Res_Timer::global_scale_factor_type gsf = ACE_High_Res_Timer::global_scale_factor (); ACE_DEBUG ((LM_DEBUG, "done\n")); ACE_Basic_Stats totals; task0.accumulate_and_dump (totals, ACE_TEXT("Task[0]"), gsf); task1.accumulate_and_dump (totals, ACE_TEXT("Task[1]"), gsf); task2.accumulate_and_dump (totals, ACE_TEXT("Task[2]"), gsf); task3.accumulate_and_dump (totals, ACE_TEXT("Task[3]"), gsf); totals.dump_results (ACE_TEXT("Total"), gsf); ACE_Throughput_Stats::dump_throughput (ACE_TEXT("Total"), gsf, test_end - test_start, totals.samples_count ()); if (do_shutdown) { roundtrip->shutdown (); } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { // Used to declare the CORBA::Environment variable try { // Initialize the ORB CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); // Parse the arguments if (parse_args (argc, argv) != 0) return 1; // Convert the ior string to an object reference. // The object reference obtained is a reference to the factory // object. CORBA::Object_var tmp = orb->string_to_object(ior); // Narrow the object reference to the appropriate type Two_Objects_Test::Object_Factory_var factory = Two_Objects_Test::Object_Factory::_narrow(tmp.in ()); if (CORBA::is_nil (factory.in ())) { ACE_ERROR_RETURN ((LM_DEBUG, "Nil Two_Objects_Test::Object_Factory reference <%s>\n", ior), 1); } Two_Objects_Test::First_var first; Two_Objects_Test::Second_var second; // Use the factory object to create the first and second interfaces first = factory->create_first(); second = factory->create_second(); // Call the oneway method first->oneway_method (); ACE_DEBUG ((LM_DEBUG, "Client : one way call done\n")); Two_Objects_Test::Octet_Seq_var reply_seq = second->twoway_method (); ACE_DEBUG ((LM_DEBUG, "Client : length of returned data is %d\n", reply_seq->length() )); second->shutdown (); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }
int main (int argc, char *argv[]) { if (argc != 2) { std::cerr << "Usage:" << std::endl << " " << argv[0] << " IOR" << std::endl << std::endl; return -1; } try { const char* options[][2] = { { "nativeCharCodeSet", "UTF-8" } , { 0, 0 } }; // Initialise the ORB. CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB4", options); // CORBA::ORB_var orb = CORBA::ORB_init(argc, argv, "omniORB4"); // Get a reference to the server from the IOR passed on the // command line CORBA::Object_var obj = orb->string_to_object(argv[1]); swordorb::SWMgr_var mgr = swordorb::SWMgr::_narrow(obj); swordorb::SWModule_ptr module; swordorb::ModInfoList *modInfoList; std::cout << "Connected: " << mgr->testConnection() << "\n"; std::cout << "PrefixPath: " << mgr->getPrefixPath() << "\n"; std::cout << "ConfigPath: " << mgr->getConfigPath() << "\n"; modInfoList = mgr->getModInfoList(); std::cout << "sequence length: " << modInfoList->length() << "\n"; for (int i = 0; i < modInfoList->length(); i++) { std::cout << (*modInfoList)[i].name << ": " << (*modInfoList)[i].category << ": " << (*modInfoList)[i].language << "\n"; /* if (!strncmp((*modInfoList)[i].category, "Bibl", 4)) { module = mgr->getModuleByName((*modInfoList)[i].name); module->setKeyText("jas1:19"); std::cout << module->getRenderText() << "\n"; } std::cout << "\n"; */ } /* swordorb::StringList *localeNames = mgr->getAvailableLocales(); for (int i = 0; i < localeNames->length(); i++) { std::cout << (*localeNames)[i] << "\n"; } */ std::cout << "filterText: " << mgr->filterText("OSISPlain", "this should be <abbr type=\"nomSac\"><hi rend=\"ol\">overlined</hi></abbr>") << "\n"; mgr->setDefaultLocale("de"); mgr->setJavascript(true); mgr->setGlobalOption("Textual Variants", "Secondary Reading"); mgr->setGlobalOption("Footnotes", "On"); module = mgr->getModuleByName("NASB"); /* module->setKeyText("jas.1.19"); swordorb::StringList *attr = module->getEntryAttribute("Footnote", "", "body", true); std::cout << "length: " << attr->length() << "\n"; for (int i = 0; i < attr->length(); i++) { std::cout << (*attr)[i] << "\n"; } */ int i = 0; for (module->setKeyText("gen.2.8"); !module->error() && i < 3; module->next(), i++) { std::cout << "KeyText: " << module->getKeyText() << "\n"; std::cout << "Text: " << module->getRenderText() << "\n"; } std::cout << "RenderHeader:\n" << module->getRenderHeader() << "\n"; /* swordorb::SearchHitList *searchResults; bool lucene = module->hasSearchFramework(); searchResults = module->search("David", (lucene)?swordorb::LUCENE:swordorb::MULTIWORD, 0, ""); for (int i = 0; i < searchResults->length(); i++) { std::cout << (*searchResults)[i].key << "\n"; } mgr->setGlobalOption("Greek Accents", "Off"); std::cout << "\nFiltered text: " << mgr->filterText("Greek Accents", "ὁ θεὸς") << "\n"; */ } catch(const CORBA::Exception& ex) { std::cout << "exception: " << ex._name() << std::endl; } return 0; }
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); 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 ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { CORBA::ORB_var orb; try { PortableInterceptor::ORBInitializer_ptr temp_orb_initializer = PortableInterceptor::ORBInitializer::_nil (); PortableInterceptor::ORBInitializer_var orb_initializer; // Register the ClientRequest_Interceptor ORBInitializer. ACE_NEW_RETURN (temp_orb_initializer, ClientORBInitializer, -1); orb_initializer = temp_orb_initializer; PortableInterceptor::register_orb_initializer (orb_initializer.in ()); orb = CORBA::ORB_init (argc, argv); if (parse_args (argc, argv) != 0) return 1; CORBA::Object_var tmp = orb->string_to_object (ior); Test::Hello_var hello = Test::Hello::_narrow(tmp.in () ); if (CORBA::is_nil (hello.in ())) { ACE_ERROR_RETURN ((LM_DEBUG, "Nil Test::Hello reference <%s>\n", ior), 1); } ACE_DEBUG ((LM_DEBUG, "Client about to make method call that is doomed to failure...\n")); CORBA::String_var the_string = hello->get_string (); ACE_ERROR_RETURN ((LM_DEBUG, "Error - the remote call succeeded which is bloody miraculous given that no server is running !!\n"), 1); orb->destroy (); } catch (const CORBA::Exception&) { orb->destroy (); if (ClientRequest_Interceptor::success_flag_) { ACE_DEBUG ((LM_DEBUG, "Success - the server was unreachable and PI receive_exception was invoked.\n")); return 0; } else { ACE_ERROR_RETURN ((LM_DEBUG, "Error: regression failed - interceptor receive_exception interception point was not invoked !!\n"), 1); } } return 1; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { int retval = 0; try { // Initialise ORB CORBA::ORB_var Orb = CORBA::ORB_init(argc, argv); // Set round-trip timeout const int timeout_secs = 5; CORBA::Object_var obj = Orb->resolve_initial_references ("ORBPolicyManager"); CORBA::PolicyManager_var policy_manager = CORBA::PolicyManager::_narrow (obj.in()); CORBA::PolicyList policy_list; policy_list.length(0); policy_manager->set_policy_overrides(policy_list, CORBA::SET_OVERRIDE); TimeBase::TimeT timeout = timeout_secs * 10000000; CORBA::Any orb_timeout; orb_timeout <<= timeout; policy_list.length(1); policy_list[0] = Orb->create_policy( Messaging::RELATIVE_RT_TIMEOUT_POLICY_TYPE, orb_timeout); policy_manager->set_policy_overrides(policy_list, CORBA::SET_OVERRIDE); // Now try to contact a server. // Use a remote machine that is unreachable on the network. const char * obj_ref = "corbaloc:iiop:[email protected]:4567/NameService"; obj = Orb->string_to_object(obj_ref); CosNaming::NamingContext_var inc; if(!CORBA::is_nil(obj.in ())) { ACE_DEBUG(( LM_INFO, "Attempting to contact %C\n", obj_ref )); try { inc = CosNaming::NamingContext::_narrow(obj.in()); ACE_DEBUG(( LM_INFO, "OK\n" )); } catch(const CORBA::TRANSIENT &) { ACE_ERROR ((LM_ERROR, "Error, caught transient exception\n")); retval = 1; } catch(const CORBA::TIMEOUT &) { ACE_DEBUG ((LM_DEBUG, "Caught correct timeout\n")); } } } catch (const ::CORBA::Exception &ex) { ex._tao_print_exception("ERROR : unexpected CORBA exception caugth :"); ++retval; } return retval; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { DANCE_DISABLE_TRACE (); int retval = 0; Options options; try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); ORB_Destroyer safe_orb (orb); DAnCE::Logger_Service * dlf = ACE_Dynamic_Service<DAnCE::Logger_Service>::instance ("DAnCE_Logger"); if (dlf) { dlf->init (argc, argv); } if (!parse_args (argc, argv, options)) { return 1; } auto_ptr<DAnCE::Plan_Launcher_Base> pl_base (0); Deployment::DeploymentPlan_var dp; DANCE_DEBUG (DANCE_LOG_MAJOR_EVENT, (LM_DEBUG, DLINFO ACE_TEXT ("Plan_Launcher - ") ACE_TEXT ("Parsing deployment plan\n"))); if (options.cdr_plan_) { dp = DAnCE::Convert_Plan::read_cdr_plan (options.cdr_plan_); if (!dp.ptr ()) { if (!options.quiet_) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("PlanLauncher - ") ACE_TEXT ("Error: Unable to read ") ACE_TEXT ("in CDR plan\n"))); } return 1; } } else if (options.xml_plan_) { dp = DAnCE::Convert_Plan::read_xml_plan (options.xml_plan_); if (!dp.ptr ()) { if (!options.quiet_) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("PlanLauncher - Error: ") ACE_TEXT ("Unable to read in XML plan\n"))); } return 1; } } if (options.domain_file_) { ::DAnCE::Config_Handlers::XML_File_Intf file (options.domain_file_); file.add_search_path (ACE_TEXT ("DANCE_ROOT"), ACE_TEXT ("/docs/schema/")); ::Deployment::Domain *plan = file.release_domain (); if (!plan) { DANCE_ERROR (DANCE_LOG_ERROR, (LM_ERROR, DLINFO ACE_TEXT("PlanLauncher - Error - ") ACE_TEXT("Error: Processing file <%C>\n"), options.domain_file_)); return false; } DAnCE_Domain_Validator_i validator (orb); validator.load_domain (*plan); ::DAnCE::Time_Value tv; tv.seconds (options.domain_timeout_); CORBA::StringSeq_var late_nodes; if (!validator.block_for_domain (tv, late_nodes.out ())) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("PlanLauncher - Error: ") ACE_TEXT ("Not all nodes in domain ready\n"))); for (CORBA::ULong i = 0; i < late_nodes->length (); ++i) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("PlanLauncher - Error: ") ACE_TEXT ("Node <%C> is not started\n"), late_nodes[i].in ())); } return 1; } } ACE_Time_Value timeout (ACE_OS::gettimeofday () + ACE_Time_Value (options.em_timeout_)); if (options.em_ior_) { // Resolve ExecutionManager IOR for EM base deployment. DAnCE::EM_Launcher *em_pl (0); Deployment::ExecutionManager_var tmp_em = resolve_manager<Deployment::ExecutionManager> (timeout, options.em_ior_, orb); if (CORBA::is_nil (tmp_em)) { DANCE_ERROR(DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher - ") ACE_TEXT ("Unable to resolve EM object reference\n"))); return 0; } ACE_NEW_THROW_EX (em_pl, DAnCE::EM_Launcher (orb.in (), tmp_em.in ()), CORBA::NO_MEMORY ()); pl_base.reset (em_pl); } else if (options.nm_ior_) { // Resolve NM IOR for NM based deployment. DAnCE::NM_Launcher *nm_pl (0); CORBA::Object_var obj = orb->string_to_object (options.nm_ior_); Deployment::NodeManager_var tmp_em = Deployment::NodeManager::_narrow (obj); if (CORBA::is_nil (tmp_em.in ())) { if (!options.quiet_) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher - ") ACE_TEXT ("Unable to resolve ") ACE_TEXT ("NodeManager reference <%s>\n"), options.nm_ior_)); } return 1; } ACE_NEW_THROW_EX (nm_pl, DAnCE::NM_Launcher (orb.in (), tmp_em.in ()), CORBA::NO_MEMORY ()); pl_base.reset (nm_pl); } else if (options.lm_ior_) { // Resolve NM IOR for NM based deployment. DAnCE::LM_Launcher *lm_pl (0); CORBA::Object_var obj = orb->string_to_object (options.lm_ior_); DAnCE::LocalityManager_var tmp_em = DAnCE::LocalityManager::_narrow (obj); if (CORBA::is_nil (tmp_em.in ())) { if (!options.quiet_) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher - ") ACE_TEXT ("Unable to resolve ") ACE_TEXT ("LocalityManager reference <%s>\n"), options.lm_ior_)); } return 1; } ACE_NEW_THROW_EX (lm_pl, DAnCE::LM_Launcher (orb.in (), tmp_em.in ()), CORBA::NO_MEMORY ()); pl_base.reset (lm_pl); } switch (options.mode_) { case Options::LAUNCH: retval = launch_plan (options, pl_base.get (), dp, orb.in ()); break; case Options::TEARDOWN: retval = teardown_plan (options, pl_base.get (), dp, orb.in ()); break; default: if (!options.quiet_) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher -") ACE_TEXT ("Mode not yet supported\n"))); } break; }; } catch (const Deployment::PlanError &ex) { if (!options.quiet_) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("PlanLauncher - ") ACE_TEXT ("Error in plan: <%C>, <%C>\n"), ex.name.in (), ex.reason.in ())); } retval = -1; } catch (const DAnCE::Deployment_Failure& e) { if (!options.quiet_) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("PlanLauncher - ") ACE_TEXT ("Error: %C.\n"), e.ex_.c_str())); } retval = 1; } catch (const CORBA::Exception& ex) { if (!options.quiet_) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ( "PlanLauncher - ") ACE_TEXT ("Error: %C\n"), ex._info ().c_str ())); } retval = 1; } catch (...) { if (!options.quiet_) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, ACE_TEXT ("PlanLauncher - ") ACE_TEXT ("Error: Unknown exception.\n"))); } retval = 1; } return retval; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { // Initialize orb CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); // Resolve HomeFinder interface CORBA::Object_var obj1 = orb->string_to_object (ior1); CORBA::Object_var obj2 = orb->string_to_object (ior2); CORBA::Object_var obj3 = orb->string_to_object (ior3); CORBA::Object_var obj4 = orb->string_to_object (ior4); if (CORBA::is_nil (obj1.in ()) || CORBA::is_nil (obj2.in ()) || CORBA::is_nil (obj3.in ()) || CORBA::is_nil (obj4.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "Nil Benchmark::RoundtripClient reference\n"), 1); } //Narrow to appropriate interfaces Benchmark::RoundTripClient_var client1= Benchmark::RoundTripClient::_narrow (obj1.in()); Benchmark::RoundTripClient_var client2= Benchmark::RoundTripClient::_narrow (obj1.in()); Benchmark::RoundTripClient_var client3= Benchmark::RoundTripClient::_narrow (obj1.in()); Benchmark::RoundTripClient_var client4= Benchmark::RoundTripClient::_narrow (obj1.in()); //Create Tasks Client_Task task1(client1.in()); Client_Task task2(client2.in()); Client_Task task3(client3.in()); Client_Task task4(client4.in()); task1.activate(THR_NEW_LWP | THR_JOINABLE); task2.activate(THR_NEW_LWP | THR_JOINABLE); task3.activate(THR_NEW_LWP | THR_JOINABLE); task4.activate(THR_NEW_LWP | THR_JOINABLE); task1.thr_mgr()->wait(); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception Caught:"); 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); if (parse_args (argc, argv) != 0) return 1; int len = ACE_OS::strlen(ior) + 1; another_ior = new ACE_TCHAR[len + 1]; ACE_OS::strcpy(another_ior, ior); another_ior[len-1] = '1'; another_ior[len] = '\0'; // Get Object Reference using IOR file CORBA::Object_var object = orb->string_to_object (ior); // Cast to Appropriate Type Simple_Server_var server = Simple_Server::_narrow (object.in ()); if (CORBA::is_nil (server.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "Object reference <%s> is nil\n", ior), 1); } object = orb->string_to_object (another_ior); // Cast to Appropriate Type Another_One_var another = Another_One::_narrow (object.in ()); Client_Worker client (server.in (), another.in (), niterations); if (client.activate (THR_NEW_LWP | THR_JOINABLE, nthreads) != 0) ACE_ERROR_RETURN ((LM_ERROR, " (%P|%t) Cannot Activate Client Threads\n"), 1); client.thr_mgr ()->wait (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) threads finished\n")); // Shut down the server if -x option given in command line if (do_shutdown) { server->shutdown (); } // Destroying the ORB.. orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught:"); return 1; } return 0; }