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
[])
71 // Initialize the ORB.
73 CORBA::ORB_init (argc
, argv
);
75 // Initialize options based on command-line arguments.
76 int parse_args_result
= parse_args (argc
, argv
);
77 if (parse_args_result
!= 0)
78 return parse_args_result
;
80 CORBA::Object_var object
=
81 orb
->resolve_initial_references ("RootPOA");
83 PortableServer::POA_var root_poa
=
84 PortableServer::POA::_narrow (object
.in ());
86 PortableServer::POAManager_var poa_manager
=
87 root_poa
->the_POAManager ();
89 poa_manager
->activate ();
91 // Get an object reference from the argument string.
92 object
= orb
->string_to_object (IOR
);
94 // Try to narrow the object reference to a <server> reference.
95 server_var server_object
= server::_narrow (object
.in ());
97 client_i
* servant
= 0;
98 ACE_NEW_RETURN (servant
,
99 client_i(server_object
.in ()),
101 PortableServer::ServantBase_var
client_transfer(servant
);
103 servant
->loop (event_loop_depth
,
104 event_loop_iterations
);
109 server_object
->shutdown ();
112 root_poa
->destroy (true, true);
114 catch (const CORBA::Exception
& ex
)
116 ex
._tao_print_exception ("Exception caught:");