1 #include "Server_Task.h"
3 #include "interceptors.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
))
23 CORBA::Object_var poa_object
=
24 sorb_
->resolve_initial_references ("RootPOA");
26 if (CORBA::is_nil (poa_object
.in ()))
27 ACE_ERROR_RETURN ((LM_ERROR
,
28 " (%P|%t) Unable to initialize the POA.\n"),
31 PortableServer::POA_var root_poa
=
32 PortableServer::POA::_narrow (poa_object
.in ());
34 PortableServer::POAManager_var poa_manager
=
35 root_poa
->the_POAManager ();
37 poa_manager
->activate ();
39 Visual_i
* server_impl
= 0;
40 ACE_NEW_RETURN (server_impl
, Visual_i (sorb_
.in ()), 1);
42 PortableServer::ObjectId_var id
=
43 root_poa
->activate_object (server_impl
);
45 CORBA::Object_var test_obj
=
46 root_poa
->id_to_reference (id
.in ());
48 Test_Interceptors::Visual_var server
=
49 Test_Interceptors::Visual::_narrow (test_obj
.in ());
51 CORBA::String_var ior
=
52 this->sorb_
->object_to_string (server
.in ());
54 ACE_DEBUG ((LM_DEBUG
, "Test_Interceptors::Visual: <%C>\n", ior
.in ()));
56 // If the ior_output_file exists, output the ior to it
59 FILE *output_file
= ACE_OS::fopen (this->output_
, "w");
61 ACE_ERROR_RETURN ((LM_ERROR
,
62 "Cannot open output file for writing IOR: %s",
65 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
66 ACE_OS::fclose (output_file
);
69 // Signal the main thread before we call orb->run ();
74 ACE_DEBUG ((LM_DEBUG
, "event loop finished\n"));
76 root_poa
->destroy (true, true);
78 catch (const CORBA::Exception
& ex
)
80 ex
._tao_print_exception ("Exception caught in server task:");