1 #include "Server_Task.h"
5 #include "ace/Manual_Event.h"
6 #include "tao/ORB_Core.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 EventNode
*evnode_impl
= new EventNode(this->sorb_
.in(),ACE_Thread::self());
39 PortableServer::ServantBase_var
owner_transfer(evnode_impl
);
40 PortableServer::ObjectId_var id
=
41 root_poa
->activate_object (evnode_impl
);
43 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
45 Test::EventNode_var evNode
= Test::EventNode::_narrow (object
.in ());
47 ACE_DEBUG((LM_DEBUG
,"Server (%t) optimize_collocation_objects=%d use_global_collocation=%d\n",
48 sorb_
->orb_core()->optimize_collocation_objects(),
49 sorb_
->orb_core()->use_global_collocation ()));
51 CORBA::String_var ior
=
52 this->sorb_
->object_to_string (evNode
.in ());
54 // Output the IOR to the <this->output_>
55 FILE *output_file
= ACE_OS::fopen (this->output_
,
58 ACE_ERROR_RETURN ((LM_ERROR
,
59 "Cannot open output file for writing IOR: %s",
63 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
64 ACE_OS::fclose (output_file
);
66 poa_manager
->activate ();
68 // Signal the main thread before we call orb->run ();
73 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) server - event loop finished\n"));
75 catch (const CORBA::BAD_INV_ORDER
&)
77 // Periodically we get a bad inv order on fast machines.
78 // It's a false negative and is safe to ignore.
80 catch (const CORBA::Exception
& ex
)
82 ex
._tao_print_exception ("Exception caught:");