1 #include "ace/Get_Opt.h"
2 #include "tao/Messaging/Messaging.h"
6 : public POA_AMI_ChildHandler
10 : parentMethod_count (0),
11 parentMethod_excep_count (0)
21 childMethod_excep (Messaging::ExceptionHolder
*
26 excep_holder
->raise_exception ();
28 catch (const CORBA::SystemException
& ex
)
30 ex
._tao_print_exception ("Reply_Handler::childMethod_excep: ");
38 "client: parentMethod reply %d @ %T\n",
39 ++parentMethod_count
));
43 parentMethod_excep (Messaging::ExceptionHolder
* excep_holder
)
47 ++parentMethod_excep_count
;
48 excep_holder
->raise_exception ();
50 catch (const CORBA::INTERNAL
&)
52 ACE_DEBUG ((LM_DEBUG
, "Successfully received an Internal Excep*ion as expected.\n"));
54 catch (const CORBA::SystemException
& ex
)
56 ex
._tao_print_exception ("Reply_Handler::childMethod_excep: ");
60 CORBA::ULong
reply_count () { return parentMethod_count
+ parentMethod_excep_count
; };
63 // Count of replies and excep
64 CORBA::ULong parentMethod_count
;
65 CORBA::ULong parentMethod_excep_count
;
69 static const ACE_TCHAR
*server_ior
= ACE_TEXT("file://server.ior");
72 client_parse_args(int argc
, ACE_TCHAR
*argv
[])
75 get_opts(argc
, argv
, "f:");
78 while ((c
= get_opts()) != -1)
83 server_ior
= get_opts
.opt_arg();
89 "-f server IOR file\n"));
94 // Indicates successful parsing of the command line
99 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
105 // Initialize the ORB.
106 orb
= CORBA::ORB_init(argc
, argv
);
108 // Initialize options based on command-line arguments.
109 int parse_args_result
= client_parse_args(argc
, argv
);
110 if (parse_args_result
!= 0)
115 CORBA::Object_var object
=
116 orb
->resolve_initial_references ("RootPOA");
118 PortableServer::POA_var root_poa
=
119 PortableServer::POA::_narrow (object
.in ());
121 // Get an object reference from the nominated file
122 object
= orb
->string_to_object (server_ior
);
125 PortableServer::POAManager_var poa_manager
=
126 root_poa
->the_POAManager();
128 poa_manager
->activate();
130 Child_var child
= Child::_narrow (object
.in());
132 Reply_Handler reply_handler_servant
;
134 PortableServer::ObjectId_var id
=
135 root_poa
->activate_object (&reply_handler_servant
);
137 CORBA::Object_var object_act
= root_poa
->id_to_reference (id
.in ());
139 AMI_ChildHandler_var reply_handler_object
=
140 AMI_ChildHandler::_narrow (object_act
.in ());
142 // Invoke the AMI parentMethod
143 child
->sendc_parentMethod (reply_handler_object
.in ());
145 // Loop until all replies have been received.
146 while (reply_handler_servant
.reply_count () == 0)
148 orb
->perform_work ();
156 catch (const CORBA::Exception
& ex
)
158 ex
._tao_print_exception ("Exception caught:");