1 #include "amh_ami_pch.h"
4 #include "ace/SString.h"
5 #include "ace/Get_Opt.h"
11 const ACE_TCHAR
*ior_output_file
= ACE_TEXT ("inner.ior");
14 parse_args (int argc
, ACE_TCHAR
*argv
[])
16 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("c:o:"));
19 while ((c
= get_opts ()) != -1)
26 ior_output_file
= get_opts
.opt_arg ();
30 ACE_ERROR_RETURN ((LM_ERROR
,
38 // Indicates successful parsing of the command line
43 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
46 // Initialize the ORB.
47 CORBA::ORB_var orb
= CORBA::ORB_init( argc
, argv
);
49 if (parse_args (argc
, argv
) != 0)
52 //Get reference to the RootPOA.
53 CORBA::Object_var obj
= orb
->resolve_initial_references( "RootPOA" );
54 PortableServer::POA_var poa
= PortableServer::POA::_narrow( obj
.in() );
56 // Activate the POAManager.
57 PortableServer::POAManager_var mgr
= poa
->the_POAManager();
61 PortableServer::Servant_var
<Inner_i
> servant
= new Inner_i(dont_crash
);
63 // Register the servant with the RootPOA, obtain its object
64 // reference, stringify it, and write it to a file.
65 PortableServer::ObjectId_var oid
= poa
->activate_object( servant
.in() );
66 obj
= poa
->id_to_reference( oid
.in() );
67 CORBA::String_var str
= orb
->object_to_string( obj
.in() );
68 ACE_CString
iorname (ACE_TEXT_ALWAYS_CHAR(ior_output_file
));
69 std::ofstream
iorFile (iorname
.c_str());
70 iorFile
<< str
.in() << std::endl
;
72 std::cout
<< "IOR written to " << iorname
<< std::endl
;
74 // Accept requests from clients.
80 catch(const CORBA::Exception
& ex
) {
81 std::cerr
<< "CORBA exception: " << ex
<< std::endl
;