1 #include "Server_Task.h"
5 Server_Task::Server_Task (const ACE_TCHAR
*output
,
6 const ACE_TCHAR
*simple_test_output
,
9 ACE_Thread_Manager
*thr_mgr
)
10 : ACE_Task_Base (thr_mgr
)
12 , simple_test_output_ (simple_test_output
)
14 , sorb_ (CORBA::ORB::_duplicate (sorb
))
20 Server_Task::svc (void)
24 CORBA::Object_var poa_object
=
25 this->sorb_
->resolve_initial_references("RootPOA");
27 PortableServer::POA_var root_poa
=
28 PortableServer::POA::_narrow (poa_object
.in ());
30 if (CORBA::is_nil (root_poa
.in ()))
31 ACE_ERROR_RETURN ((LM_ERROR
,
32 " (%P|%t) Panic: nil RootPOA\n"),
35 PortableServer::POAManager_var poa_manager
=
36 root_poa
->the_POAManager ();
38 Hello
*hello_impl
= 0;
39 ACE_NEW_RETURN (hello_impl
,
40 Hello (this->sorb_
.in (),
44 PortableServer::ServantBase_var
owner_transfer(hello_impl
);
46 PortableServer::ObjectId_var id
=
47 root_poa
->activate_object (hello_impl
);
49 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
51 Test::Hello_var hello
=
52 Test::Hello::_narrow (object
.in ());
54 CORBA::String_var ior
=
55 this->sorb_
->object_to_string (hello
.in ());
57 // Output the IOR to the <this->output_>
58 FILE *output_file
= ACE_OS::fopen (this->output_
,
61 ACE_ERROR_RETURN ((LM_ERROR
,
62 "Cannot open output file for writing Hello IOR: %s",
66 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
67 ACE_OS::fclose (output_file
);
69 Test_Simple_Test_i
*simple_impl
= 0;
70 ACE_NEW_RETURN (simple_impl
,
71 Test_Simple_Test_i (),
74 PortableServer::ServantBase_var
owner_transfer_simple(simple_impl
);
76 id
= root_poa
->activate_object (simple_impl
);
78 object
= root_poa
->id_to_reference (id
.in ());
80 Test::Simple_Test_var simple_test
=
81 Test::Simple_Test::_narrow (object
.in ());
83 CORBA::String_var simple_test_ior
=
84 this->sorb_
->object_to_string (simple_test
.in ());
86 // Output the IOR to the <this->output_>
87 FILE *simple_test_output_file
= ACE_OS::fopen (this->simple_test_output_
,
89 if (simple_test_output_file
== 0)
90 ACE_ERROR_RETURN ((LM_ERROR
,
91 "Cannot open output file for writing Simple_Test IOR: %s",
92 this->simple_test_output_
),
95 ACE_OS::fprintf (simple_test_output_file
, "%s", simple_test_ior
.in ());
96 ACE_OS::fclose (simple_test_output_file
);
98 poa_manager
->activate ();
100 // Signal the main thread before we call orb->run ();
105 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) server - event loop finished\n"));
107 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) server - verifing results\n"));
109 CORBA::ULong errors
= hello_impl
->error_count ();
111 error_count_
+= errors
;
113 catch (const CORBA::Exception
& ex
)
116 ex
._tao_print_exception ("Exception caught:");
122 ACE_ERROR ((LM_ERROR
, "(%P|%t)Server_Task::svc - caught unknown exception\n"));
130 Server_Task::error_count () const