2 #include "ace/OS_NS_stdio.h"
3 #include "ace/Get_Opt.h"
5 const ACE_TCHAR
*ior_output_file
= ACE_TEXT ("server.ior");
8 parse_args (int argc
, ACE_TCHAR
*argv
[])
10 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
13 while ((c
= get_opts ()) != -1)
17 ior_output_file
= get_opts
.opt_arg ();
22 ACE_ERROR_RETURN ((LM_ERROR
,
29 // Indicates successful parsing of the command line
33 class foo_i
: public POA_foo
36 foo_i (CORBA::ORB_ptr orb
)
37 : orb_ (CORBA::ORB::_duplicate (orb
)) {
40 //FUZZ: disable check_for_lack_ACE_OS
42 //FUZZ: enable check_for_lack_ACE_OS
53 this->orb_
->shutdown ();
59 bool expected_exception_raised
= false;
63 // This should case an BAD_INV_ORDER exception
64 this->orb_
->destroy ();
66 catch (const CORBA::BAD_INV_ORDER
& ex
)
68 if ((ex
.minor() & 0xFFFU
) == 3)
70 expected_exception_raised
= true;
74 if (!expected_exception_raised
)
75 ACE_ERROR ((LM_ERROR
, "ERROR: Caught incorrect exception\n"));
77 ACE_DEBUG ((LM_DEBUG
, "Caught correct exception\n"));
82 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
86 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
88 if (parse_args (argc
, argv
) != 0)
91 CORBA::Object_var poa_object
=
92 orb
->resolve_initial_references("RootPOA");
94 PortableServer::POA_var root_poa
=
95 PortableServer::POA::_narrow (poa_object
.in ());
97 if (CORBA::is_nil (root_poa
.in ()))
98 ACE_ERROR_RETURN ((LM_ERROR
,
99 " (%P|%t) Panic: nil RootPOA\n"),
102 PortableServer::POAManager_var poa_manager
=
103 root_poa
->the_POAManager ();
105 foo_i
* server_impl
= 0;
106 ACE_NEW_RETURN (server_impl
,
109 PortableServer::ServantBase_var
owner_transfer(server_impl
);
111 PortableServer::ObjectId_var id
=
112 root_poa
->activate_object (server_impl
);
114 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
116 foo_var server
= foo::_narrow (object
.in ());
118 CORBA::String_var ior
=
119 orb
->object_to_string (server
.in ());
121 // Output the IOR to the <ior_output_file>
122 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
123 if (output_file
== 0)
124 ACE_ERROR_RETURN ((LM_ERROR
,
125 "Cannot open output file for writing IOR: %s",
128 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
129 ACE_OS::fclose (output_file
);
131 poa_manager
->activate ();
135 root_poa
->destroy (true, true);
138 catch (const CORBA::Exception
& ex
)
140 ex
._tao_print_exception ("CORBA::Exception");