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
method (CORBA::Short boo
);
26 //FUZZ: disable check_for_lack_ACE_OS
27 ///FUZZ: enable check_for_lack_ACE_OS
34 Test_i::Test_i (CORBA::ORB_ptr orb
)
35 : orb_ (CORBA::ORB::_duplicate (orb
))
40 Test_i :: method (CORBA::Short boo
)
43 ACE_TEXT ("Test_i::method () invoked\n")));
45 throw Test::Oops ("Invalid boo\n");
53 this->orb_
->shutdown (false);
56 static const ACE_TCHAR
*ior_output_file
= 0;
59 parse_args (int argc
, ACE_TCHAR
*argv
[])
61 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
64 while ((c
= get_opts ()) != -1)
68 ior_output_file
= get_opts
.opt_arg ();
72 ACE_ERROR_RETURN ((LM_ERROR
,
79 // Indicates successful parsing of the command line
84 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
88 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
90 if (parse_args (argc
, argv
) != 0)
93 Test_i
servant (orb
.in ());
95 CORBA::Object_var object
=
96 orb
->resolve_initial_references ("RootPOA");
98 PortableServer::POA_var root_poa
=
99 PortableServer::POA::_narrow (object
.in ());
101 // Get the POAManager of the RootPOA.
102 PortableServer::POAManager_var poa_manager
=
103 root_poa
->the_POAManager ();
105 PortableServer::ObjectId_var id
=
106 root_poa
->activate_object (&servant
);
108 CORBA::Object_var object_act
= root_poa
->id_to_reference (id
.in ());
110 Test_var Test_object
=
111 Test::_narrow (object_act
.in ());
113 CORBA::String_var ior
=
114 orb
->object_to_string (Test_object
.in ());
116 // If the ior_output_file exists, output the ior to it
117 if (ior_output_file
!= 0)
120 ACE_OS::fopen (ior_output_file
, "w");
122 if (output_file
== 0)
123 ACE_ERROR_RETURN ((LM_ERROR
,
124 "Cannot open output file for writing IOR: %s",
128 ACE_OS::fprintf (output_file
,
131 ACE_OS::fclose (output_file
);
134 poa_manager
->activate ();
138 ACE_DEBUG ((LM_DEBUG
,
139 "event loop finished\n"));
141 root_poa
->destroy (true, true);
145 catch (const CORBA::Exception
& ex
)
147 ex
._tao_print_exception ("Exception in setting up server");