2 #include "ace/Get_Opt.h"
3 #include "ace/OS_NS_stdio.h"
5 #include "ace/SString.h"
7 const ACE_TCHAR
*ior_output_file
= 0;
8 const char *cert_file
= "cacert.pem";
11 parse_args (int argc
, ACE_TCHAR
*argv
[])
13 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
16 while ((c
= get_opts ()) != -1)
20 ior_output_file
= get_opts
.opt_arg ();
24 ACE_ERROR_RETURN ((LM_ERROR
,
31 // Indicates successful parsing of the command line
36 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
41 CORBA::ORB_init (argc
, argv
);
43 CORBA::Object_var obj
=
44 orb
->resolve_initial_references ("RootPOA");
46 if (CORBA::is_nil (obj
.in ()))
47 ACE_ERROR_RETURN ((LM_ERROR
,
48 "(%P|%t) ERROR: Unable to initialize the "
52 PortableServer::POA_var root_poa
=
53 PortableServer::POA::_narrow (obj
.in ());
55 PortableServer::POAManager_var poa_manager
=
56 root_poa
->the_POAManager ();
58 if (parse_args (argc
, argv
) != 0)
61 Foo_i
*server_impl
= 0;
63 ACE_NEW_RETURN (server_impl
,
67 PortableServer::ServantBase_var
owner_transfer (server_impl
);
70 server_impl
->_this ();
72 CORBA::String_var ior
=
73 orb
->object_to_string (server
.in ());
75 ACE_DEBUG ((LM_DEBUG
, "Activated as <%C>\n", ior
.in ()));
77 // If the ior_output_file exists, output the ior to it
78 if (ior_output_file
!= 0)
80 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
82 ACE_ERROR_RETURN ((LM_ERROR
,
83 "Cannot open output file for writing IOR: %s",
86 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
87 ACE_OS::fclose (output_file
);
90 poa_manager
->activate ();
96 "Event loop finished.\n"));
98 root_poa
->destroy (1, 1);
102 catch (const CORBA::Exception
& ex
)
104 ex
._tao_print_exception ("Caught exception:");