2 #include "ace/Get_Opt.h"
5 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
8 const ACE_TCHAR
*ior_output_file
= ACE_TEXT("gateway.ior");
11 parse_args (int argc
, ACE_TCHAR
*argv
[])
13 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("xk:i:o:"));
16 while ((c
= get_opts ()) != -1)
24 ior
= get_opts
.opt_arg ();
28 niterations
= ACE_OS::atoi (get_opts
.opt_arg ());
32 ior_output_file
= get_opts
.opt_arg ();
37 ACE_ERROR_RETURN ((LM_ERROR
,
48 // Indicates successful parsing of the command line
53 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
58 CORBA::ORB_init (argc
, argv
);
60 CORBA::Object_var poa_object
=
61 orb
->resolve_initial_references("RootPOA");
63 if (CORBA::is_nil (poa_object
.in ()))
65 ACE_ERROR_RETURN ((LM_ERROR
,
66 " (%P|%t) Unable to initialize the POA.\n"),
70 PortableServer::POA_var root_poa
=
71 PortableServer::POA::_narrow (poa_object
.in ());
73 PortableServer::POAManager_var poa_manager
=
74 root_poa
->the_POAManager ();
76 poa_manager
->activate ();
78 if (parse_args (argc
, argv
) != 0)
83 CORBA::Object_var object
=
84 orb
->string_to_object (ior
);
86 DSI_Simple_Server
server_impl (orb
.in (),
89 PortableServer::ObjectId_var oid
=
90 root_poa
->activate_object (&server_impl
);
92 CORBA::Object_var server
=
93 root_poa
->id_to_reference (oid
.in ());
95 CORBA::String_var ior
=
96 orb
->object_to_string (server
.in ());
98 ACE_DEBUG ((LM_DEBUG
, "Activated as <%C>\n", ior
.in ()));
100 // If the ior_output_file exists, output the ior to it
101 if (ior_output_file
!= 0)
103 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
105 if (output_file
== 0)
107 ACE_ERROR_RETURN ((LM_ERROR
,
108 "Cannot open output file for writing IOR: %s",
113 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
114 ACE_OS::fclose (output_file
);
119 ACE_DEBUG ((LM_DEBUG
, "event loop finished\n"));
121 catch (const CORBA::Exception
& ex
)
123 ex
._tao_print_exception ("Gateway: exception caught - ");