2 * @file Server_Task.cpp
3 * @author Will Otte <wotte@dre.vanderbilt.edu>
5 * Implements the Server_Task class which acts as the process colocated
6 * corba server for Bug_1495_Regression test.
9 #include "Server_Task.h"
10 #include "ace/OS_NS_unistd.h"
13 #include "ace/Manual_Event.h"
16 Server_Task::Server_Task (const ACE_TCHAR
*output
,
19 ACE_Thread_Manager
*thr_mgr
)
20 : ACE_Task_Base (thr_mgr
),
23 sorb_ (CORBA::ORB::_duplicate (sorb
))
33 CORBA::Object_var poa_object
=
34 sorb_
->resolve_initial_references ("RootPOA");
36 if (CORBA::is_nil (poa_object
.in ()))
39 " (%P|%t) Unable to initialize the POA\n"));
43 PortableServer::POA_var root_poa
=
44 PortableServer::POA::_narrow (poa_object
.in ());
46 PortableServer::POAManager_var poa_manager
=
47 root_poa
->the_POAManager ();
49 poa_manager
->activate ();
51 Bug1495_i
*server_impl
= 0;
52 ACE_NEW_RETURN (server_impl
,
53 Bug1495_i (sorb_
.in ()),
55 PortableServer::ServantBase_var
owner_transfer (server_impl
);
57 PortableServer::ObjectId_var id
=
58 root_poa
->activate_object (server_impl
);
60 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
62 Bug1495_Regression::Bug1495_var bug1495
=
63 Bug1495_Regression::Bug1495::_narrow (object
.in ());
65 CORBA::String_var ior
= sorb_
->object_to_string (bug1495
.in ());
69 FILE *output_file
= ACE_OS::fopen (output_
, "w");
74 "Cannot open output file for writing the "
75 "thread server IOR: %s", output_
));
79 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
80 ACE_OS::fclose (output_file
);
83 // sleep for a few seconds and hope the remote server picks up the
87 // Signal the manual event to wake the main thread up.
90 // The ORB will run for 15 seconds and shut down.
91 ACE_Time_Value
tv (15, 0);
95 "Event loop finished for the thread server.\n"));
97 root_poa
->destroy (true, true);
101 catch (const CORBA::Exception
& ex
)
103 ex
._tao_print_exception ("Caught an exception in server task: ");