2 #include "MyInterfaceImpl.h"
3 #include "ace/Get_Opt.h"
4 #include "ace/OS_NS_stdio.h"
6 const ACE_TCHAR
*server_ior
= ACE_TEXT("");
7 const ACE_TCHAR
*ior_output_file
= ACE_TEXT("client.ior");
10 parse_args (int argc
, ACE_TCHAR
*argv
[])
12 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("k:"));
15 while ((c
= get_opts ()) != -1)
19 server_ior
= get_opts
.opt_arg ();
22 ior_output_file
= get_opts
.opt_arg ();
26 ACE_ERROR_RETURN ((LM_ERROR
,
33 // Indicates successful parsing of the command line
38 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
44 CORBA::ORB_init (argc
, argv
);
46 if (parse_args (argc
, argv
) != 0)
49 CORBA::Object_var poa_object
=
50 orb
->resolve_initial_references("RootPOA");
52 PortableServer::POA_var root_poa
=
53 PortableServer::POA::_narrow (poa_object
.in ());
55 if (CORBA::is_nil (root_poa
.in ()))
56 ACE_ERROR_RETURN ((LM_ERROR
,
57 " (%P|%t) Panic: nil RootPOA\n"),
60 PortableServer::POAManager_var poa_manager
=
61 root_poa
->the_POAManager ();
63 if (parse_args (argc
, argv
) != 0)
66 MyInterfaceImpl
*test_impl
;
67 ACE_NEW_RETURN (test_impl
,
68 MyInterfaceImpl (orb
.in ()),
71 PortableServer::ServantBase_var
owner_transfer(test_impl
);
73 PortableServer::ObjectId_var id
=
74 root_poa
->activate_object (test_impl
);
76 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
78 MyInterface_var test_ref
=
79 MyInterface::_narrow (object
.in ());
81 CORBA::String_var ior
=
82 orb
->object_to_string (test_ref
.in ());
84 // Output the IOR to the <ior_output_file>
85 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
88 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
89 ACE_OS::fclose (output_file
);
92 poa_manager
->activate ();
94 CORBA::Object_var tmp
=
95 orb
->string_to_object(server_ior
);
97 MyInterface_var server
=
98 MyInterface::_narrow(tmp
.in ());
100 if (CORBA::is_nil (server
.in ()))
102 ACE_ERROR_RETURN ((LM_DEBUG
,
103 "Nil server reference <%s>\n",
109 CORBA::Boolean temp
= server
->myMethod (MyInterfaceImpl::my_string
);
113 ACE_DEBUG ((LM_DEBUG
, "Test succeeded\n"));
117 ACE_DEBUG ((LM_ERROR
, "Test failed\n"));
121 //hello->shutdown ();
125 catch (const CORBA::Exception
& ex
)
127 ex
._tao_print_exception ("Exception caught:");