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
[])
61 CORBA::ORB_init (argc
, argv
);
63 if (parse_args (argc
, argv
) != 0)
67 CORBA::Object_var object_primary
=
68 orb
->string_to_object (ior
);
71 CORBA::Object_var object_secondary
=
72 orb
->string_to_object (name
);
74 // Get an object reference for the ORBs IORManipultion object!
75 CORBA::Object_var IORM
=
76 orb
->resolve_initial_references (TAO_OBJID_IORMANIPULATION
, 0);
78 TAO_IOP::TAO_IOR_Manipulation_var iorm
=
79 TAO_IOP::TAO_IOR_Manipulation::_narrow (IORM
.in ());
81 TAO_IOP::TAO_IOR_Manipulation::IORList
iors (2);
83 iors
[0] = object_primary
;
84 iors
[1] = object_secondary
;
86 CORBA::Object_var merged
= iorm
->merge_iors (iors
);
88 CORBA::Object_var object
=
89 orb
->resolve_initial_references ("PolicyCurrent");
91 CORBA::PolicyCurrent_var policy_current
=
92 CORBA::PolicyCurrent::_narrow (object
.in ());
94 CORBA::Any timeout_as_any
;
95 timeout_as_any
<<= timeout_period
;
97 CORBA::PolicyList
policy_list (1);
98 policy_list
.length (1);
101 orb
->create_policy (TAO::CONNECTION_TIMEOUT_POLICY_TYPE
,
104 policy_current
->set_policy_overrides (policy_list
,
105 CORBA::ADD_OVERRIDE
);
108 for (CORBA::ULong l
= 0;
109 l
!= policy_list
.length ();
112 policy_list
[l
]->destroy ();
115 // Combined IOR stuff
116 Simple_Server_var server
=
117 Simple_Server::_narrow (merged
.in ());
119 if (CORBA::is_nil (server
.in ()))
121 ACE_ERROR_RETURN ((LM_ERROR
,
122 "Object reference <%s> is nil.\n",
127 CORBA::ULongLong freq
=
128 run_test (server
.in ());
131 ACE_ERROR ((LM_ERROR
,
132 ACE_TEXT ("(%P|%t) ERROR in the test\n")));
134 ACE_DEBUG ((LM_DEBUG
,
135 ACE_TEXT ("(%P|%t) Shutting server down\n")));
139 catch (const CORBA::Exception
& ex
)
141 ex
._tao_print_exception ("Caught an exception\n");
149 run_test (Simple_Server_ptr server
)
151 return server
->remote_call ();