2 //=============================================================================
6 * This is the server program that tests TAO's Smart Proxy extension.
8 * @author Kirthika Parameswaran <kirthika@cs.wustl.edu>
10 //=============================================================================
14 #include "ace/Get_Opt.h"
15 #include "ace/OS_NS_string.h"
19 class Test_i
: public POA_Test
22 Test_i (CORBA::ORB_ptr orb
);
24 CORBA::Short
box_prices (void);
26 CORBA::Long
tickets (CORBA::Short number
);
28 //FUZZ: disable check_for_lack_ACE_OS
29 ///FUZZ: enable check_for_lack_ACE_OS
37 Test_i::Test_i (CORBA::ORB_ptr orb
)
38 : orb_ (CORBA::ORB::_duplicate (orb
))
43 Test_i::box_prices (void)
49 Test_i::tickets (CORBA::Short number
)
55 Test_i::shutdown (void)
57 this->orb_
->shutdown (0);
60 static const ACE_TCHAR
*ior_output_file
= 0;
63 parse_args (int argc
, ACE_TCHAR
*argv
[])
65 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
68 while ((c
= get_opts ()) != -1)
72 ior_output_file
= get_opts
.opt_arg ();
76 ACE_ERROR_RETURN ((LM_ERROR
,
83 // Indicates successful parsing of the command line
88 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
93 CORBA::ORB_var orb
= CORBA::ORB_init (argc
,
95 if (parse_args (argc
, argv
) != 0)
98 Test_i
servant (orb
.in ());
100 CORBA::Object_var object
=
101 orb
->resolve_initial_references ("RootPOA");
103 PortableServer::POA_var root_poa
=
104 PortableServer::POA::_narrow (object
.in ());
107 // Get the POAManager of the RootPOA.
108 PortableServer::POAManager_var poa_manager
=
109 root_poa
->the_POAManager ();
111 PortableServer::ObjectId_var id
=
112 root_poa
->activate_object (&servant
);
114 CORBA::Object_var object_act
= root_poa
->id_to_reference (id
.in ());
116 Test_var Test_object
=
117 Test::_narrow (object_act
.in ());
119 CORBA::String_var ior
=
120 orb
->object_to_string (Test_object
.in ());
122 // If the ior_output_file exists, output the ior to it
123 if (ior_output_file
!= 0)
126 ACE_OS::fopen (ior_output_file
, "w");
128 if (output_file
== 0)
129 ACE_ERROR_RETURN ((LM_ERROR
,
130 "Cannot open output file for writing IOR: %s",
134 ACE_OS::fprintf (output_file
,
137 ACE_OS::fclose (output_file
);
140 poa_manager
->activate ();
144 ACE_DEBUG ((LM_DEBUG
,
145 "event loop finished\n"));
147 root_poa
->destroy (true, true);
151 catch (const CORBA::Exception
& ex
)
153 ex
._tao_print_exception ("Exception in setting up server");