1 #include "Server_Task.h"
5 #include "ace/Manual_Event.h"
7 Server_Task::Server_Task (const ACE_TCHAR
*output
,
10 ACE_Thread_Manager
*thr_mgr
)
11 : ACE_Task_Base (thr_mgr
)
14 , sorb_ (CORBA::ORB::_duplicate (sorb
))
19 Server_Task::svc (void)
23 CORBA::Object_var poa_object
=
24 this->sorb_
->resolve_initial_references("RootPOA");
26 PortableServer::POA_var root_poa
=
27 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"),
36 PortableServer::POAManager_var poa_manager
=
37 root_poa
->the_POAManager ();
39 HelloAgain
*hello_impl
;
40 ACE_NEW_RETURN (hello_impl
,
41 HelloAgain (this->sorb_
.in (),
44 PortableServer::ServantBase_var
owner1_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::HelloAgain_var hello
=
52 Test::HelloAgain::_narrow (object
.in ());
54 CORBA::String_var ior
=
55 this->sorb_
->object_to_string (hello
.in ());
58 // Output the IOR to the <this->output_>
59 FILE *output_file
= ACE_OS::fopen (this->output_
,
62 ACE_ERROR_RETURN ((LM_ERROR
,
63 "Cannot open output file for writing IOR: %s",
67 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
68 // ACE_OS::fprintf (output_file, "%s", ior1.in ());
70 ACE_OS::fclose (output_file
);
72 poa_manager
->activate ();
74 // Signal the main thread before we call orb->run ();
79 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) server - event loop finished\n"));
81 catch (const CORBA::Exception
& ex
)
83 ex
._tao_print_exception ("Exception caught:");