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
));
44 parentMethod_excep (Messaging::ExceptionHolder
* excep_holder
)
48 ++parentMethod_excep_count
;
49 excep_holder
->raise_exception ();
51 catch (const CORBA::INTERNAL
&)
53 ACE_DEBUG ((LM_DEBUG
, "Successfully received an Internal Excep*ion as expected.\n"));
55 catch (const CORBA::SystemException
& ex
)
57 ex
._tao_print_exception ("Reply_Handler::childMethod_excep: ");
61 CORBA::ULong
reply_count (void) { return parentMethod_count
+ parentMethod_excep_count
; };
64 // Count of replies and excep
65 CORBA::ULong parentMethod_count
;
66 CORBA::ULong parentMethod_excep_count
;
70 static const ACE_TCHAR
*server_ior
= ACE_TEXT("file://server.ior");
73 client_parse_args(int argc
, ACE_TCHAR
*argv
[])
76 get_opts(argc
, argv
, "f:");
79 while ((c
= get_opts()) != -1)
84 server_ior
= get_opts
.opt_arg();
90 "-f server IOR file\n"));
95 // Indicates successful parsing of the command line
100 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
107 // Initialize the ORB.
108 orb
= CORBA::ORB_init(argc
, argv
);
110 // Initialize options based on command-line arguments.
111 int parse_args_result
= client_parse_args(argc
, argv
);
112 if (parse_args_result
!= 0)
117 CORBA::Object_var object
=
118 orb
->resolve_initial_references ("RootPOA");
120 PortableServer::POA_var root_poa
=
121 PortableServer::POA::_narrow (object
.in ());
123 // Get an object reference from the nominated file
124 object
= orb
->string_to_object (server_ior
);
127 PortableServer::POAManager_var poa_manager
=
128 root_poa
->the_POAManager();
130 poa_manager
->activate();
132 Child_var child
= Child::_narrow (object
.in());
134 Reply_Handler reply_handler_servant
;
136 PortableServer::ObjectId_var id
=
137 root_poa
->activate_object (&reply_handler_servant
);
139 CORBA::Object_var object_act
= root_poa
->id_to_reference (id
.in ());
141 AMI_ChildHandler_var reply_handler_object
=
142 AMI_ChildHandler::_narrow (object_act
.in ());
144 // Invoke the AMI parentMethod
145 child
->sendc_parentMethod (reply_handler_object
.in ());
147 // Loop until all replies have been received.
148 while (reply_handler_servant
.reply_count () == 0)
150 orb
->perform_work ();
158 catch (const CORBA::Exception
& ex
)
160 ex
._tao_print_exception ("Exception caught:");