1 #include "Messenger_i.h"
4 #include "ace/Get_Opt.h"
6 const ACE_TCHAR
*ior_output_file
= ACE_TEXT ("Messenger.ior");
9 parse_args (int argc
, ACE_TCHAR
*argv
[])
11 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
14 while ((c
= get_opts ()) != -1)
18 ior_output_file
= get_opts
.opt_arg ();
23 ACE_ERROR_RETURN ((LM_ERROR
,
30 // Indicates successful parsing of the command line
35 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
39 CORBA::ORB_var orb
= CORBA::ORB_init( argc
, argv
);
41 if (parse_args (argc
, argv
) != 0)
44 //Get reference to Root POA
45 CORBA::Object_var obj
= orb
->resolve_initial_references( "RootPOA" );
46 PortableServer::POA_var poa
= PortableServer::POA::_narrow( obj
.in() );
48 // Activate POA Manager
49 PortableServer::POAManager_var mgr
= poa
->the_POAManager();
53 PortableServer::Servant_var
<Messenger_i
> messenger_servant
= new Messenger_i
;
55 // Write its strigified reference to a file
56 PortableServer::ObjectId_var oid
=
57 poa
->activate_object( messenger_servant
.in() );
58 CORBA::Object_var messenger_obj
= poa
->id_to_reference( oid
.in() );
59 CORBA::String_var str
= orb
->object_to_string( messenger_obj
.in() );
60 std::ofstream
iorFile(ACE_TEXT_ALWAYS_CHAR(ior_output_file
));
61 iorFile
<< str
.in() << std::endl
;
63 std::cout
<< "IOR written to file " << ACE_TEXT_ALWAYS_CHAR(ior_output_file
) << std::endl
;
70 catch(const CORBA::Exception
& ex
) {
71 std::cerr
<< "Caught a CORBA exception: " << ex
<< std::endl
;