1 #include "ace/Get_Opt.h"
5 #include "tao/Strategies/advanced_resource.h"
7 const ACE_TCHAR
*ior_output_file
= ACE_TEXT("ior");
9 int number_of_event_loop_threads
= 1;
12 parse_args (int argc
, ACE_TCHAR
*argv
[])
14 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("e:o:"));
17 while ((c
= get_opts ()) != -1)
21 ior_output_file
= get_opts
.opt_arg ();
25 number_of_event_loop_threads
= ACE_OS::atoi (get_opts
.opt_arg ());
30 ACE_ERROR_RETURN ((LM_ERROR
,
33 "-e <number of event loop threads> "
39 // Indicates successful parsing of the command line
43 class Event_Loop_Task
: public ACE_Task_Base
46 Event_Loop_Task (CORBA::ORB_ptr orb
)
47 : orb_ (CORBA::ORB::_duplicate (orb
))
58 catch (const CORBA::Exception
& ex
)
60 ex
._tao_print_exception ("Exception caught in thread:");
74 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
79 CORBA::ORB_init (argc
,
82 CORBA::Object_var poa_object
=
83 orb
->resolve_initial_references ("RootPOA");
85 PortableServer::POA_var root_poa
=
86 PortableServer::POA::_narrow (poa_object
.in ());
88 PortableServer::POAManager_var poa_manager
=
89 root_poa
->the_POAManager ();
91 poa_manager
->activate ();
93 if (parse_args (argc
, argv
) != 0)
96 test_i
servant (orb
.in ());
98 PortableServer::ObjectId_var id
=
99 root_poa
->activate_object (&servant
);
101 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
104 test::_narrow (object
.in ());
106 CORBA::String_var ior
=
107 orb
->object_to_string (server
.in ());
109 ACE_DEBUG ((LM_DEBUG
, "Activated as <%C>\n", ior
.in ()));
111 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
112 if (output_file
== 0)
113 ACE_ERROR_RETURN ((LM_ERROR
,
114 "Cannot open output file for writing IOR: %s",
117 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
118 ACE_OS::fclose (output_file
);
120 Event_Loop_Task
event_loop_task (orb
.in ());
122 if (event_loop_task
.activate (THR_NEW_LWP
| THR_JOINABLE
,
123 number_of_event_loop_threads
) != 0)
124 ACE_ERROR_RETURN ((LM_ERROR
,
125 "Cannot activate event_loop threads\n"),
128 event_loop_task
.thr_mgr ()->wait ();
130 ACE_DEBUG ((LM_DEBUG
, "Server: Event loop finished\n"));
132 root_poa
->destroy (1,
135 catch (const CORBA::Exception
& ex
)
137 ex
._tao_print_exception ("Exception caught:");