3 #include "ace/OS_NS_unistd.h"
4 #include "ace/Get_Opt.h"
6 const ACE_TCHAR
*hostname
= ACE_TEXT ("localhost");
7 const ACE_TCHAR
*port
= ACE_TEXT ("12345");
10 : public POA_AMI_test::AMI_adderHandler
,
11 public ACE_Task_Base
{
13 AdderCallback(CORBA::ORB_ptr orb
)
14 : orb(CORBA::ORB::_duplicate(orb
)) {
19 CORBA::Long ami_return_val
22 ACE_DEBUG ((LM_DEBUG
, "Return value: %d\n", ami_return_val
));
25 virtual void add_excep (
26 ::Messaging::ExceptionHolder
*
29 ACE_DEBUG ((LM_DEBUG
, "Caught exception in _excep\n"));
42 parse_args (int argc
, ACE_TCHAR
*argv
[])
44 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("h:p:"));
47 while ((c
= get_opts ()) != -1)
51 hostname
= get_opts
.opt_arg ();
54 port
= get_opts
.opt_arg ();
58 ACE_ERROR_RETURN ((LM_ERROR
,
66 // Indicates successful parsing of the command line
71 int ACE_TMAIN (int argc
, ACE_TCHAR
* argv
[]) {
72 ACE_TCHAR address_servant
[1000];
75 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
77 if (parse_args (argc
, argv
) != 0)
79 // Get reference to Root POA
81 = orb
->resolve_initial_references ("RootPOA");
83 PortableServer::POA_var rootPOA
= PortableServer::POA::_narrow (obj
.in ());
85 // Activate POA manager
86 PortableServer::POAManager_var mgr
87 = rootPOA
->the_POAManager ();
91 ACE_OS::sprintf(address_servant
, ACE_TEXT("corbaloc:iiop:%s:%s/Adder"), hostname
, port
);
93 // Resolve Adder Reference
94 obj
= orb
->string_to_object(ACE_TEXT_ALWAYS_CHAR(address_servant
));
95 AMI_test::adder_var adder
= AMI_test::adder::_narrow(obj
.in ());
97 AdderCallback
cb_servant(orb
.in ());
102 adder
->sendc_add(cb_servant
._this(), 3, 2);
106 ACE_ERROR ((LM_ERROR
, "ERROR: Caught exception after sendc_add\n"));
113 ACE_ERROR ((LM_ERROR
, "ERROR: Caught exception in main\n"));