3 #include "tao/Messaging/Messaging.h"
4 #include "tao/AnyTypeCode/Any.h"
5 #include "ace/Get_Opt.h"
7 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
8 bool shutdown_server
= false;
11 parse_args (int argc
, ACE_TCHAR
*argv
[])
13 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:s"));
16 while ((c
= get_opts ()) != -1)
20 ior
= get_opts
.opt_arg ();
23 shutdown_server
= true;
27 ACE_ERROR_RETURN ((LM_ERROR
,
35 // Indicates successful parsing of the command line
40 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
45 CORBA::ORB_init (argc
, argv
);
47 CORBA::Object_var poa_object
=
48 orb
->resolve_initial_references("RootPOA");
50 PortableServer::POA_var root_poa
=
51 PortableServer::POA::_narrow (poa_object
.in ());
53 if (CORBA::is_nil (root_poa
.in ()))
54 ACE_ERROR_RETURN ((LM_ERROR
,
55 " (%P|%t) Panic: nil RootPOA\n"),
58 PortableServer::POAManager_var poa_manager
=
59 root_poa
->the_POAManager ();
61 // Make all oneways "reliable."
63 CORBA::Object_var manager_object
=
64 orb
->resolve_initial_references("ORBPolicyManager");
65 CORBA::PolicyManager_var policy_manager
=
66 CORBA::PolicyManager::_narrow(manager_object
.in());
68 if (CORBA::is_nil (policy_manager
.in ()))
69 ACE_ERROR_RETURN ((LM_ERROR
,
70 " (%P|%t) Panic: nil PolicyManager\n"),
72 CORBA::Any policy_value
;
73 policy_value
<<= Messaging::SYNC_WITH_SERVER
;
74 CORBA::PolicyList
policies(1); policies
.length(1);
76 orb
->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE
,
79 policy_manager
->set_policy_overrides (policies
,
82 policies
[0]->destroy ();
85 if (parse_args (argc
, argv
) != 0)
88 CORBA::Object_var tmp
=
89 orb
->string_to_object(ior
);
91 Test::Service_var service
=
92 Test::Service::_narrow(tmp
.in ());
94 if (CORBA::is_nil (service
.in ()))
96 ACE_ERROR_RETURN ((LM_DEBUG
,
97 "Nil service reference <%s>\n",
102 Callback
*callback_impl
;
103 ACE_NEW_RETURN (callback_impl
,
106 PortableServer::ServantBase_var
owner_transfer(callback_impl
);
108 PortableServer::ObjectId_var id
=
109 root_poa
->activate_object (callback_impl
);
111 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
113 Test::Callback_var callback
=
114 Test::Callback::_narrow (object
.in ());
116 poa_manager
->activate ();
118 ACE_DEBUG ((LM_DEBUG
,
119 "(%P|%t) client - starting test\n"));
121 service
->run_test (callback
.in ());
123 ACE_DEBUG ((LM_DEBUG
,
124 "(%P|%t) client - running ORB\n"));
126 while (!callback_impl
->received_callback ())
128 orb
->perform_work ();
130 if (shutdown_server
) {
131 service
->shutdown ();
134 root_poa
->destroy (true, true);
138 catch (const CORBA::Exception
& ex
)
140 ex
._tao_print_exception ("Exception caught:");