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
))
57 catch (const CORBA::Exception
& ex
)
59 ex
._tao_print_exception ("Exception caught in thread:");
73 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
78 CORBA::ORB_init (argc
,
81 CORBA::Object_var poa_object
=
82 orb
->resolve_initial_references ("RootPOA");
84 PortableServer::POA_var root_poa
=
85 PortableServer::POA::_narrow (poa_object
.in ());
87 PortableServer::POAManager_var poa_manager
=
88 root_poa
->the_POAManager ();
90 poa_manager
->activate ();
92 if (parse_args (argc
, argv
) != 0)
95 test_i
servant (orb
.in ());
97 PortableServer::ObjectId_var id
=
98 root_poa
->activate_object (&servant
);
100 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
103 test::_narrow (object
.in ());
105 CORBA::String_var ior
=
106 orb
->object_to_string (server
.in ());
108 ACE_DEBUG ((LM_DEBUG
, "Activated as <%C>\n", ior
.in ()));
110 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
111 if (output_file
== 0)
112 ACE_ERROR_RETURN ((LM_ERROR
,
113 "Cannot open output file for writing IOR: %s",
116 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
117 ACE_OS::fclose (output_file
);
119 Event_Loop_Task
event_loop_task (orb
.in ());
121 if (event_loop_task
.activate (THR_NEW_LWP
| THR_JOINABLE
,
122 number_of_event_loop_threads
) != 0)
123 ACE_ERROR_RETURN ((LM_ERROR
,
124 "Cannot activate event_loop threads\n"),
127 event_loop_task
.thr_mgr ()->wait ();
129 ACE_DEBUG ((LM_DEBUG
, "Server: Event loop finished\n"));
131 root_poa
->destroy (true, true);
133 catch (const CORBA::Exception
& ex
)
135 ex
._tao_print_exception ("Exception caught:");