int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); ::CIAO::Client_init (orb.in ()); if (parse_args (argc, argv) != 0) return 1; CORBA::Object_var tmp = orb->string_to_object(ior); Test::Cook_var cook = Test::Cook::_narrow(tmp.in ()); if (CORBA::is_nil (cook.in ())) { ACE_ERROR_RETURN ((LM_DEBUG, "Nil Test::Cook reference <%s>\n", ior), 1); } Components::Cookie_var cookie = cook->get_cookie (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) - cookie returned <%@>\n", cookie.in ())); try { cook->check_cookie (cookie.in ()); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Client exception caught:"); return 1; } cook->shutdown (); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Client exception caught:"); return 1; } return 0; }
int ACE_TMAIN(int argc, ACE_TCHAR *argv[]) { try { CORBA::ORB_var orb = CORBA::ORB_init (argc, argv); CIAO::Server_init (orb); 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; Cookie *cookie_impl = 0; ACE_NEW_RETURN (cookie_impl, Cookie (orb.in ()), 1); PortableServer::ServantBase_var owner_transfer (cookie_impl); PortableServer::ObjectId_var id = root_poa->activate_object (cookie_impl); CORBA::Object_var object = root_poa->id_to_reference (id.in ()); Test::Cook_var cook = Test::Cook::_narrow (object.in ()); CORBA::String_var ior = orb->object_to_string (cook.in ()); // Output the IOR to the <ior_output_file> FILE *output_file= ACE_OS::fopen (ior_output_file, "w"); if (output_file == 0) ACE_ERROR_RETURN ((LM_ERROR, "Cannot open output file for writing IOR: %s\n", ior_output_file), 1); ACE_OS::fprintf (output_file, "%s", ior.in ()); ACE_OS::fclose (output_file); poa_manager->activate (); orb->run (); ACE_DEBUG ((LM_DEBUG, "(%P|%t) server - event loop finished\n")); root_poa->destroy (1, 1); orb->destroy (); } catch (const CORBA::Exception& ex) { ex._tao_print_exception ("Server exception caught:"); return 1; } return 0; }