3 #include "tao/Messaging/Messaging.h"
4 #include "tao/AnyTypeCode/Any.h"
5 #include "tao/ORB_Core.h"
6 #include "ace/Get_Opt.h"
7 #include "ace/Reactor.h"
9 const ACE_TCHAR
*ior
= ACE_TEXT("file://test.ior");
12 parse_args (int argc
, ACE_TCHAR
*argv
[]);
14 class Crasher
: public ACE_Event_Handler
19 virtual int handle_timeout (ACE_Time_Value
const & current_time
,
24 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
29 CORBA::ORB_init (argc
, argv
);
31 CORBA::Object_var poa_object
=
32 orb
->resolve_initial_references("RootPOA");
34 PortableServer::POA_var root_poa
=
35 PortableServer::POA::_narrow (poa_object
.in ());
37 if (CORBA::is_nil (root_poa
.in ()))
38 ACE_ERROR_RETURN ((LM_ERROR
,
39 " (%P|%t) Panic: nil RootPOA\n"),
42 PortableServer::POAManager_var poa_manager
=
43 root_poa
->the_POAManager ();
45 CORBA::Object_var object
=
46 orb
->resolve_initial_references ("PolicyCurrent");
48 CORBA::PolicyCurrent_var policy_current
=
49 CORBA::PolicyCurrent::_narrow (object
.in ());
51 if (CORBA::is_nil (policy_current
.in ()))
53 ACE_ERROR ((LM_ERROR
, "ERROR: Nil policy current\n"));
56 CORBA::Any scope_as_any
;
57 scope_as_any
<<= Messaging::SYNC_WITH_TRANSPORT
;
59 CORBA::PolicyList
policies(1); policies
.length (1);
61 orb
->create_policy (Messaging::SYNC_SCOPE_POLICY_TYPE
,
64 policy_current
->set_policy_overrides (policies
, CORBA::ADD_OVERRIDE
);
66 policies
[0]->destroy ();
68 if (parse_args (argc
, argv
) != 0)
71 PortableServer::Servant_var
<Echo
> impl
;
74 // ACE_NEW_RETURN is the worst possible way to handle
75 // exceptions (think: what if the constructor allocates memory
76 // and fails?), but I'm not in the mood to fight for a more
77 // reasonable way to handle allocation errors in ACE.
84 PortableServer::ObjectId_var id
=
85 root_poa
->activate_object (impl
.in ());
87 CORBA::Object_var object_act
= root_poa
->id_to_reference (id
.in ());
90 Test::Echo::_narrow (object_act
.in ());
92 CORBA::Object_var tmp
=
93 orb
->string_to_object(ior
);
95 Test::Server_var server
=
96 Test::Server::_narrow(tmp
.in ());
98 if (CORBA::is_nil (echo
.in ()))
100 ACE_ERROR_RETURN ((LM_DEBUG
,
101 "Nil Test::Server reference <%s>\n",
106 poa_manager
->activate ();
110 // Crash after 15 seconds
111 ACE_Time_Value
interval(15, 0);
112 ACE_Reactor
* reactor
= orb
->orb_core()->reactor();
113 reactor
->schedule_timer(&crasher
, 0, interval
, interval
);
115 ORB_Task
task(orb
.in());
116 task
.activate(THR_NEW_LWP
| THR_JOINABLE
, 4, 1);
118 Test::Payload
payload(16); payload
.length(16);
119 for(int i
= 0; i
!= 4; ++i
)
121 server
->start_task(echo
.in());
126 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) client - event loop finished\n"));
128 root_poa
->destroy (true, true);
132 catch (const CORBA::Exception
& ex
)
134 ex
._tao_print_exception ("Exception caught:");
142 parse_args (int argc
, ACE_TCHAR
*argv
[])
144 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
147 while ((c
= get_opts ()) != -1)
151 ior
= get_opts
.opt_arg ();
156 ACE_ERROR_RETURN ((LM_ERROR
,
163 // Indicates successful parsing of the command line
172 Crasher::handle_timeout (ACE_Time_Value
const & ,