2 #include "tao/Messaging/Messaging.h"
3 #include "tao/AnyTypeCode/Any.h"
4 #include "tao/ORB_Core.h"
5 #include "ace/Get_Opt.h"
7 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
8 bool do_shutdown
= false;
11 parse_args (int argc
, ACE_TCHAR
*argv
[]);
14 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
19 CORBA::ORB_init (argc
, argv
);
21 CORBA::Object_var poa_object
=
22 orb
->resolve_initial_references("RootPOA");
24 PortableServer::POA_var root_poa
=
25 PortableServer::POA::_narrow (poa_object
.in ());
27 if (CORBA::is_nil (root_poa
.in ()))
28 ACE_ERROR_RETURN ((LM_ERROR
,
29 " (%P|%t) Panic: nil RootPOA\n"),
32 PortableServer::POAManager_var poa_manager
=
33 root_poa
->the_POAManager ();
35 CORBA::Object_var object
=
36 orb
->resolve_initial_references ("PolicyCurrent");
38 CORBA::PolicyCurrent_var policy_current
=
39 CORBA::PolicyCurrent::_narrow (object
.in ());
41 if (CORBA::is_nil (policy_current
.in ()))
43 ACE_ERROR ((LM_ERROR
, "ERROR: Nil policy current\n"));
46 CORBA::Any scope_as_any
;
47 scope_as_any
<<= Messaging::SYNC_WITH_TRANSPORT
;
49 CORBA::PolicyList
policies(1); policies
.length (1);
51 orb
->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE
,
54 policy_current
->set_policy_overrides (policies
, CORBA::ADD_OVERRIDE
);
56 policies
[0]->destroy ();
58 if (parse_args (argc
, argv
) != 0)
61 PortableServer::Servant_var
<Echo
> impl
;
64 // ACE_NEW_RETURN is the worst possible way to handle
65 // exceptions (think: what if the constructor allocates memory
66 // and fails?), but I'm not in the mood to fight for a more
67 // reasonable way to handle allocation errors in ACE.
74 PortableServer::ObjectId_var id
=
75 root_poa
->activate_object (impl
.in ());
77 CORBA::Object_var object_act
= root_poa
->id_to_reference (id
.in ());
80 Test::Echo::_narrow (object_act
.in ());
82 CORBA::Object_var tmp
=
83 orb
->string_to_object(ior
);
85 Test::Echo_Caller_var server
=
86 Test::Echo_Caller::_narrow(tmp
.in ());
88 if (CORBA::is_nil (echo
.in ()))
90 ACE_ERROR_RETURN ((LM_DEBUG
,
91 "Nil Test::Echo_Caller reference <%s>\n",
102 poa_manager
->activate ();
104 server
->start_task(echo
.in());
108 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) client - event loop finished\n"));
110 // Actually the code here should never be reached.
111 root_poa
->destroy (true, true);
115 catch (const CORBA::Exception
& ex
)
117 ex
._tao_print_exception ("Exception caught:");
125 parse_args (int argc
, ACE_TCHAR
*argv
[])
127 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:x"));
130 while ((c
= get_opts ()) != -1)
134 ior
= get_opts
.opt_arg ();
143 ACE_ERROR_RETURN ((LM_ERROR
,
150 // Indicates successful parsing of the command line