2 #include "tao/RTCORBA/RTCORBA.h"
3 #include "tao/RTPortableServer/RTPortableServer.h"
4 #include "ace/Get_Opt.h"
5 #include "ace/OS_NS_stdio.h"
7 class Test_i
: public POA_Test
10 // An implementation for the Test interface in test.idl
13 Test_i (CORBA::ORB_ptr orb
);
16 // = The Test methods.
19 //FUZZ: disable check_for_lack_ACE_OS
21 //FUZZ: enable check_for_lack_ACE_OS
28 Test_i::Test_i (CORBA::ORB_ptr orb
)
29 : orb_ (CORBA::ORB::_duplicate (orb
))
34 Test_i::test_method (/* */)
37 "Server: test_method invoked.\n"));
43 this->orb_
->shutdown (false);
46 //*************************************************************************
48 const ACE_TCHAR
*ior_output_file1
= ACE_TEXT("test1.ior");
49 const ACE_TCHAR
*ior_output_file2
= ACE_TEXT("test2.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:p:"));
58 while ((c
= get_opts ()) != -1)
62 ior_output_file1
= get_opts
.opt_arg ();
66 ior_output_file2
= get_opts
.opt_arg ();
71 ACE_ERROR_RETURN ((LM_ERROR
,
84 check_for_nil (CORBA::Object_ptr obj
, const char *msg
)
86 if (CORBA::is_nil (obj
))
87 ACE_ERROR_RETURN ((LM_ERROR
,
88 "ERROR: Object reference <%C> is nil\n",
96 create_object (PortableServer::POA_ptr poa
,
99 const ACE_TCHAR
*filename
)
101 // Register with poa.
102 PortableServer::ObjectId_var id
=
103 poa
->activate_object (server_impl
);
106 CORBA::Object_var server
=
107 poa
->id_to_reference (id
.in ());
109 // Print out the IOR.
110 CORBA::String_var ior
=
111 orb
->object_to_string (server
.in ());
113 ACE_DEBUG ((LM_DEBUG
, "<%C>\n\n", ior
.in ()));
115 // Print ior to the file.
118 FILE *output_file
= ACE_OS::fopen (filename
, "w");
119 if (output_file
== 0)
120 ACE_ERROR_RETURN ((LM_ERROR
,
121 "Cannot open output file for writing IOR: %s",
124 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
125 ACE_OS::fclose (output_file
);
132 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
138 CORBA::ORB_init (argc
, argv
);
141 if (parse_args (argc
, argv
) != 0)
145 CORBA::Object_var object
=
146 orb
->resolve_initial_references("RootPOA");
147 PortableServer::POA_var root_poa
=
148 PortableServer::POA::_narrow (object
.in ());
149 if (check_for_nil (root_poa
.in (), "RootPOA") == -1)
153 PortableServer::POAManager_var poa_manager
=
154 root_poa
->the_POAManager ();
157 Test_i
server_impl1 (orb
.in ());
158 Test_i
server_impl2 (orb
.in ());
162 result
= create_object (root_poa
.in (),
169 result
= create_object (root_poa
.in (),
176 // Run ORB Event loop.
177 poa_manager
->activate ();
181 ACE_DEBUG ((LM_DEBUG
, "Server ORB event loop finished\n"));
183 catch (const CORBA::Exception
& ex
)
185 ex
._tao_print_exception (
186 "Unexpected exception caught in Private_Connection test server:");