2 #include "ORB_Holder.h"
3 #include "Servant_var.h"
4 #include "RIR_Narrow.h"
5 #include "RTEC_Initializer.h"
6 #include "RTServer_Setup.h"
8 #include "ORB_Task_Activator.h"
10 #include "orbsvcs/Event/EC_Event_Channel.h"
11 #include "orbsvcs/Event/EC_Default_Factory.h"
13 #include "tao/PortableServer/PortableServer.h"
14 #include "tao/RTPortableServer/RTPortableServer.h"
15 #include "tao/Strategies/advanced_resource.h"
16 #include "tao/Messaging/Messaging.h"
17 #include "ace/Get_Opt.h"
18 #include "ace/Auto_Ptr.h"
20 const ACE_TCHAR
*ior_output_file
= ACE_TEXT ("test.ior");
25 parse_args (int argc
, ACE_TCHAR
*argv
[])
27 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:n:r"));
30 while ((c
= get_opts ()) != -1)
34 ior_output_file
= get_opts
.opt_arg ();
38 nthreads
= ACE_OS::atoi (get_opts
.opt_arg ());
47 ACE_ERROR_RETURN ((LM_ERROR
,
56 // Indicates successful parsing of the command line
60 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
62 TAO_EC_Default_Factory::init_svcs ();
64 /// Move the test to the real-time class if it is possible.
69 ORB_Holder
orb (argc
, argv
, "");
71 if (parse_args (argc
, argv
) != 0)
74 RTServer_Setup
rtserver_setup (use_rt_corba
,
79 PortableServer::POA_var root_poa
=
80 RIR_Narrow
<PortableServer::POA
>::resolve (orb
,
83 PortableServer::POAManager_var poa_manager
=
84 root_poa
->the_POAManager ();
86 poa_manager
->activate ();
88 PortableServer::POA_var
ec_poa (rtserver_setup
.poa ());
90 ORB_Task
orb_task (orb
);
91 ORB_Task_Activator
orb_task_activator (rt_class
.priority_high (),
92 rt_class
.thr_sched_class (),
96 ACE_DEBUG ((LM_DEBUG
, "Finished ORB and POA configuration\n"));
98 Servant_var
<TAO_EC_Event_Channel
> ec_impl (
99 RTEC_Initializer::create (ec_poa
.in (),
101 rtserver_setup
.rtcorba_setup ()));
103 ec_impl
->activate ();
105 PortableServer::ObjectId_var ec_id
=
106 ec_poa
->activate_object (ec_impl
.in ());
107 CORBA::Object_var ec_object
=
108 ec_poa
->id_to_reference (ec_id
.in ());
110 RtecEventChannelAdmin::EventChannel_var ec
=
111 RtecEventChannelAdmin::EventChannel::_narrow (ec_object
.in ());
113 CORBA::String_var ior
=
114 orb
->object_to_string (ec
.in ());
116 // Output the ior to the <ior_output_file>
117 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
118 if (output_file
== 0)
119 ACE_ERROR_RETURN ((LM_ERROR
,
120 "Cannot open output file for writing IOR: %s",
123 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
124 ACE_OS::fclose (output_file
);
127 ACE_Time_Value
tv (1, 0);
129 } while (ec_impl
->destroyed () == 0);
131 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) server - event loop finished\n"));
133 catch (const CORBA::Exception
& ex
)
135 ex
._tao_print_exception ("Exception caught:");