1 #include "ace/Get_Opt.h"
2 #include "ace/OS_NS_stdio.h"
3 #include "tao/IFR_Client/IFR_BasicC.h"
4 // Must include this header file and link to TAO_IFR_Client.lib
5 // to dynamically load this necessary library.
6 #include "tao/IFR_Client/IFR_Client_Adapter_Impl.h"
9 #include "ace/streams.h"
11 const ACE_TCHAR
*ior_output_file
= ACE_TEXT ("test.ior");
14 parse_args (int argc
, ACE_TCHAR
*argv
[])
16 ACE_Get_Opt
get_opts (argc
, argv
, "o:");
19 while ((c
= get_opts ()) != -1)
23 ior_output_file
= get_opts
.opt_arg ();
28 ACE_ERROR_RETURN ((LM_ERROR
,
35 // Indicates successful parsing of the command line
40 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
45 CORBA::ORB_init (argc
, argv
);
47 CORBA::Object_var poa_object
=
48 orb
->resolve_initial_references("RootPOA");
50 PortableServer::POA_var root_poa
=
51 PortableServer::POA::_narrow (poa_object
.in ());
53 if (CORBA::is_nil (root_poa
.in ()))
54 ACE_ERROR_RETURN ((LM_ERROR
,
55 " (%P|%t) Panic: nil RootPOA\n"),
58 PortableServer::POAManager_var poa_manager
=
59 root_poa
->the_POAManager ();
61 poa_manager
->activate ();
63 if (parse_args (argc
, argv
) != 0)
66 Test_interfaceOne_i
*ifo_impl
;
67 ACE_NEW_RETURN (ifo_impl
,
68 Test_interfaceOne_i (),
70 PortableServer::ServantBase_var
owner_transfer(ifo_impl
);
72 Test::interfaceOne_var ifo
= ifo_impl
->_this ();
74 CORBA::String_var ior
=
75 orb
->object_to_string (ifo
.in ());
77 // Output the IOR to the <ior_output_file>
78 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
80 ACE_ERROR_RETURN ((LM_ERROR
,
81 "Cannot open output file for writing IOR: %s\n",
84 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
86 ACE_OS::fclose (output_file
);
90 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) server - event loop finished\n"));
92 root_poa
->destroy (true, true);
96 catch (const CORBA::Exception
& ex
)
98 ex
._tao_print_exception ("Exception caught:");