int main(int argc, char** argv) { if( argc == 1 ) { printf("usage:\n\t%s <server_url>\n", argv[0]); return -1; } try { CORBA::ORB_ptr orb = CORBA::ORB_init(argc, argv); // // destringify the URL (i.e. args[1]) to a programming object // CORBA::Object_var ref = orb->string_to_object(argv[1]); sample::Greeting_var server = sample::Greeting::_narrow(ref.in()); // // invoke the server and get reply. // CORBA::String_var reply = server->hello("hello greeting from Client"); printf("Client received a %s\n", reply.in()); } catch(const CORBA::Exception& e) { printf("Exception: %s\n", e._name()); return -1; } return 0; }
bool test_string_to_object (CORBA::ORB_ptr orb, const char* ior, CORBA::ULong minor) { bool succeed = false; try { // Get the object reference with the IOR CORBA::Object_var object = orb->string_to_object (ior); } catch (const CORBA::BAD_PARAM& ex) { if ((ex.minor() & 0xFFFU) == minor) { succeed = true; } } catch (const CORBA::Exception&) { } if (!succeed) { ACE_ERROR ((LM_ERROR, "(%t) ERROR, test_string_to_object for <%C> didn't result in minor code %d\n", ior, minor)); } return succeed; }
int Client_Task::narrow_servant (CORBA::ORB_ptr orb) { try { CORBA::Object_var object = orb->string_to_object (this->ior_); this->roundtrip_ = Test::Roundtrip::_narrow (object.in ()); if (CORBA::is_nil (this->roundtrip_.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "Nil Test::Roundtrip reference <%s>\n", this->ior_), 0); } } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Exception caught trying to narrow servant\n"); return 0; } return 1; }
static void test_forward_permanent (CORBA::ORB_ptr orb) { CORBA::Object_var obj1 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:1111,iiop:192.168.1.3:1111/NameService"); // the permanent profile CORBA::Object_var obj4 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:4444,iiop:192.168.1.3:4444/NameService"); TAO_Stub *stub1 = obj1->_stubobj (); TAO_Stub *stub4 = obj4->_stubobj (); TAO_Profile *profile = 0; profile = stub1->profile_in_use (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 1111)); // ----- forward to obj2 permanently stub1->add_forward_profiles (stub4->base_profiles(), true /* permanent */ ); FRANKS_ASSERT (stub1->forward_profiles () != 0); profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 4444)); // ----- stringified object reference must be equal to obj4->base_prpfiles(). FRANKS_ASSERT (marshaled_equal_to_other (orb, obj1.in (), &(stub4->base_profiles())) ); // ----- consume second profile of obj2 profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.3", 4444)); // ----- reached end, next_profile() must yield NULL profile = stub1->next_profile (); FRANKS_ASSERT (profile == 0); FRANKS_ASSERT (stub1->forward_profiles () != 0); }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { int status = 0; try { Supplier_Client client; status = client.init (argc, argv); if (status == 0) { CosNotifyChannelAdmin::EventChannel_var ec = client.create_event_channel ("MyEventChannel", 1); CORBA::ORB_ptr orb = client.orb (); CORBA::Object_var object = orb->string_to_object (ior); MonitorTestInterface_var sig = MonitorTestInterface::_narrow (object.in ()); if (CORBA::is_nil (sig.in ())) ACE_ERROR_RETURN ((LM_ERROR, "Error: Structured Supplier: Narrow to MonitorTestInterface failed.\n"),1); CosNotifyChannelAdmin::SupplierAdmin_var admin = create_supplieradmin (ec.in ()); if (!CORBA::is_nil (admin.in ())) { create_suppliers (admin.in (), client.root_poa ()); sig->running (MonitorTestInterface::Supplier); ACE_DEBUG ((LM_DEBUG, "1 supplier sending %d events...\n", max_events)); for (int i = 0; i < max_events; ++i) { ACE_DEBUG ((LM_DEBUG, "+")); SendEvent (i); } ACE_DEBUG ((LM_DEBUG, "\nSupplier sent %d events.\n", max_events)); sig->finished (MonitorTestInterface::Supplier); supplier_1->disconnect (); } } } catch (const CORBA::Exception& e) { e._tao_print_exception ("Supplier Error: "); status = 1; } return status; }
Test::Hello_var create_policies (CORBA::ORB_ptr orb, bool add_zlib_compressor) { CORBA::PolicyList policies(4); policies.length(4); policies[0] = create_compressor_id_level_list_policy (orb, add_zlib_compressor); policies[1] = create_low_value_policy (orb); policies[2] = create_compression_enabled_policy (orb); policies[3] = create_min_ratio_policy (orb); CORBA::Object_var tmp = orb->string_to_object(ior); CORBA::Object_var tmp2 = tmp->_set_policy_overrides (policies, CORBA::ADD_OVERRIDE); Test::Hello_var hello = Test::Hello::_narrow(tmp2.in ()); return hello._retn (); }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { int status = 0; try { Consumer_Client client; status = client.init (argc, argv); ACE_UNUSED_ARG(status); ACE_ASSERT(status == 0); CosNotifyChannelAdmin::EventChannel_var ec = client.create_event_channel ("MyEventChannel", 1); CORBA::ORB_ptr orb = client.orb (); CORBA::Object_var object = orb->string_to_object (ior); sig_var sig = sig::_narrow (object.in ()); ACE_ASSERT(! CORBA::is_nil (sig.in ())); CosNotifyChannelAdmin::ConsumerAdmin_var admin = create_consumeradmin (ec.in ()); ACE_ASSERT(!CORBA::is_nil (admin.in ())); create_consumers (admin.in (), &client); // Tell the supplier to go sig->go (); ACE_DEBUG((LM_DEBUG, "Consumer waiting for events...\n")); client.ORB_run( ); ACE_DEBUG((LM_DEBUG, "Consumer done.\n")); consumer_1->disconnect(); sig->done (); } catch (const CORBA::Exception& e) { e._tao_print_exception ("Error: "); status = 1; } return status; }
Test::Hello_var prepare_tests (CORBA::ORB_ptr orb, bool create_factories=true) { #if defined TAO_HAS_ZIOP && TAO_HAS_ZIOP == 1 if (create_factories) { register_factories(orb); } return create_policies (orb, !create_factories); #else ACE_UNUSED_ARG (create_factories); CORBA::Object_var tmp = orb->string_to_object(ior); Test::Hello_var hello = Test::Hello::_narrow(tmp.in ()); return hello._retn (); #endif }
Smart_Messenger_Proxy_Factory::Smart_Messenger_Proxy_Factory( CORBA::ORB_ptr orb) { std::cout << "Creating smart proxy factory" << std::endl; // Convert the contents of the Logger.ior file to an object reference. CORBA::Object_var obj = orb->string_to_object("file://Logger.ior"); if (CORBA::is_nil(obj.in())) { std::cerr << "Nil Logger reference" << std::endl; throw 0; } // Narrow the object reference to a Logger object reference. logger_ = Logger::_narrow(obj.in()); if (CORBA::is_nil(logger_.in ())) { std::cerr << "Not a Logger object reference" << std::endl; throw 0; } }
int ACE_TMAIN (int argc, ACE_TCHAR* argv[]) { int status = 0; try { Consumer_Client client; status = client.init (argc, argv); if (status != 0) ACE_ERROR_RETURN ((LM_ERROR, "Error: Client init failed.\n"),1); CosNotifyChannelAdmin::EventChannel_var ec = client.create_event_channel ("MyEventChannel", 1); CORBA::ORB_ptr orb = client.orb (); CORBA::Object_var object = orb->string_to_object (ior); sig_var sig = sig::_narrow (object.in ()); CosNotifyChannelAdmin::ConsumerAdmin_var admin = create_consumeradmin (ec.in ()); if (CORBA::is_nil (admin.in ())) ACE_ERROR_RETURN ((LM_ERROR, "Error: nil ConsumerAdmin.\n"),1); create_consumers (admin.in (), &client); ACE_DEBUG ((LM_DEBUG, "\nConsumer waiting for events...\n")); sig->go (); ACE_Time_Value tv (5); orb->run (tv); ACE_DEBUG ((LM_DEBUG, "Consumer done.\n")); } catch (const CORBA::Exception& e) { e._tao_print_exception ("Consumer Error: "); status = 1; } return status; }
static CORBA::Object_ptr get_distributor_reference (CORBA::ORB_ptr orb) { if (use_naming) { CORBA::Object_var tmp = orb->resolve_initial_references ("NameService"); CosNaming::NamingContext_var pns = CosNaming::NamingContext::_narrow (tmp.in ()); CosNaming::Name name (1); name.length (1); name[0].id = distributor_name.c_str (); return pns->resolve (name); } else // Read and destringify the Stock_Distributor object's IOR. return orb->string_to_object (ior.c_str ()); }
static void run (CORBA::ORB_ptr orb, ACE_TCHAR *IOR) { if (IOR != 0) { // Get an object reference from the argument string. CORBA::Object_var object = orb->string_to_object (IOR); // Try to narrow the object reference to a reference. T_var test = T::_narrow (object.in ()); ACE_Profile_Timer timer; ACE_Profile_Timer::ACE_Elapsed_Time elapsed_time; // We start an ACE_Profile_Timer here... timer.start (); CORBA::Long result = 0; int i = 0; for (i = 0; i < iterations ; i++) { // Invoke the doit() method on the reference. result = test->doit (); } // stop the timer. timer.stop (); timer.elapsed_time (elapsed_time); // compute average time. print_stats (elapsed_time, i); // Print the result of doit () method on the reference. ACE_DEBUG ((LM_DEBUG, "%d\n", result)); } }
static bool marshaled_equal_to_other (CORBA::ORB_ptr orb, CORBA::Object_ptr obj, TAO_MProfile *other_mprofile) { CORBA::String_var str = orb->object_to_string (obj); CORBA::Object_var obj_copy = orb->string_to_object (str.in ()); TAO_Stub *stub_copy = obj_copy->_stubobj (); TAO_MProfile *copy_mprofile = &(stub_copy->base_profiles ()); if ( copy_mprofile->size() != other_mprofile->size()) return false; for (size_t i=0; i<copy_mprofile->size(); ++i) { TAO_Profile *copy_profile = copy_mprofile->get_profile (i); TAO_Profile *other_profile = other_mprofile->get_profile (i); if ( ! equal_endpoint (copy_profile, other_profile) ) return false; } return true; }
void test_impl( CORBA::ORB_ptr orb, ACE_TCHAR const * ior, bool shutdown) { CORBA::Object_var object = orb->string_to_object(ior); Test_var test = Test::_narrow(object.in()); if(CORBA::is_nil(test.in())) { throw "Nil reference after narrow"; } for(int i = 0; i != niterations; ++i) { test->sendc_the_operation(AMI_TestHandler::_nil()); } ACE_Time_Value wait_for_responses_interval(1, 0); orb->run(wait_for_responses_interval); if (shutdown) test->shutdown (); }
CORBA::Object_ptr TAO_FILE_Parser::parse_string (const char *ior, CORBA::ORB_ptr orb) { // Skip the prefix, we know it is there because this method in only // called if <match_prefix> returns 1. const char *filename = ior + sizeof (::file_prefix)+1; FILE* file = ACE_OS::fopen (ACE_TEXT_CHAR_TO_TCHAR (filename), ACE_TEXT("r")); if (file == 0) return CORBA::Object::_nil (); ACE_Read_Buffer reader (file, true); char* string = reader.read (); if (string == 0) return CORBA::Object::_nil (); CORBA::Object_ptr object = CORBA::Object::_nil (); try { object = orb->string_to_object (string); reader.alloc ()->free (string); } catch (const ::CORBA::Exception&) { reader.alloc ()->free (string); throw; } return object; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { Consumer_Client client; int status = client.init (argc, argv); ACE_ASSERT(status == 0); ACE_UNUSED_ARG(status); CosNotifyChannelAdmin::EventChannel_var ec = client.create_event_channel ("MyEventChannel", 1); CORBA::ORB_ptr orb = client.orb (); CORBA::Object_var object = orb->string_to_object (ior); sig_var sig = sig::_narrow (object.in ()); ACE_ASSERT(! CORBA::is_nil (sig.in ())); CosNotifyChannelAdmin::ConsumerAdmin_var admin = create_consumeradmin (ec.in ()); if (filter) { CosNotifyFilter::FilterFactory_var ffact = ec->default_filter_factory (); CosNotifyFilter::Filter_var filter = ffact->create_filter ("TCL"); ACE_ASSERT(! CORBA::is_nil(filter.in())); CosNotifyFilter::ConstraintExpSeq constraint_list (1); constraint_list.length(1); constraint_list[0].event_types.length (0); constraint_list[0].constraint_expr = CORBA::string_dup(ACE_TEXT_ALWAYS_CHAR (constraintString)); filter->add_constraints (constraint_list); admin->add_filter(filter.in()); } ACE_ASSERT (!CORBA::is_nil (admin.in ())); create_consumers(admin.in (), &client); // Tell the supplier to go sig->go (); client.ORB_run( ); ACE_DEBUG((LM_DEBUG, "Consumer done.\n")); sig->done (); return 0; } catch (const CORBA::Exception& e) { e._tao_print_exception ("Error: Consumer exception: "); } return 1; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { int status = 0; try { Consumer_Client client; status = client.init (argc, argv); if (status != 0) { ACE_ERROR_RETURN ((LM_ERROR, "Error: Client init failed.\n"), 1); } CosNotifyChannelAdmin::EventChannel_var ec = client.create_event_channel ("MyEventChannel", 0); #ifdef TEST_QOS_MAX_QUEUE_LENGTH ACE_OS::printf ("%s: setting max queue length to 1000\n", argv[0]); CosNotification::AdminProperties properties(1); properties.length(1); properties[0].name = CORBA::string_dup (CosNotification::MaxQueueLength); properties[0].value <<= 1000; ec->set_admin(properties); #endif //TEST_QOS_MAX_QUEUE_LENGTH CORBA::ORB_ptr orb = client.orb (); CORBA::Object_var object = orb->string_to_object (ior); MonitorTestInterface_var sig = MonitorTestInterface::_narrow (object.in ()); if (CORBA::is_nil (sig.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "Error: Narrow failed.\n"), 1); } CosNotifyChannelAdmin::ConsumerAdmin_var admin = create_consumeradmin (ec.in ()); if (CORBA::is_nil (admin.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "Error: nil ConsumerAdmin.\n"), 1); } create_consumers (admin.in (), &client); sig->running (MonitorTestInterface::Consumer); ACE_DEBUG ((LM_DEBUG, "\nConsumer waiting for events...\n")); FILE* ready_file = ACE_OS::fopen (ACE_TEXT_ALWAYS_CHAR(ready_output_file), "w"); if (ready_file == 0) { ACE_ERROR_RETURN ((LM_ERROR, "Cannot open ready file for writing\n"), 1); } ACE_OS::fprintf (ready_file, "ready\n"); ACE_OS::fclose (ready_file); client.ORB_run (); #ifdef PAUSE_ON_EXIT _cputs( "All events received. Still connected.\n"); _cputs( "Hit a key to exit consumer: " ); _getch(); #endif // PAUSE_ON_EXIT ACE_DEBUG ((LM_DEBUG, "Consumer done.\n")); consumer_1->disconnect (); ec->destroy (); sig->finished (MonitorTestInterface::Consumer); } catch (const CORBA::Exception& e) { e._tao_print_exception ("Consumer Error: "); status = 1; } return status; }
int teardown_plan (const Options &opts, DAnCE::Plan_Launcher_Base *pl_base, const ::Deployment::DeploymentPlan *plan, CORBA::ORB_ptr orb) { DANCE_TRACE ("teardown_plan"); int rc = 0; try { CORBA::Object_var am; CORBA::Object_var app; if (opts.am_ior_ && opts.app_ior_) { DANCE_DEBUG (DANCE_LOG_MAJOR_EVENT, (LM_DEBUG, DLINFO ACE_TEXT ("Plan_Launcher::teardown_plan - ") ACE_TEXT ("Tearing down plan with explicitly ") ACE_TEXT ("nominated App and AM IORs.\n"))); am = orb->string_to_object (opts.am_ior_); app = orb->string_to_object (opts.app_ior_); } else { // Need to perform lookup by uuid, // either explicitly provided or in plan. ACE_CString uuid; if (plan) uuid = plan->UUID.in (); else uuid = ACE_TEXT_ALWAYS_CHAR (opts.uuid_); DAnCE::EM_Launcher *em_launcher = dynamic_cast <DAnCE::EM_Launcher *> (pl_base); if (!em_launcher) { DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher::teardown_plan - ") ACE_TEXT ("Error: Attempting UUID lookup on non") ACE_TEXT ("-EM managed plan not supported\n"))); return 1; } if (em_launcher->lookup_by_uuid (uuid.c_str (), am.out (), app.out ())) { DANCE_DEBUG (DANCE_LOG_MAJOR_EVENT, (LM_DEBUG, DLINFO ACE_TEXT ("Plan_Launcher::teardown_plan - ") ACE_TEXT ("Tearing down plan with UUID %C\n"), uuid.c_str ())); } else { DANCE_ERROR (DANCE_LOG_TERMINAL_ERROR, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher::teardown_plan - ") ACE_TEXT ("Error: Lookup by UUID failed\n"))); return 1; } } try { pl_base->teardown_application (am, app); } catch (const DAnCE::Deployment_Failure &ex) { if (!opts.quiet_) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher::teardown_plan - ") ACE_TEXT ("Application Teardown failed, exception: %C\n"), ex.ex_.c_str ())); } rc = 1; } catch (const CORBA::Exception &ex) { if (!opts.quiet_) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher::teardown_plan - ") ACE_TEXT ("Application Teardown failed, ") ACE_TEXT ("caught CORBA exception %C\n"), ex._info ().c_str ())); } rc = 1; } catch (...) { if (!opts.quiet_) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher::teardown_plan - ") ACE_TEXT ("Application Teardown failed, ") ACE_TEXT ("caught unknown C++ exception\n"))); } rc = 1; } if (rc == 0 || opts.force_) pl_base->destroy_app_manager (am); } catch (const DAnCE::Deployment_Failure &ex) { if (!opts.quiet_) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher::teardown_plan - ") ACE_TEXT ("Teardown failed, exception: %C\n"), ex.ex_.c_str ())); } return 1; } catch (const CORBA::Exception &ex) { if (!opts.quiet_) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher::teardown_plan - ") ACE_TEXT ("Teardown failed, caught CORBA exception %C\n"), ex._info ().c_str ())); } return 1; } catch (...) { if (!opts.quiet_) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher::teardown_plan - ") ACE_TEXT ("Teardown failed, ") ACE_TEXT ("caught unknown C++ exception\n"))); } return 1; } return rc; }
typename Manager::_ptr_type resolve_manager (ACE_Time_Value timeout, const ACE_TCHAR * ior, CORBA::ORB_ptr orb) { ACE_Time_Value retry (0, 1000000 / 4); CORBA::Object_var obj; typename Manager::_var_type tmp_em; ACE_CString last_error; do { try { obj = orb->string_to_object (ior); if (CORBA::is_nil (obj)) { ACE_OS::sleep (retry); } else break; } catch (CORBA::Exception &ex) { DANCE_ERROR (DANCE_LOG_WARNING, (LM_ERROR, DLINFO, ACE_TEXT ("Plan_Launcher - ") ACE_TEXT ("Caught CORBA Exception while resolving Manager object reference: %C\n"), ex._info ().c_str ())); last_error = ex._info (); } } while (ACE_OS::gettimeofday () < timeout); tmp_em = Manager::_narrow (obj); if (CORBA::is_nil (tmp_em.in ())) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("Plan_Launcher - ") ACE_TEXT ("Unable to resolve ") ACE_TEXT ("Manager reference <%s>, %C\n"), ior, last_error.c_str ())); return 0; } bool non_existant (false); do { try { non_existant = tmp_em->_non_existent (); if (!non_existant) break; ACE_OS::sleep (retry); } catch (CORBA::Exception &ex) { DANCE_ERROR (DANCE_LOG_WARNING, (LM_ERROR, DLINFO, ACE_TEXT ("Plan_Launcher - ") ACE_TEXT ("Caught CORBA Exception while resolving Manager object reference: %C\n"), ex._info ().c_str ())); last_error = ex._info (); } } while (ACE_OS::gettimeofday () < timeout); if (non_existant) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_EMERGENCY, DLINFO, ACE_TEXT ("Plan_Launcher - ") ACE_TEXT ("Unable to validate connection to Manager: %C\n"), last_error.c_str ())); return 0; } return tmp_em._retn (); }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { int status = 0; try { Consumer_Client client; status = client.init (argc, argv); if (status == 0) { CosNotifyChannelAdmin::EventChannel_var ec = client.create_event_channel ("MyEventChannel", 1); CORBA::ORB_ptr orb = client.orb (); CORBA::Object_var object = orb->string_to_object (ior); sig_var sig = sig::_narrow (object.in ()); if (CORBA::is_nil (sig.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "Object reference <%s> is nil\n", ior), 1); } CosNotifyChannelAdmin::ConsumerAdmin_var admin = ec->default_consumer_admin(); CosNotifyFilter::Filter_var filter = create_proxyFilter (ec.in()); if (!CORBA::is_nil (admin.in ())) { create_consumers (admin.in (), &client, filter.in()); // Tell the supplier to go sig->go (); ACE_Time_Value tv(10, 0); client.ORB_run(tv); ACE_DEBUG((LM_DEBUG, "Consumer done.\n")); sig->done (); ACE_DEBUG((LM_DEBUG, "Expected %d message(s) and received %d message(s).\n", expect_fail == 1 ? 0 : 1, consumer_1->messages_received())); if (1 == expect_fail) status = consumer_1->messages_received() == 0 ? 0 : 1; else status = consumer_1->messages_received() == 1 ? 0 : 1; ACE_DEBUG((LM_DEBUG, "Test status is %s.\n", status == 1 ? "fail" : "pass")); } } } catch (const CORBA::Exception& e) { e._tao_print_exception ("Error: Consumer exception: "); status = 1; } return status; }
bool NameServiceBase::initNameService(CORBA::ORB_ptr orb) { // // try to get naming service from config values // CORBA::Object_var obj; 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( "NameServiceBase: can't resolve NameService ", ns ); return false; } if (CORBA::is_nil(obj.in())) { NORMAL_ERR( "NameServiceBase: NameService is a nil object reference" ); return false; } NORMAL_OUT2( "NameServiceBase: 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( "NameServiceBase: can't resolve NameService" ); return false; } if (CORBA::is_nil(obj.in())) { NORMAL_ERR( "NameServiceBase: NameService is a nil object reference" ); return false; } } try { nameService_ = CosNaming::NamingContext::_narrow( obj.in() ); } catch (const CORBA::Exception&) { NORMAL_ERR( "NameServiceBase: NameService is not running" ); return false; } if( CORBA::is_nil(nameService_.in()) ) { NORMAL_ERR( "NameService is not a NamingContext object reference" ); return false; } return true; }
static void test_forward_permanent_mix (CORBA::ORB_ptr orb) { CORBA::Object_var obj1 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:1111,iiop:192.168.1.3:1111/NameService"); CORBA::Object_var obj2 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:2222,iiop:192.168.1.3:2222/NameService"); CORBA::Object_var obj3 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:3333,iiop:192.168.1.3:3333/NameService"); CORBA::Object_var obj4 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:4444,iiop:192.168.1.3:4444/NameService"); CORBA::Object_var obj5 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:5555,iiop:192.168.1.3:5555/NameService"); TAO_Stub *stub1 = obj1->_stubobj (); TAO_Stub *stub2 = obj2->_stubobj (); TAO_Stub *stub3 = obj3->_stubobj (); TAO_Stub *stub4 = obj4->_stubobj (); TAO_Stub *stub5 = obj5->_stubobj (); TAO_Profile *profile = 0; profile = stub1->profile_in_use (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 1111)); // ----- forward to obj2 stub1->add_forward_profiles (stub2->base_profiles(), false /* permanent */ ); FRANKS_ASSERT (stub1->forward_profiles () != 0); profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 2222)); // ----- forward to obj3 stub1->add_forward_profiles (stub3->base_profiles(), false /* permanent */ ); FRANKS_ASSERT (stub1->forward_profiles () != 0); profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 3333)); // ----- stringified object reference must be equal to obj1->base_prpfiles(). FRANKS_ASSERT (marshaled_equal_to_other (orb, obj1.in (), &(stub1->base_profiles())) ); // ----- forward to obj4 permanently stub1->add_forward_profiles (stub4->base_profiles(), true /* permanent */ ); FRANKS_ASSERT (stub1->forward_profiles () != 0); profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 4444)); // ----- stringified object reference must be equal to obj4->base_prpfiles(). FRANKS_ASSERT (marshaled_equal_to_other (orb, obj1.in (), &(stub4->base_profiles())) ); // ----- consume second profile from obj4 profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.3", 4444)); // ----- forward to obj2 stub1->add_forward_profiles (stub2->base_profiles(), false /* permanent */ ); FRANKS_ASSERT (stub1->forward_profiles () != 0); profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 2222)); // ----- forward to obj3 stub1->add_forward_profiles (stub3->base_profiles(), false /* permanent */ ); FRANKS_ASSERT (stub1->forward_profiles () != 0); profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 3333)); // ----- stringified object reference must be equal to obj4->base_prpfiles(). FRANKS_ASSERT (marshaled_equal_to_other (orb, obj1.in (), &(stub4->base_profiles())) ); // ----- forward to obj5 permanently stub1->add_forward_profiles (stub5->base_profiles(), true /* permanent */ ); FRANKS_ASSERT (stub1->forward_profiles () != 0); profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 5555)); // ----- stringified object reference must be equal to obj5->base_prpfiles(). FRANKS_ASSERT (marshaled_equal_to_other (orb, obj1.in (), &(stub5->base_profiles())) ); // ----- consume second profile from obj5 profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.3", 5555)); // ----- stringified object reference must be equal to obj1->base_prpfiles(). FRANKS_ASSERT (marshaled_equal_to_other (orb, obj1.in (), &(stub5->base_profiles())) ); // reached end of profiles, next_profile must return NULL profile = stub1->next_profile (); FRANKS_ASSERT (profile == 0); }
static void test_forward (CORBA::ORB_ptr orb) { CORBA::Object_var obj1 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:1111,iiop:192.168.1.3:1111/NameService"); CORBA::Object_var obj2 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:2222,iiop:192.168.1.3:2222/NameService"); CORBA::Object_var obj3 = orb->string_to_object ("corbaloc:iiop:192.168.1.2:3333,iiop:192.168.1.3:3333/NameService"); TAO_Stub *stub1 = obj1->_stubobj (); TAO_Stub *stub2 = obj2->_stubobj (); TAO_Stub *stub3 = obj3->_stubobj (); TAO_Profile *profile = 0; profile = stub1->profile_in_use (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 1111)); // ----- forward to obj2 stub1->add_forward_profiles (stub2->base_profiles(), false /* permanent */ ); FRANKS_ASSERT (stub1->forward_profiles () != 0); profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 2222)); // ----- forward to obj3 stub1->add_forward_profiles (stub3->base_profiles(), false /* permanent */ ); FRANKS_ASSERT (stub1->forward_profiles () != 0); profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.2", 3333)); // ----- stringified object reference must be equal to obj1->base_prpfiles(). FRANKS_ASSERT (marshaled_equal_to_other (orb, obj1.in (), &(stub1->base_profiles())) ); // ----- consume second profile of obj3 profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.3", 3333)); // ----- consume second profile of obj2 profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.3", 2222)); // ----- consume second profile of obj1 profile = stub1->next_profile (); FRANKS_ASSERT (is_endpoint (profile, "192.168.1.3", 1111)); FRANKS_ASSERT (stub1->forward_profiles () == 0); // ----- reached end, next_profile() must yield NULL profile = stub1->next_profile (); }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { try { Consumer_Client client; int status = client.init (argc, argv); if (status != 0) { ACE_ERROR((LM_ERROR, "Error: Unable to init consumer.\n")); return 1; } CosNotifyChannelAdmin::EventChannel_var ec = client.create_event_channel ("Struct_Multi_Filter", 1); CosNotifyChannelAdmin::AdminID adminid = 0; CosNotifyChannelAdmin::ConsumerAdmin_var consumer_admin = ec->new_for_consumers ((consumerFilter == OrOp ? CosNotifyChannelAdmin::OR_OP : CosNotifyChannelAdmin::AND_OP), adminid); ACE_ASSERT(! CORBA::is_nil (consumer_admin.in ())); if (consumerFilter != None) { CosNotifyFilter::FilterFactory_var ffact = ec->default_filter_factory (); CosNotifyFilter::Filter_var filter = ffact->create_filter (GRAMMAR); if (CORBA::is_nil (filter.in ())) { ACE_ERROR ((LM_ERROR, " (%P|%t) Consumer unable to initialize filter.\n")); return 1; } CosNotifyFilter::ConstraintExpSeq constraint_list (1); constraint_list.length (1); constraint_list[0].event_types.length (0); constraint_list[0].constraint_expr = CORBA::string_dup ("type != 1"); filter->add_constraints (constraint_list); consumer_admin->add_filter (filter.in ()); } CORBA::ORB_ptr orb = client.orb (); CORBA::Object_var object = orb->string_to_object (ior); sig_var sig = sig::_narrow (object.in ()); ACE_ASSERT(! CORBA::is_nil (sig.in ())); create_consumer (consumer_admin.in (), ec.in (), &client); ACE_DEBUG((LM_DEBUG, "\nConsumer waiting for events...\n")); sig->go (); client.ORB_run( ); ACE_DEBUG((LM_DEBUG, "\nConsumer done.\n")); sig->done(); return 0; } catch (const CORBA::Exception& e) { e._tao_print_exception ("\nError: Consumer:"); } return 1; }
CosNotifyChannelAdmin::EventChannel_var get_event_channel(CORBA::ORB_ptr orb) { CosNotifyChannelAdmin::EventChannel_var ec; CosNotifyChannelAdmin::ChannelID id; CosNotification::QoSProperties init_qos(0); CosNotification::AdminProperties init_admin(0); std::cout << "Get CosNotifyChannelAdmin::EventChannelFactory" << std::endl; std::cout << "IorEventChannelFactory=" << ior << std::endl; CORBA::Object_var obj = orb->string_to_object(ior); if (CORBA::is_nil(obj.in ())) { std::cerr << "Bad ec_fact.ior " << std::endl; exit(1); } CosNotifyChannelAdmin::EventChannelFactory_var factory = CosNotifyChannelAdmin::EventChannelFactory::_narrow(obj.in ()); if (CORBA::is_nil(factory.in())) { std::cerr << "Could not _narrow object to type CosNotifyChannelAdmin::EventChannelFactory" << std::endl; exit(1); } //Get the first ec CosNotifyChannelAdmin::ChannelIDSeq_var channelIdSeq; try { channelIdSeq = factory->get_all_channels(); } catch (CORBA::SystemException& se ) { std::cerr << "System exception occurred during get_all_channels: " << se << std::endl; exit(1); } if( channelIdSeq->length() == 0 ) { try { ec = factory->create_channel( init_qos, init_admin, id); } catch (CORBA::SystemException& se ) { std::cerr << "System exception occurred during find_channel: " << se << std::endl; exit(1); } } else { try { ec = factory->get_event_channel(channelIdSeq.in()[0]); } catch (CosNotifyChannelAdmin::ChannelNotFound&) { std::cerr << "ChannelNotFound: " << channelIdSeq.in()[0] << std::endl; exit(1); } catch (CORBA::SystemException& se ) { std::cerr << "System exception occurred during get_event_channel: " << se << std::endl; exit(1); } } return ec._retn(); }
CORBA::Object_ptr DAnCE_NodeManager_Module::init (CORBA::ORB_ptr orb, int argc, ACE_TCHAR *argv[]) { try { if (CORBA::is_nil(orb)) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT("DAnCE_NodeManager_Module::init - ") ACE_TEXT("Attempted to create Node Manager with a nil orb.\n"))); return CORBA::Object::_nil(); } if (CORBA::is_nil(this->orb_.in())) { DANCE_TRACE_LOG (DANCE_LOG_DETAILED_TRACE, (LM_TRACE, DLINFO ACE_TEXT("DAnCE_NodeManager_Module::init - ") ACE_TEXT("NM's orb is nil.\n"))); this->orb_ = CORBA::ORB::_duplicate (orb); } else if (ACE_OS::strcmp(orb->id(), this->orb_->id()) != 0) { DANCE_DEBUG (DANCE_LOG_DETAILED_TRACE, (LM_TRACE, DLINFO ACE_TEXT("DAnCE_NodeManager_Module::init - ") ACE_TEXT("Resetting NM's orb.\n"))); this->orb_ = CORBA::ORB::_duplicate (orb); this->domain_nc_ = CosNaming::NamingContext::_nil(); } if (!this->parse_args (argc, argv)) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT("DAnCE_NodeManager_Module::init - ") ACE_TEXT("Unable to parse the commandline arguments.\n"))); return CORBA::Object::_nil (); } this->register_value_factories (); this->create_poas (); if (this->options_.domain_nc_) { try { DANCE_TRACE_LOG (DANCE_LOG_TRACE, (LM_TRACE, DLINFO ACE_TEXT("DAnCE_NodeManager_Module::init - ") ACE_TEXT("Resolving DomainNC.\n"))); CORBA::Object_var domain_obj = this->orb_->string_to_object (this->options_.domain_nc_); if (!CORBA::is_nil (domain_obj.in ())) { this->domain_nc_ = CosNaming::NamingContext::_narrow (domain_obj.in()); if (CORBA::is_nil (this->domain_nc_.in ())) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT("DAnCE_NodeManager_Module::init - ") ACE_TEXT("Narrow to NamingContext return nil for DomainNC.\n"))); return CORBA::Object::_nil (); } } } catch (const CORBA::Exception&) { DANCE_ERROR (DANCE_LOG_WARNING, (LM_WARNING, DLINFO ACE_TEXT("DAnCE_NodeManager_Module::init - ") ACE_TEXT("DomainNC context not found!\n"))); } } DANCE_TRACE_LOG (DANCE_LOG_TRACE, (LM_TRACE, DLINFO ACE_TEXT("DAnCE_NodeManager_Module::init - ") ACE_TEXT("Resolving plan NS naming context.\n"))); CosNaming::NamingContext_var rebind_nc; if (this->options_.rebind_plan_ns_) { if (!this->options_.create_plan_ns_) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("DAnCE_NodeManager_Module::init - ") ACE_TEXT ("Rebind_plan_ns option is enabled but Create_plan_ns is not.\n"))); return CORBA::Object::_nil(); } CORBA::Object_var tmp_obj; if (0 != this->options_.rebind_plan_ns_ior_) { tmp_obj = orb->string_to_object (this->options_.rebind_plan_ns_ior_); rebind_nc = CosNaming::NamingContext::_narrow (tmp_obj); } else { if (CORBA::is_nil (this->domain_nc_.in ())) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("DAnCE_NodeManager_Module::init - ") ACE_TEXT ("The rebind plan is enabled but neither NC ") ACE_TEXT ("nor DomainNC are not supplied. No rebinding will be done.\n") ACE_TEXT ("Use the \"-rebind-plan-ns NC ior\" ") ACE_TEXT ("or \"-ORBInitRef DomainNC\" option.\n"))); return CORBA::Object::_nil (); } rebind_nc = CosNaming::NamingContext::_duplicate (this->domain_nc_.in ()); } } // Initialize IOR table CORBA::Object_var table_object = orb->resolve_initial_references ("IORTable"); IORTable::Table_var adapter = IORTable::Table::_narrow (table_object.in ()); if (CORBA::is_nil (adapter.in ())) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("DAnCE_NodeManager_Module::init - ") ACE_TEXT ("Unable to RIR the IORTable.\n"))); return CORBA::Object::_nil (); } // Creating in process nameservice CosNaming::NamingContext_var plan_nc; if (this->options_.create_plan_ns_) { DANCE_DEBUG (DANCE_LOG_TRACE, (LM_TRACE, DLINFO ACE_TEXT ("DAnCE_NodeManager_Module::init - ") ACE_TEXT ("Resolving plan-specific naming context.\n"))); CORBA::Object_var naming_obj; if (0 != this->options_.create_plan_ns_ior_) { naming_obj = orb->string_to_object (this->options_.create_plan_ns_ior_); plan_nc = CosNaming::NamingContext::_narrow (naming_obj.in()); if (CORBA::is_nil (plan_nc.in())) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("DAnCE_NodeManager_Module::init - ") ACE_TEXT ("Failed trying to narrow naming context ") ACE_TEXT ("for dance creating plan NC.\n") ACE_TEXT ("Use the \"--create-plan-ns NC ior\" ") ACE_TEXT ("or \"--process-ns\" option.\n"))); return CORBA::Object::_nil (); } } else if (this->options_.process_ns_) { naming_obj = orb->resolve_initial_references ("NameService"); if (0 != this->options_.process_ns_file_) { CORBA::String_var ior = orb->object_to_string (naming_obj.in ()); DAnCE::Node_Manager::write_IOR (this->options_.process_ns_file_, ior.in ()); } plan_nc = CosNaming::NamingContext::_narrow (naming_obj.in ()); if (CORBA::is_nil (plan_nc.in ())) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("DAnCE_NodeManager_Module::init - ") ACE_TEXT ("Fails trying to narrow naming context ") ACE_TEXT ("for dance creating plan NC.\n") ACE_TEXT ("Use the \"--create-plan-ns NC ior\" ") ACE_TEXT ("or \"--process-ns\" option.\n"))); return CORBA::Object::_nil (); } } else if (CORBA::is_nil (this->domain_nc_.in ())) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("DAnCE_NodeManager_Module::init - ") ACE_TEXT ("The create plan is enabled but neither NC ior ") ACE_TEXT ("nor --process-ns or DomainNC option are not supplied.\n") ACE_TEXT ("Use the \"--create-plan-ns NC ior\", \"--process-ns\" ") ACE_TEXT ("or \"-ORBInitRef DomainNC\" option.\n"))); return CORBA::Object::_nil (); } else { plan_nc = CosNaming::NamingContext::_duplicate (this->domain_nc_.in ()); } } // Parsing Node name and node manager ior file name ACE_TString node_name = this->options_.node_managers_[0].c_str (); ACE_TString node_file; size_t npos = node_name.find ('='); if (ACE_CString::npos != npos) { node_file = node_name.substring (npos + 1, node_name.length() - npos + 1); node_name = node_name.substring (0, npos); } // load service modules for artifact installation service load_artifact_installation_modules (argc, argv); // Creating in process artifact installation service DAnCE::ArtifactInstallation_Impl* installer = 0; ACE_NEW_RETURN (installer, DAnCE::ArtifactInstallation_Impl (), CORBA::Object::_nil ()); PortableServer::Servant_var<DAnCE::ArtifactInstallation_Impl> safe_installer (installer); ACE_CString installer_oid_str = ACE_TEXT_ALWAYS_CHAR ((node_name + ACE_TEXT (".ArtifactInstaller")).c_str ()); // Registering servant in poa PortableServer::ObjectId_var installer_oid = PortableServer::string_to_ObjectId (installer_oid_str.c_str()); this->nm_poa_->activate_object_with_id (installer_oid, safe_installer._retn ()); CORBA::Object_var installer_object = this->nm_poa_->id_to_reference (installer_oid.in ()); this->installer_ = DAnCE::ArtifactInstallation::_narrow (installer_object.in ()); // Getting node manager ior CORBA::String_var installer_ior = orb->object_to_string (installer_object.in ()); // Binding ior to IOR Table adapter->bind (installer_oid_str.c_str (), installer_ior.in ()); // Make sure that we have only one Node Manager if (this->options_.node_managers_.size () != 1) { DANCE_ERROR (DANCE_LOG_EMERGENCY, (LM_ERROR, DLINFO ACE_TEXT ("DAnCE_NodeManager_Module::init - ") ACE_TEXT ("For now only one node manager creation is supported.\n"))); return CORBA::Object::_nil (); } DANCE_DEBUG (DANCE_LOG_MINOR_EVENT, (LM_DEBUG, DLINFO ACE_TEXT ("DAnCE_NodeManager_Module::init - ") ACE_TEXT ("DAnCE_NodeManager::run_main - creating NodeManager for node %C\n"), this->options_.node_managers_[0].c_str())); //Creating node manager servant DAnCE::NodeManager_Impl * nm = 0; if (this->nm_map_.find (node_name, nm) == -1) { DANCE_DEBUG (DANCE_LOG_EVENT_TRACE, (LM_TRACE, DLINFO ACE_TEXT ("DAnCE_NodeManager_Module::init - ") ACE_TEXT ("Allocating new NodeManager servant instance for NodeManager\n"))); int size = 64; DAnCE::Utility::PROPERTY_MAP properties (size); this->create_nm_properties (properties); ACE_NEW_RETURN (nm, DAnCE::NodeManager_Impl (orb, this->root_poa_.in (), this->installer_.in (), ACE_TEXT_ALWAYS_CHAR (node_name.c_str()), this->options_.node_config_, properties), CORBA::Object::_nil ()); DANCE_TRACE_LOG (DANCE_LOG_TRACE, (LM_TRACE, DLINFO ACE_TEXT ("DAnCE_NodeManager_Module::init - ") ACE_TEXT ("New NodeManager servant instance for NodeManager allocated.\n"))); this->nm_map_.bind (node_name, nm); } ACE_CString node_manager_oid = ACE_TEXT_ALWAYS_CHAR ((node_name + ACE_TEXT (".NodeManager")).c_str ()); // Registering servant in poa PortableServer::ObjectId_var oid = PortableServer::string_to_ObjectId (node_manager_oid.c_str()); this->nm_poa_->activate_object_with_id (oid, nm); // Getting node manager ior CORBA::Object_var nm_obj = this->nm_poa_->id_to_reference (oid.in ()); CORBA::String_var ior = orb->object_to_string (nm_obj.in ()); // Binding ior to IOR Table adapter->bind (node_manager_oid.c_str (), ior.in ()); // Binding node manager to DomainNC if (!CORBA::is_nil (this->domain_nc_.in ())) { DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, (LM_TRACE, DLINFO ACE_TEXT ("DAnCE_NodeManager_Module::init - ") ACE_TEXT ("Registering NM in NC as \"%C.NodeManager\".\n"), node_name.c_str ())); CosNaming::Name name (1); name.length (1); name[0].id = CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR (node_name.c_str ())); name[0].kind = CORBA::string_dup ("NodeManager"); this->domain_nc_->rebind (name, nm_obj.in ()); } // Writing ior to file if (0 != node_file.length ()) { DANCE_DEBUG (DANCE_LOG_EVENT_TRACE, (LM_TRACE, DLINFO ACE_TEXT ("DAnCE_NodeManager_Module::init - ") ACE_TEXT ("Writing node IOR %C to file %C.\n"), node_file.c_str (), ior.in ())); if (!DAnCE::Node_Manager::write_IOR (node_file.c_str (), ior.in ())) DANCE_ERROR (DANCE_LOG_NONFATAL_ERROR, (LM_ERROR, DLINFO ACE_TEXT ("DAnCE_NodeManager_Module::init - ") ACE_TEXT ("Error: Unable to write IOR to file %C\n"), node_file.c_str ())); } // Activate POA manager PortableServer::POAManager_var mgr = this->root_poa_->the_POAManager (); mgr->activate (); // Finishing Deployment part DANCE_DEBUG (DANCE_LOG_MAJOR_EVENT, (LM_NOTICE, DLINFO ACE_TEXT ("DAnCE_NodeManager_Module::init - ") ACE_TEXT ("DAnCE_NodeManager is running...\n"))); DANCE_DEBUG (DANCE_LOG_MAJOR_DEBUG_INFO, (LM_DEBUG, DLINFO ACE_TEXT ("DAnCE_NodeManager_Module::init - ") ACE_TEXT ("NodeManager IOR: %C\n"), ior.in ())); return nm_obj._retn (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("DAnCE_NodeManager::main\t\n"); return CORBA::Object::_nil (); } }
CORBA::Object_ptr TAO_CORBANAME_Parser::parse_string (const char *ior, CORBA::ORB_ptr orb) { // Skip the prefix, we know it is there because this method in only // called if <match_prefix> returns 1. const char *corbaname = ior + sizeof corbaname_prefix - 1; CORBA::Object_ptr obj = CORBA::Object::_nil (); try { // The position of the seperator between the obj_addr and key // string ACE_CString::size_type pos_seperator = 0; ACE_CString corbaname_str (corbaname, 0, 1); pos_seperator = corbaname_str.find ("#", 0); // Get the Key String ACE_CString key_string; if (pos_seperator != ACE_CString::npos) { key_string = corbaname_str.substring (pos_seperator + 1, ACE_CString::npos); } // Prepare a suitable corbaloc string for the name service. // CORBALOC assumes "NameService" for the object key if none // is provided, so just pass everything between "corbaname:" // and "#" as the address ACE_CString corbaloc_addr ("corbaloc:", 0, 1); corbaloc_addr += corbaname_str.substring (0, pos_seperator); // Obtain a reference to the naming context CORBA::Object_var name_context = orb->string_to_object (corbaloc_addr.c_str () ); // Check if the Object reference is nil. if (CORBA::is_nil (name_context.in ())) TAOLIB_ERROR_RETURN ((LM_ERROR, "Cannot resolve Naming Service: CORBANAME_Parser\n"), 0); CORBA::Boolean is_a = name_context->_is_a ("IDL:omg.org/CosNaming/NamingContextExt:1.0"); if (!is_a) { TAOLIB_ERROR_RETURN ((LM_ERROR, "Cannot narrow Naming Service: " "CORBANAME_Parser\n"), 0); } if (key_string.length () != 0) { // Make a dynamic request for resolve_str in this naming context obj = this->parse_string_dynamic_request_helper (name_context.in (), key_string); } else { // There was no key string which implies that the caller wants // the object reference of the naming service. obj = name_context._retn (); } } catch (const ::CORBA::SystemException& ex) { if (TAO_debug_level >= 4) { ex._tao_print_exception ("CORBANAME_Parser"); } } return obj; }
int ACE_TMAIN (int argc, ACE_TCHAR *argv[]) { int status = 0; try { Consumer_Client client; status = client.init (argc, argv); if (status == 0) { // If we are filtering, we will get half as many as originally // expected if (filter) { expected /= 2; } CosNotifyChannelAdmin::EventChannel_var ec = client.create_event_channel ("MyEventChannel", 1); CORBA::ORB_ptr orb = client.orb (); CORBA::Object_var object = orb->string_to_object (ior); sig_var sig = sig::_narrow (object.in ()); if (CORBA::is_nil (sig.in ())) { ACE_ERROR_RETURN ((LM_ERROR, "Object reference <%s> is nil\n", ior), 1); } CosNotifyChannelAdmin::ConsumerAdmin_var admin = create_consumeradmin (ec.in ()); if (!CORBA::is_nil (admin.in ())) { create_consumers(admin.in (), &client); // Tell the supplier to go sig->go (); client.ORB_run(); ACE_DEBUG((LM_DEBUG, "Consumer done.\n")); sig->done (); } } } catch (const CORBA::Exception& e) { e._tao_print_exception ("Error: Consumer exception: "); status = 1; } return status; }