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
&)
32 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
38 ACE_DEBUG((LM_INFO
,"(%P|%t) SERVER START\n"));
40 orb_
= CORBA::ORB_init (argc
, argv
);
42 CORBA::Object_var obj
= orb_
->resolve_initial_references("RootPOA");
43 PortableServer::POA_var poa
= PortableServer::POA::_narrow (obj
.in());
44 PortableServer::POAManager_var mgr
= poa
->the_POAManager ();
47 ACE_DEBUG((LM_INFO
,"(%P|%t) ORB initialized\n"));
49 Test_Idl_SharedIntf_i
* intf_i
= new Test_Idl_SharedIntf_i(orb_
.in());
51 PortableServer::ServantBase_var base_var
= intf_i
;
52 PortableServer::ObjectId_var intfId_var
=
53 poa
->activate_object(base_var
.in());
55 obj
= poa
->id_to_reference(intfId_var
.in());
56 Test_Idl::SharedIntf_var intf_var
= Test_Idl::SharedIntf::_narrow(obj
.in());
57 CORBA::String_var intfString_var
= orb_
->object_to_string(intf_var
.in());
59 // Output the IOR to the <ior_output_file>
60 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
62 ACE_ERROR_RETURN ((LM_ERROR
,
63 "Cannot open output file for writing IOR: %s\n",
66 ACE_OS::fprintf (output_file
, "%s", intfString_var
.in ());
67 ACE_OS::fclose (output_file
);
69 intf_i
->set_upper (upper_ior
);
71 // Running ORB in separate thread
73 if (worker
.activate () != 0)
74 ACE_ERROR_RETURN ((LM_ERROR
,
75 "(%P|%t) %p\n", "Cannot activate server thread(s)"),
78 worker
.thr_mgr()->wait ();
81 catch (const CORBA::Exception
& ex
)
83 ex
._tao_print_exception ("Error: Exception caught:");
86 ACE_OS::unlink (ior_output_file
);