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");
10 parse_args (int argc
, ACE_TCHAR
*argv
[])
12 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
15 while ((c
= get_opts ()) != -1)
19 ior
= get_opts
.opt_arg ();
23 ACE_ERROR_RETURN ((LM_ERROR
,
30 // Indicates successful parsing of the command line
35 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
40 CORBA::ORB_init (argc
, argv
);
42 CORBA::Object_var poa_object
=
43 orb
->resolve_initial_references("RootPOA");
45 PortableServer::POA_var root_poa
=
46 PortableServer::POA::_narrow (poa_object
.in ());
48 if (CORBA::is_nil (root_poa
.in ()))
49 ACE_ERROR_RETURN ((LM_ERROR
,
50 " (%P|%t) Panic: nil RootPOA\n"),
53 PortableServer::POAManager_var poa_manager
=
54 root_poa
->the_POAManager ();
56 // Make all oneways "reliable."
58 CORBA::Object_var manager_object
=
59 orb
->resolve_initial_references("ORBPolicyManager");
60 CORBA::PolicyManager_var policy_manager
=
61 CORBA::PolicyManager::_narrow(manager_object
.in());
63 if (CORBA::is_nil (policy_manager
.in ()))
64 ACE_ERROR_RETURN ((LM_ERROR
,
65 " (%P|%t) Panic: nil PolicyManager\n"),
67 CORBA::Any policy_value
;
68 policy_value
<<= Messaging::SYNC_WITH_SERVER
;
69 CORBA::PolicyList
policies(1); policies
.length(1);
71 orb
->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE
,
74 policy_manager
->set_policy_overrides (policies
,
77 policies
[0]->destroy ();
80 if (parse_args (argc
, argv
) != 0)
83 CORBA::Object_var tmp
=
84 orb
->string_to_object(ior
);
86 Test::Service_var service
=
87 Test::Service::_narrow(tmp
.in ());
89 if (CORBA::is_nil (service
.in ()))
91 ACE_ERROR_RETURN ((LM_DEBUG
,
92 "Nil service reference <%s>\n",
97 Callback
*callback_impl
;
98 ACE_NEW_RETURN (callback_impl
,
101 PortableServer::ServantBase_var
owner_transfer(callback_impl
);
103 PortableServer::ObjectId_var id
=
104 root_poa
->activate_object (callback_impl
);
106 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
108 Test::Callback_var callback
=
109 Test::Callback::_narrow (object
.in ());
111 poa_manager
->activate ();
113 ACE_DEBUG ((LM_DEBUG
,
114 "(%P|%t) client - starting test\n"));
116 service
->run_test (callback
.in ());
118 ACE_DEBUG ((LM_DEBUG
,
119 "(%P|%t) client - running ORB\n"));
123 root_poa
->destroy (true, true);
127 catch (const CORBA::Exception
& ex
)
129 ex
._tao_print_exception ("Exception caught:");