1 #include "ace/Get_Opt.h"
2 #include "AMI_Manager.h"
4 const ACE_TCHAR
*ior_output_file
= ACE_TEXT("test.ior");
7 parse_args (int argc
, ACE_TCHAR
*argv
[])
9 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
12 while ((c
= get_opts ()) != -1)
16 ior_output_file
= get_opts
.opt_arg ();
20 ACE_ERROR_RETURN ((LM_ERROR
,
27 // Indicates successful parsing of the command line
32 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
37 CORBA::ORB_init (argc
, argv
);
39 CORBA::Object_var poa_object
=
40 orb
->resolve_initial_references("RootPOA");
42 if (CORBA::is_nil (poa_object
.in ()))
43 ACE_ERROR_RETURN ((LM_ERROR
,
44 " (%P|%t) Unable to initialize the POA.\n"),
47 PortableServer::POA_var root_poa
=
48 PortableServer::POA::_narrow (poa_object
.in ());
50 PortableServer::POAManager_var poa_manager
=
51 root_poa
->the_POAManager ();
53 if (parse_args (argc
, argv
) != 0)
56 AMI_Manager
manager_impl (orb
.in ());
58 PortableServer::ObjectId_var id
=
59 root_poa
->activate_object (&manager_impl
);
61 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
63 Test::Manager_var manager
=
64 Test::Manager::_narrow (object
.in ());
66 CORBA::String_var ior
=
67 orb
->object_to_string (manager
.in ());
69 // If the ior_output_file exists, output the ior to it
70 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
72 ACE_ERROR_RETURN ((LM_ERROR
,
73 "Cannot open output file for writing IOR: %s",
76 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
77 ACE_OS::fclose (output_file
);
79 poa_manager
->activate ();
83 // ACE_DEBUG ((LM_DEBUG, "event loop finished\n"));
85 root_poa
->destroy (true, true);
89 catch (const CORBA::Exception
& ex
)
91 ex
._tao_print_exception ("Exception caught:");