2 #include "Server_Task.h"
6 #include "ace/Manual_Event.h"
8 Server_Task::Server_Task (const ACE_TCHAR
*output
,
11 ACE_Thread_Manager
*thr_mgr
)
12 : ACE_Task_Base (thr_mgr
)
15 , sorb_ (CORBA::ORB::_duplicate (sorb
))
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 IOR: %s",
66 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
67 ACE_OS::fclose (output_file
);
69 poa_manager
->activate ();
71 // Signal the main thread before we call orb->run ();
74 ACE_Time_Value
runtime (10);
75 this->sorb_
->run (runtime
);
77 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) server - event loop finished\n"));
79 catch (const CORBA::Exception
& ex
)
81 ex
._tao_print_exception ("Exception caught:");