2 #include "tao/RTCORBA/RTCORBA.h"
3 #include "tao/Policy_ManagerC.h"
5 #include "ace/Condition_T.h"
6 #include "ace/OS_NS_time.h"
7 #include "ace/OS_NS_sys_time.h"
8 #include "ace/Thread.h"
9 #include "ace/Get_Opt.h"
11 TAO_SYNCH_MUTEX test_lock
;
12 ACE_Condition
<TAO_SYNCH_MUTEX
> cond (test_lock
);
16 const ACE_TCHAR
*ior
= ACE_TEXT ("corbaloc::localhost:5678/Test");
19 parse_args (int argc
, ACE_TCHAR
*argv
[])
21 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
24 while ((c
= get_opts ()) != -1)
28 ior
= get_opts
.opt_arg ();
33 ACE_ERROR_RETURN ((LM_ERROR
,
40 // Indicates successful parsing of the command line
44 ACE_THR_FUNC_RETURN
failsafe (void *)
47 ACE_Time_Value timeout
= ACE_OS::gettimeofday() + ACE_Time_Value (10,0);
52 ACE_DEBUG ((LM_DEBUG
, "FAILURE: failsafe timed out\n"));
60 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
64 orb
= CORBA::ORB_init (argc
, argv
);
65 CORBA::Object_var object
=
66 orb
->resolve_initial_references ("RTORB");
68 RTCORBA::RTORB_var rt_orb
=
69 RTCORBA::RTORB::_narrow (object
.in ());
71 // Set the tcp protocol properties
72 RTCORBA::TCPProtocolProperties_var tcp_properties
=
73 rt_orb
->create_tcp_protocol_properties (ACE_DEFAULT_MAX_SOCKET_BUFSIZ
,
74 ACE_DEFAULT_MAX_SOCKET_BUFSIZ
,
76 RTCORBA::ProtocolList protocols
;
78 protocols
[0].protocol_type
= 0;
79 protocols
[0].transport_protocol_properties
=
80 RTCORBA::ProtocolProperties::_duplicate (tcp_properties
.in ());
81 protocols
[0].orb_protocol_properties
=
82 RTCORBA::ProtocolProperties::_nil ();
84 CORBA::PolicyList policy_list
;
86 policy_list
.length (1);
88 rt_orb
->create_client_protocol_policy (protocols
);
89 object
= orb
->resolve_initial_references ("ORBPolicyManager");
91 CORBA::PolicyManager_var policy_manager
=
92 CORBA::PolicyManager::_narrow (object
.in ());
94 policy_manager
->set_policy_overrides (policy_list
,
97 // start the failsafe thread. It will expire in 10 seconds and
98 // terminate with a failure if the following does not complete.
100 ACE_Thread::spawn (failsafe
);
102 object
= orb
->string_to_object ("corbaloc::localhost:5678/Test");
103 Test::Hello_var hello
= Test::Hello::_narrow(object
.in());
106 test_lock
.acquire ();
108 test_lock
.release ();
109 ACE_DEBUG ((LM_DEBUG
, "SUCCESS: test did not spin.\n"));
111 CORBA::String_var the_string
= hello
->get_string ();
113 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) - string returned <%C>\n",
119 catch (const CORBA::Exception
& ex
)
121 ex
._tao_print_exception ("Exception caught:");