2 #include "ace/Get_Opt.h"
4 #include "tao/Strategies/advanced_resource.h"
5 #include "tao/RTCORBA/RTCORBA.h"
6 #include "tao/RTPortableServer/RTPortableServer.h"
8 class Test_i
: public POA_Test
11 // An implementation for the Test interface in test.idl
14 Test_i (CORBA::ORB_ptr orb
);
17 // = The Test methods.
20 //FUZZ: disable check_for_lack_ACE_OS
22 //FUZZ: enable check_for_lack_ACE_OS
29 Test_i::Test_i (CORBA::ORB_ptr orb
)
30 : orb_ (CORBA::ORB::_duplicate (orb
))
35 Test_i::test_method (/* */)
38 "Server: test_method invoked.\n"));
44 this->orb_
->shutdown (false);
47 //*************************************************************************
49 const ACE_TCHAR
*ior_output_file
= ACE_TEXT("test.ior");
51 // Parse command-line arguments.
53 parse_args (int argc
, ACE_TCHAR
*argv
[])
55 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
58 while ((c
= get_opts ()) != -1)
62 ior_output_file
= get_opts
.opt_arg ();
67 ACE_ERROR_RETURN ((LM_ERROR
,
79 check_for_nil (CORBA::Object_ptr obj
, const char *msg
)
81 if (CORBA::is_nil (obj
))
82 ACE_ERROR_RETURN ((LM_ERROR
,
83 "ERROR: Object reference <%C> is nil\n",
91 create_object (PortableServer::POA_ptr poa
,
94 const ACE_TCHAR
*filename
)
97 PortableServer::ObjectId_var id
=
98 poa
->activate_object (server_impl
);
101 CORBA::Object_var server
=
102 poa
->id_to_reference (id
.in ());
104 // Print out the IOR.
105 CORBA::String_var ior
=
106 orb
->object_to_string (server
.in ());
108 ACE_DEBUG ((LM_DEBUG
, "<%C>\n\n", ior
.in ()));
110 // Print ior to the file.
113 FILE *output_file
= ACE_OS::fopen (filename
, "w");
114 if (output_file
== 0)
115 ACE_ERROR_RETURN ((LM_ERROR
,
116 "Cannot open output file for writing IOR: %s",
119 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
120 ACE_OS::fclose (output_file
);
127 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
133 CORBA::ORB_init (argc
, argv
);
136 if (parse_args (argc
, argv
) != 0)
140 CORBA::Object_var object
=
141 orb
->resolve_initial_references("RootPOA");
142 PortableServer::POA_var root_poa
=
143 PortableServer::POA::_narrow (object
.in ());
144 if (check_for_nil (root_poa
.in (), "RootPOA") == -1)
148 PortableServer::POAManager_var poa_manager
=
149 root_poa
->the_POAManager ();
152 Test_i
server_impl (orb
.in ());
156 result
= create_object (root_poa
.in (),
163 // Run ORB Event loop.
164 poa_manager
->activate ();
168 ACE_DEBUG ((LM_DEBUG
, "Server ORB event loop finished\n"));
170 catch (const CORBA::Exception
& ex
)
172 ex
._tao_print_exception (
173 "Unexpected exception caught in Explicit_Binding test server:");