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"
19 const ACE_TCHAR
*ior_output_file
= ACE_TEXT ("test.ior");
24 parse_args (int argc
, ACE_TCHAR
*argv
[])
26 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:n:r"));
29 while ((c
= get_opts ()) != -1)
33 ior_output_file
= get_opts
.opt_arg ();
37 nthreads
= ACE_OS::atoi (get_opts
.opt_arg ());
46 ACE_ERROR_RETURN ((LM_ERROR
,
55 // Indicates successful parsing of the command line
59 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
61 TAO_EC_Default_Factory::init_svcs ();
63 /// Move the test to the real-time class if it is possible.
68 ORB_Holder
orb (argc
, argv
, "");
70 if (parse_args (argc
, argv
) != 0)
73 RTServer_Setup
rtserver_setup (use_rt_corba
,
78 PortableServer::POA_var root_poa
=
79 RIR_Narrow
<PortableServer::POA
>::resolve (orb
,
82 PortableServer::POAManager_var poa_manager
=
83 root_poa
->the_POAManager ();
85 poa_manager
->activate ();
87 PortableServer::POA_var
ec_poa (rtserver_setup
.poa ());
89 ORB_Task
orb_task (orb
);
90 ORB_Task_Activator
orb_task_activator (rt_class
.priority_high (),
91 rt_class
.thr_sched_class (),
95 ACE_DEBUG ((LM_DEBUG
, "Finished ORB and POA configuration\n"));
97 Servant_var
<TAO_EC_Event_Channel
> ec_impl (
98 RTEC_Initializer::create (ec_poa
.in (),
100 rtserver_setup
.rtcorba_setup ()));
102 ec_impl
->activate ();
104 PortableServer::ObjectId_var ec_id
=
105 ec_poa
->activate_object (ec_impl
.in ());
106 CORBA::Object_var ec_object
=
107 ec_poa
->id_to_reference (ec_id
.in ());
109 RtecEventChannelAdmin::EventChannel_var ec
=
110 RtecEventChannelAdmin::EventChannel::_narrow (ec_object
.in ());
112 CORBA::String_var ior
=
113 orb
->object_to_string (ec
.in ());
115 // Output the ior to the <ior_output_file>
116 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
117 if (output_file
== 0)
118 ACE_ERROR_RETURN ((LM_ERROR
,
119 "Cannot open output file for writing IOR: %s",
122 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
123 ACE_OS::fclose (output_file
);
126 ACE_Time_Value
tv (1, 0);
128 } while (ec_impl
->destroyed () == 0);
130 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) server - event loop finished\n"));
132 catch (const CORBA::Exception
& ex
)
134 ex
._tao_print_exception ("Exception caught:");