1 #include "ace/Get_Opt.h"
3 #include "ace/OS_NS_stdio.h"
5 const ACE_TCHAR
*ior_output_file
= ACE_TEXT("ior");
6 const ACE_TCHAR
*client_done_file
= ACE_TEXT("client_done.ior");
9 parse_args (int argc
, ACE_TCHAR
*argv
[])
11 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:s:"));
14 while ((c
= get_opts ()) != -1)
18 ior_output_file
= get_opts
.opt_arg ();
21 client_done_file
= get_opts
.opt_arg ();
25 ACE_ERROR_RETURN ((LM_ERROR
,
28 "-s <file_in_servant>"
34 // Indicates successful parsing of the command line
39 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
44 CORBA::ORB_init (argc
,
47 CORBA::Object_var poa_object
=
48 orb
->resolve_initial_references ("RootPOA");
50 PortableServer::POA_var root_poa
=
51 PortableServer::POA::_narrow (poa_object
.in ());
53 PortableServer::POAManager_var poa_manager
=
54 root_poa
->the_POAManager ();
56 if (parse_args (argc
, argv
) != 0)
59 test_i
servant (orb
.in (), client_done_file
);
61 PortableServer::ObjectId_var id
=
62 root_poa
->activate_object (&servant
);
64 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
67 test::_narrow (object
.in ());
69 CORBA::String_var ior
=
70 orb
->object_to_string (server
.in ());
72 ACE_DEBUG ((LM_DEBUG
, "Activated as <%C>\n", ior
.in ()));
74 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
76 ACE_ERROR_RETURN ((LM_ERROR
,
77 "Cannot open output file for writing IOR: %s",
80 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
81 ACE_OS::fclose (output_file
);
83 poa_manager
->activate ();
87 ACE_DEBUG ((LM_DEBUG
, "event loop finished\n"));
89 root_poa
->destroy (true, true);
91 catch (const CORBA::Exception
& ex
)
93 ex
._tao_print_exception ("Exception caught:");