1
// server.cpp,v 1.10 2003/11/04 08:13:00 dhinton Exp
3
//========================================================================
6
// TAO/tests/Smart_Proxy
12
// This is the server program that tests TAO's Smart Proxy extension.
15
// Kirthika Parameswaran <kirthika@cs.wustl.edu>
17
//=========================================================================
20
#include "ace/Get_Opt.h"
21
#include "ace/OS_NS_string.h"
23
ACE_RCSID(Smart_Proxy, server, "server.cpp,v 1.10 2003/11/04 08:13:00 dhinton Exp")
27
class Test_i : public POA_Test
30
Test_i (CORBA::ORB_ptr orb);
32
CORBA::Short method (CORBA::Short boo
34
ACE_THROW_SPEC ((CORBA::SystemException,
37
void shutdown (ACE_ENV_SINGLE_ARG_DECL)
38
ACE_THROW_SPEC ((CORBA::SystemException));
45
Test_i::Test_i (CORBA::ORB_ptr orb)
46
: orb_ (CORBA::ORB::_duplicate (orb))
51
Test_i :: method (CORBA::Short boo
53
ACE_THROW_SPEC ((CORBA::SystemException,
57
ACE_TEXT ("Test_i::method () invoked\n")));
59
ACE_THROW_RETURN (Test::Oops ("Invalid boo\n"),
66
Test_i::shutdown (ACE_ENV_SINGLE_ARG_DECL_NOT_USED)
67
ACE_THROW_SPEC ((CORBA::SystemException))
69
this->orb_->shutdown ();
72
static const char *ior_output_file = 0;
75
parse_args (int argc, char *argv[])
77
ACE_Get_Opt get_opts (argc, argv, "o:");
80
while ((c = get_opts ()) != -1)
84
ior_output_file = ACE_OS::strdup (get_opts.opt_arg ());
88
ACE_ERROR_RETURN ((LM_ERROR,
95
// Indicates sucessful parsing of the command line
100
main (int argc, char *argv[])
102
ACE_DECLARE_NEW_CORBA_ENV;
106
if (parse_args (argc, argv) != 0)
109
CORBA::ORB_var orb = CORBA::ORB_init (argc,
112
ACE_ENV_ARG_PARAMETER);
115
Test_i servant (orb.in ());
117
CORBA::Object_var object =
118
orb->resolve_initial_references ("RootPOA"
119
ACE_ENV_ARG_PARAMETER);
121
PortableServer::POA_var root_poa =
122
PortableServer::POA::_narrow (object.in ()
123
ACE_ENV_ARG_PARAMETER);
127
// Get the POAManager of the RootPOA.
128
PortableServer::POAManager_var poa_manager =
129
root_poa->the_POAManager (ACE_ENV_SINGLE_ARG_PARAMETER);
132
Test_var Test_object =
133
servant._this (ACE_ENV_SINGLE_ARG_PARAMETER);
136
CORBA::String_var ior =
137
orb->object_to_string (Test_object.in ()
138
ACE_ENV_ARG_PARAMETER);
140
// If the ior_output_file exists, output the ior to it
141
if (ior_output_file != 0)
144
ACE_OS::fopen (ior_output_file, "w");
146
if (output_file == 0)
147
ACE_ERROR_RETURN ((LM_ERROR,
148
"Cannot open output file for writing IOR: %s",
152
ACE_OS::fprintf (output_file,
155
ACE_OS::fclose (output_file);
158
poa_manager->activate (ACE_ENV_SINGLE_ARG_PARAMETER);
161
orb->run (ACE_ENV_SINGLE_ARG_PARAMETER);
164
ACE_DEBUG ((LM_DEBUG, "event loop finished\n"));
166
root_poa->destroy (1,
168
ACE_ENV_ARG_PARAMETER);
173
ACE_PRINT_EXCEPTION (ACE_ANY_EXCEPTION,
174
"Exception in setting up server");