3 #include "ace/Get_Opt.h"
4 #include "AMH_Messenger_i.h"
8 ACE_TString ior_output_file
;
11 parse_args(int argc
, ACE_TCHAR
*argv
[])
13 ACE_Get_Opt
get_opts(argc
, argv
, ACE_TEXT("o:"));
16 while((c
= get_opts()) != -1)
20 ior_output_file
= get_opts
.optarg
;
25 std::cerr
<< "usage: " << argv
[0] << "-o <iorfile>" << std::endl
;
29 // Indicates successful parsing of the command line
33 int ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
36 // Initialize the ORB.
37 CORBA::ORB_var orb
= CORBA::ORB_init( argc
, argv
);
39 if (parse_args(argc
, argv
) != 0) {
43 //Get reference to the RootPOA.
44 CORBA::Object_var obj
= orb
->resolve_initial_references( "RootPOA" );
45 PortableServer::POA_var poa
= PortableServer::POA::_narrow( obj
.in() );
47 // Activate the POAManager.
48 PortableServer::POAManager_var mgr
= poa
->the_POAManager();
52 PortableServer::Servant_var
<AMH_Messenger_i
> servant
= new AMH_Messenger_i
;
54 // Register the servant with the RootPOA, obtain its object
55 // reference, stringify it, and write it to a file.
56 PortableServer::ObjectId_var oid
= poa
->activate_object( servant
.in() );
57 obj
= poa
->id_to_reference( oid
.in() );
58 CORBA::String_var str
= orb
->object_to_string( obj
.in() );
59 std::ofstream
iorFile(ACE_TEXT_ALWAYS_CHAR(ior_output_file
.c_str()));
60 iorFile
<< str
.in() << std::endl
;
62 std::cout
<< "IOR written to file Messenger.ior" << std::endl
;
64 // Accept requests from clients.
70 catch(const CORBA::Exception
& ex
) {
71 std::cerr
<< "CORBA exception: " << ex
<< std::endl
;