2 #include "Backend_Impl.h"
3 #include "tao/Strategies/advanced_resource.h"
4 #include "ace/Get_Opt.h"
5 #include "ace/OS_NS_stdio.h"
7 const ACE_TCHAR
*ior_output_file
= ACE_TEXT ("backend.ior");
11 parse_args (int argc
, ACE_TCHAR
*argv
[])
13 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("vo:"));
16 while ((c
= get_opts ()) != -1)
20 ior_output_file
= get_opts
.opt_arg ();
29 ACE_ERROR_RETURN ((LM_ERROR
,
30 ACE_TEXT("usage: %s ")
31 ACE_TEXT("-o <iorfile>")
36 // Indicates successful parsing of the command line
41 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
46 CORBA::ORB_init (argc
, argv
);
48 CORBA::Object_var poa_object
=
49 orb
->resolve_initial_references("RootPOA");
51 PortableServer::POA_var root_poa
=
52 PortableServer::POA::_narrow (poa_object
.in ());
54 if (CORBA::is_nil (root_poa
.in ()))
56 ACE_ERROR_RETURN ((LM_ERROR
,
57 "backend_server(%P|%t) - panic: nil RootPOA\n"),
61 PortableServer::POAManager_var poa_manager
= root_poa
->the_POAManager ();
63 if (parse_args (argc
, argv
) != 0)
66 using namespace Bug_3647_Regression
;
67 PortableServer::ServantBase_var
impl(
68 new Backend_Impl(orb
.in(), verbose
));
70 PortableServer::ObjectId_var id
=
71 root_poa
->activate_object (impl
.in());
73 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
75 Bug_3647_Regression::Backend_var backend
=
76 Bug_3647_Regression::Backend::_narrow (object
.in ());
78 CORBA::String_var ior
= orb
->object_to_string (backend
.in ());
80 // Output the IOR to the <ior_output_file>
81 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
84 ACE_ERROR_RETURN ((LM_ERROR
,
85 "backend_server(%P|%) - cannot open output file "
86 "for writing IOR: %s\n",
90 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
91 ACE_OS::fclose (output_file
);
93 poa_manager
->activate ();
97 ACE_DEBUG ((LM_DEBUG
, "backend_server(%P|%t) - event loop finished\n"));
99 root_poa
->destroy (true, true);
103 catch (const CORBA::Exception
& ex
)
105 ACE_DEBUG ((LM_DEBUG
,
107 ex
._tao_print_exception ("Exception caught:");