1 #include "SharedIntf_i.h"
4 #include "ace/SString.h"
5 #include "ace/Get_Opt.h"
6 #include "ace/OS_NS_unistd.h"
8 const ACE_TCHAR
*ior_output_file
= ACE_TEXT ("server.ior");
9 const char *upper_ior
= "corbaloc::127.10.100.4:34999/bogus";
13 class Worker
: public ACE_Task_Base
18 ACE_DEBUG((LM_INFO
,"(%P|%t) Running ORB in a separate thread\n"));
23 catch (const CORBA::Exception
&)
31 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
37 ACE_DEBUG((LM_INFO
,"(%P|%t) SERVER START\n"));
39 orb_
= CORBA::ORB_init (argc
, argv
);
41 CORBA::Object_var obj
= orb_
->resolve_initial_references("RootPOA");
42 PortableServer::POA_var poa
= PortableServer::POA::_narrow (obj
.in());
43 PortableServer::POAManager_var mgr
= poa
->the_POAManager ();
46 ACE_DEBUG((LM_INFO
,"(%P|%t) ORB initialized\n"));
48 Test_Idl_SharedIntf_i
* intf_i
= new Test_Idl_SharedIntf_i(orb_
.in());
50 PortableServer::ServantBase_var base_var
= intf_i
;
51 PortableServer::ObjectId_var intfId_var
=
52 poa
->activate_object(base_var
.in());
54 obj
= poa
->id_to_reference(intfId_var
.in());
55 Test_Idl::SharedIntf_var intf_var
= Test_Idl::SharedIntf::_narrow(obj
.in());
56 CORBA::String_var intfString_var
= orb_
->object_to_string(intf_var
.in());
58 // Output the IOR to the <ior_output_file>
59 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
61 ACE_ERROR_RETURN ((LM_ERROR
,
62 "Cannot open output file for writing IOR: %s\n",
65 ACE_OS::fprintf (output_file
, "%s", intfString_var
.in ());
66 ACE_OS::fclose (output_file
);
68 intf_i
->set_upper (upper_ior
);
70 // Running ORB in separate thread
72 if (worker
.activate () != 0)
73 ACE_ERROR_RETURN ((LM_ERROR
,
74 "(%P|%t) %p\n", "Cannot activate server thread(s)"),
77 worker
.thr_mgr()->wait ();
80 catch (const CORBA::Exception
& ex
)
82 ex
._tao_print_exception ("Error: Exception caught:");
85 ACE_OS::unlink (ior_output_file
);