1 #include "Server_Task.h"
5 #include "ace/Manual_Event.h"
7 Server_Task::Server_Task (const ACE_TCHAR
*output
,
8 const ACE_TCHAR
*simple_test_output
,
11 ACE_Thread_Manager
*thr_mgr
)
12 : ACE_Task_Base (thr_mgr
)
14 , simple_test_output_ (simple_test_output
)
16 , sorb_ (CORBA::ORB::_duplicate (sorb
))
26 CORBA::Object_var poa_object
=
27 this->sorb_
->resolve_initial_references("RootPOA");
29 PortableServer::POA_var root_poa
=
30 PortableServer::POA::_narrow (poa_object
.in ());
32 if (CORBA::is_nil (root_poa
.in ()))
33 ACE_ERROR_RETURN ((LM_ERROR
,
34 " (%P|%t) Panic: nil RootPOA\n"),
37 PortableServer::POAManager_var poa_manager
=
38 root_poa
->the_POAManager ();
41 ACE_NEW_RETURN (hello_impl
,
42 Hello (this->sorb_
.in (),
46 PortableServer::ServantBase_var
owner_transfer(hello_impl
);
48 PortableServer::ObjectId_var id
=
49 root_poa
->activate_object (hello_impl
);
51 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
53 Test::Hello_var hello
=
54 Test::Hello::_narrow (object
.in ());
56 CORBA::String_var ior
=
57 this->sorb_
->object_to_string (hello
.in ());
59 // Output the IOR to the <this->output_>
60 FILE *output_file
= ACE_OS::fopen (this->output_
,
63 ACE_ERROR_RETURN ((LM_ERROR
,
64 "Cannot open output file for writing Hello IOR: %s",
68 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
69 ACE_OS::fclose (output_file
);
71 Test_Simple_Test_i
*simple_impl
;
72 ACE_NEW_RETURN (simple_impl
,
73 Test_Simple_Test_i (),
76 PortableServer::ServantBase_var
owner_transfer_simple(simple_impl
);
78 id
= root_poa
->activate_object (simple_impl
);
80 object
= root_poa
->id_to_reference (id
.in ());
82 Test::Simple_Test_var simple_test
=
83 Test::Simple_Test::_narrow (object
.in ());
85 CORBA::String_var simple_test_ior
=
86 this->sorb_
->object_to_string (simple_test
.in ());
88 // Output the IOR to the <this->output_>
89 FILE *simple_test_output_file
= ACE_OS::fopen (this->simple_test_output_
,
91 if (simple_test_output_file
== 0)
92 ACE_ERROR_RETURN ((LM_ERROR
,
93 "Cannot open output file for writing Simple_Test IOR: %s",
94 this->simple_test_output_
),
97 ACE_OS::fprintf (simple_test_output_file
, "%s", simple_test_ior
.in ());
98 ACE_OS::fclose (simple_test_output_file
);
100 poa_manager
->activate ();
102 // Signal the main thread before we call orb->run ();
107 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) server - event loop finished\n"));
109 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) server - verifing results\n"));
111 CORBA::ULong errors
= hello_impl
->error_count ();
113 error_count_
+= errors
;
115 catch (const CORBA::Exception
& ex
)
118 ex
._tao_print_exception ("Exception caught:");
124 ACE_ERROR ((LM_ERROR
, "(%P|%t)Server_Task::svc - caught unknown exception\n"));
132 Server_Task::error_count () const