2 #include "MyInterfaceImpl.h"
4 #include "ace/Get_Opt.h"
5 #include "ace/OS_NS_stdio.h"
6 #include "tao/IORTable/IORTable.h"
8 const ACE_TCHAR
*ior_output_file
= ACE_TEXT("server.ior");
9 const ACE_TCHAR
*client_ior
= ACE_TEXT("file://client.ior");
12 parse_args (int argc
, ACE_TCHAR
*argv
[])
14 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
17 while ((c
= get_opts ()) != -1)
21 client_ior
= get_opts
.opt_arg ();
24 ior_output_file
= get_opts
.opt_arg ();
29 ACE_ERROR_RETURN ((LM_ERROR
,
36 // Indicates successful parsing of the command line
41 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
46 CORBA::ORB_init (argc
, argv
);
48 CORBA::Object_var poa_object
=
49 orb
->resolve_initial_references("RootPOA");
51 PortableServer::POA_var root_poa
=
52 PortableServer::POA::_narrow (poa_object
.in ());
54 if (CORBA::is_nil (root_poa
.in ()))
55 ACE_ERROR_RETURN ((LM_ERROR
,
56 " (%P|%t) Panic: nil RootPOA\n"),
59 PortableServer::POAManager_var poa_manager
=
60 root_poa
->the_POAManager ();
62 if (parse_args (argc
, argv
) != 0)
65 MyInterfaceImpl
*test_impl
= 0;
66 ACE_NEW_RETURN (test_impl
,
67 MyInterfaceImpl (orb
.in ()),
70 PortableServer::ServantBase_var
owner_transfer(test_impl
);
72 PortableServer::ObjectId_var id
=
73 root_poa
->activate_object (test_impl
);
75 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
77 MyInterface_var test_ref
=
78 MyInterface::_narrow (object
.in ());
80 CORBA::String_var ior
=
81 orb
->object_to_string (test_ref
.in ());
83 // Output the IOR to the <ior_output_file>
84 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
87 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
88 ACE_OS::fclose (output_file
);
91 poa_manager
->activate ();
93 CORBA::Object_var table_object
=
94 orb
->resolve_initial_references ("IORTable");
96 IORTable::Table_var adapter
=
97 IORTable::Table::_narrow (table_object
.in ());
99 if (CORBA::is_nil (adapter
.in ()))
101 ACE_ERROR ((LM_ERROR
, "Nil IORTable\n"));
105 adapter
->bind ("collocated_ior_bound_in_remote_iortable",
106 ACE_TEXT_ALWAYS_CHAR(client_ior
));
111 ACE_DEBUG ((LM_DEBUG
, "(%P|%t) server - event loop finished\n"));
113 root_poa
->destroy (true, true);
117 catch (const CORBA::Exception
& ex
)
119 ex
._tao_print_exception ("Exception caught:");