1 #include "ace/Get_Opt.h"
2 #include "ace/Read_Buffer.h"
5 #include "tao/Strategies/advanced_resource.h"
7 // Name of file contains ior.
8 static const ACE_TCHAR
*IOR
= ACE_TEXT ("file://ior");
10 // Default event_loop_depth.
11 static CORBA::ULong event_loop_depth
= 6;
13 // Default event_loop_iterations.
14 static CORBA::ULong event_loop_iterations
= 6;
16 // Flag indicates whether to shutdown remote server or not upon client
18 static int shutdown_server
= 0;
21 parse_args (int argc
, ACE_TCHAR
**argv
)
23 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:d:i:x"));
26 while ((c
= get_opts ()) != -1)
30 IOR
= get_opts
.opt_arg ();
34 event_loop_iterations
= ACE_OS::atoi (get_opts
.opt_arg ());
38 event_loop_depth
= ACE_OS::atoi (get_opts
.opt_arg ());
47 ACE_ERROR_RETURN ((LM_ERROR
,
50 "-i event loop iterations "
51 "-d event loop depth "
59 ACE_ERROR_RETURN ((LM_ERROR
,
60 "Please specify the IOR for the servant\n"), -1);
62 // Indicates successful parsing of command line.
67 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
72 // Initialize the ORB.
74 CORBA::ORB_init (argc
, argv
);
76 // Initialize options based on command-line arguments.
77 int parse_args_result
= parse_args (argc
, argv
);
78 if (parse_args_result
!= 0)
79 return parse_args_result
;
81 CORBA::Object_var object
=
82 orb
->resolve_initial_references ("RootPOA");
84 PortableServer::POA_var root_poa
=
85 PortableServer::POA::_narrow (object
.in ());
87 PortableServer::POAManager_var poa_manager
=
88 root_poa
->the_POAManager ();
90 poa_manager
->activate ();
92 // Get an object reference from the argument string.
93 object
= orb
->string_to_object (IOR
);
95 // Try to narrow the object reference to a <server> reference.
96 server_var server_object
= server::_narrow (object
.in ());
98 client_i
* servant
= 0;
99 ACE_NEW_RETURN (servant
,
100 client_i(server_object
.in ()),
102 PortableServer::ServantBase_var
client_transfer(servant
);
104 servant
->loop (event_loop_depth
,
105 event_loop_iterations
);
110 server_object
->shutdown ();
113 root_poa
->destroy (1,
116 catch (const CORBA::Exception
& ex
)
118 ex
._tao_print_exception ("Exception caught:");