2 #include "ace/Get_Opt.h"
6 // The test is quiet...
8 static const ACE_TCHAR
*ior_file
= ACE_TEXT ("test.ior");
9 // File of file to which the ior is written
11 static int number_of_threads
= 1;
12 // Number of server threads.
14 class Server_Task
: public ACE_Task_Base
17 Server_Task (CORBA::ORB_ptr orb
);
24 Server_Task::Server_Task (CORBA::ORB_ptr orb
)
25 : orb_ (CORBA::ORB::_duplicate (orb
))
36 catch (const CORBA::Exception
&)
44 write_ior_to_file (const char *ior
)
46 FILE *output_file
= ACE_OS::fopen (ior_file
, "w");
49 ACE_ERROR_RETURN ((LM_ERROR
, "Cannot open output files for writing IOR: %s\n",
55 result
= ACE_OS::fprintf (output_file
,
59 static_cast<size_t> (result
) != ACE_OS::strlen (ior
))
60 ACE_ERROR_RETURN ((LM_ERROR
,
61 "ACE_OS::fprintf failed while writing %C to %s\n",
66 ACE_OS::fclose (output_file
);
75 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("q:f:t:"));
78 while ((c
= get_opts ()) != -1)
86 number_of_threads
= ACE_OS::atoi (get_opts
.opt_arg ());
90 ior_file
= get_opts
.opt_arg ();
95 ACE_ERROR_RETURN ((LM_ERROR
,
97 " [-t number of threads]"
109 ACE_TMAIN (int argc
, ACE_TCHAR
**argv
)
113 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
115 int result
= parse_args (argc
, argv
);
119 CORBA::Object_var object
= orb
->resolve_initial_references ("RootPOA");
121 PortableServer::POA_var root_poa
=
122 PortableServer::POA::_narrow (object
.in ());
124 PortableServer::POAManager_var poa_manager
=
125 root_poa
->the_POAManager ();
127 poa_manager
->activate ();
129 server_i
server_servant (quiet
,
132 PortableServer::ObjectId_var id
=
133 root_poa
->activate_object (&server_servant
);
135 CORBA::Object_var object_act
= root_poa
->id_to_reference (id
.in ());
137 server_var server_object
= server::_narrow (object_act
.in ());
139 CORBA::String_var ior
= orb
->object_to_string (server_object
.in ());
141 result
= write_ior_to_file (ior
.in ());
145 Server_Task
server_tasks (orb
.in ());
147 result
= server_tasks
.activate (THR_BOUND
,
153 result
= ACE_Thread_Manager::instance ()->wait ();
158 root_poa
->destroy (true, true);
160 catch (const CORBA::Exception
& ex
)
162 ex
._tao_print_exception ("server::main");