1 #include "TestCallback.h"
2 #include "ace/Get_Opt.h"
4 const ACE_TCHAR
*ior
= ACE_TEXT ("file://test.ior");
7 parse_args (int argc
, ACE_TCHAR
*argv
[])
9 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
12 while ((c
= get_opts ()) != -1)
16 ior
= get_opts
.opt_arg ();
21 ACE_ERROR_RETURN ((LM_ERROR
,
28 // Indicates successful parsing of the command line
33 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
37 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
);
39 CORBA::Object_var poa_object
=
40 orb
->resolve_initial_references("RootPOA");
42 PortableServer::POA_var root_poa
=
43 PortableServer::POA::_narrow (poa_object
.in ());
45 if (CORBA::is_nil (root_poa
.in ()))
46 ACE_ERROR_RETURN ((LM_ERROR
,
47 " (%P|%t) Panic: nil RootPOA\n"),
50 PortableServer::POAManager_var poa_manager
= root_poa
->the_POAManager ();
52 if (parse_args (argc
, argv
) != 0)
55 // Create client callback CORBA object
57 TestCallback
*test_impl
= 0;
58 ACE_NEW_RETURN (test_impl
,
59 TestCallback (orb
.in()),
61 PortableServer::ServantBase_var
owner_transfer(test_impl
);
63 PortableServer::ObjectId_var id
=
64 root_poa
->activate_object (test_impl
);
66 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
68 Test::TestCallback_var client
= Test::TestCallback::_narrow (object
.in ());
70 poa_manager
->activate ();
72 // Get server CORBA object and call it
74 CORBA::Object_var tmp
= orb
->string_to_object(ior
);
76 Test::TestServer_var server
= Test::TestServer::_narrow(tmp
.in ());
78 if (CORBA::is_nil (server
.in ()))
80 ACE_ERROR_RETURN ((LM_DEBUG
,
81 "Nil Test::TestServer reference <%s>\n",
86 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) client - calling server\n"));
87 server
->pass_callback (client
.in());
89 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) client - call failed to block\n"));
91 catch (const CORBA::Exception
& ex
)
93 ex
._tao_print_exception ("Exception caught:");
97 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) client - not stopped by server\n"));