2 #include "tao/PortableServer/PortableServer.h"
3 #include "tao/ImR_Client/ImR_Client.h"
4 #include "ace/Get_Opt.h"
5 #include "ace/Argv_Type_Converter.h"
7 #include "bug_689_regression_i.h"
9 const ACE_TCHAR
*ior_output_file
= ACE_TEXT ("server.ior");
12 parse_args (int argc
, ACE_TCHAR
*argv
[])
14 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT ("o:"));
17 while ((c
= get_opts ()) != -1)
21 ior_output_file
= get_opts
.opt_arg ();
26 ACE_ERROR_RETURN ((LM_ERROR
,
33 // Indicates successful parsing of the command line
38 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
42 ACE_Argv_Type_Converter
argcon (argc
, argv
);
43 CORBA::ORB_var orb
= CORBA::ORB_init (argcon
.get_argc (),
44 argcon
.get_TCHAR_argv ());
46 if (parse_args (argc
, argv
) != 0)
49 CORBA::Object_var poa_object
=
50 orb
->resolve_initial_references ("RootPOA");
52 PortableServer::POA_var root_poa
=
53 PortableServer::POA::_narrow (poa_object
.in ());
55 if (CORBA::is_nil (root_poa
.in ()))
56 ACE_ERROR_RETURN ((LM_ERROR
,
57 " (%P|%t) Panic: nil RootPOA\n"),
60 PortableServer::POAManager_var poa_manager
=
61 root_poa
->the_POAManager ();
63 CORBA::PolicyList
policies (5);
66 root_poa
->create_id_assignment_policy (PortableServer::USER_ID
);
69 root_poa
->create_lifespan_policy (PortableServer::PERSISTENT
);
72 root_poa
->create_request_processing_policy (
73 PortableServer::USE_DEFAULT_SERVANT
);
76 root_poa
->create_servant_retention_policy (
77 PortableServer::NON_RETAIN
);
80 root_poa
->create_id_uniqueness_policy (
81 PortableServer::MULTIPLE_ID
);
83 PortableServer::POA_var new_poa
=
84 root_poa
->create_POA ("test_server",
88 for (CORBA::ULong i
= 0; i
< policies
.length (); ++i
)
90 policies
[i
]->destroy ();
93 PortableServer::ObjectId_var id
=
94 PortableServer::string_to_ObjectId ("server");
96 CORBA::Object_var object
=
97 new_poa
->create_reference_with_id (id
.in (),
98 "IDL:bug_689_regression:1.0");
100 bug_689_regression_var bug_689_regression
=
101 bug_689_regression::_unchecked_narrow (object
.in ());
103 bug_689_regression_i
impl (orb
.in ());
104 new_poa
->set_servant (&impl
);
106 poa_manager
->activate ();
108 CORBA::String_var ior
= orb
->object_to_string (bug_689_regression
.in ());
110 // Output the IOR to the <ior_output_file>
111 FILE *output_file
= ACE_OS::fopen (ior_output_file
, ACE_TEXT ("w"));
112 if (output_file
== 0)
113 ACE_ERROR_RETURN ((LM_ERROR
,
114 ACE_TEXT ("Cannot open output file for writing IOR: %s\n"),
117 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
118 ACE_OS::fclose (output_file
);
123 catch (const CORBA::Exception
& ex
)
125 ex
._tao_print_exception ("Exception caught:");