2 #include "tao/IORManipulation/IORManip_Loader.h"
3 #include "ace/SString.h"
4 #include "ace/Get_Opt.h"
6 #include "tao/TimeBaseC.h"
7 #include "tao/Messaging/Messaging.h"
8 #include "tao/AnyTypeCode/Any.h"
10 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
13 const ACE_TCHAR
*name
= ACE_TEXT("file://amba.ior");
14 TimeBase::TimeT timeout_period
= 1000000;
17 parse_args (int argc
, ACE_TCHAR
*argv
[])
19 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("xk:m:"));
22 while ((c
= get_opts ()) != -1)
30 ior
= get_opts
.opt_arg ();
34 name
= get_opts
.opt_arg ();
39 ACE_ERROR_RETURN ((LM_ERROR
,
47 // Indicates successful parsing of the command line
52 run_test (Simple_Server_ptr server
);
55 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
60 CORBA::ORB_init (argc
, argv
);
62 if (parse_args (argc
, argv
) != 0)
66 CORBA::Object_var object_primary
=
67 orb
->string_to_object (ior
);
70 CORBA::Object_var object_secondary
=
71 orb
->string_to_object (name
);
73 // Get an object reference for the ORBs IORManipultion object!
74 CORBA::Object_var IORM
=
75 orb
->resolve_initial_references (TAO_OBJID_IORMANIPULATION
, 0);
77 TAO_IOP::TAO_IOR_Manipulation_var iorm
=
78 TAO_IOP::TAO_IOR_Manipulation::_narrow (IORM
.in ());
80 TAO_IOP::TAO_IOR_Manipulation::IORList
iors (2);
82 iors
[0] = object_primary
;
83 iors
[1] = object_secondary
;
85 CORBA::Object_var merged
= iorm
->merge_iors (iors
);
87 CORBA::Object_var object
=
88 orb
->resolve_initial_references ("PolicyCurrent");
90 CORBA::PolicyCurrent_var policy_current
=
91 CORBA::PolicyCurrent::_narrow (object
.in ());
93 CORBA::Any timeout_as_any
;
94 timeout_as_any
<<= timeout_period
;
96 CORBA::PolicyList
policy_list (1);
97 policy_list
.length (1);
100 orb
->create_policy (TAO::CONNECTION_TIMEOUT_POLICY_TYPE
,
103 policy_current
->set_policy_overrides (policy_list
,
104 CORBA::ADD_OVERRIDE
);
107 for (CORBA::ULong l
= 0;
108 l
!= policy_list
.length ();
111 policy_list
[l
]->destroy ();
114 // Combined IOR stuff
115 Simple_Server_var server
=
116 Simple_Server::_narrow (merged
.in ());
118 if (CORBA::is_nil (server
.in ()))
120 ACE_ERROR_RETURN ((LM_ERROR
,
121 "Object reference <%s> is nil.\n",
126 CORBA::ULongLong freq
=
127 run_test (server
.in ());
130 ACE_ERROR ((LM_ERROR
,
131 ACE_TEXT ("(%P|%t) ERROR in the test\n")));
133 ACE_DEBUG ((LM_DEBUG
,
134 ACE_TEXT ("(%P|%t) Shutting server down\n")));
138 catch (const CORBA::Exception
& ex
)
140 ex
._tao_print_exception ("Caught an exception\n");
148 run_test (Simple_Server_ptr server
)
150 return server
->remote_call ();