1 #include "ace/Get_Opt.h"
2 #include "ace/OS_NS_stdio.h"
5 #include "tao/IORTable/IORTable.h"
7 const ACE_TCHAR
*object_key
= 0;
8 const ACE_TCHAR
*ior_file
= ACE_TEXT ("server.ior");
11 parse_args (int argc
, ACE_TCHAR
*argv
[])
13 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:k"));
16 while ((c
= get_opts ()) != -1)
20 ior_file
= get_opts
.opt_arg ();
23 object_key
= get_opts
.opt_arg ();
27 ACE_ERROR_RETURN ((LM_ERROR
,
28 "SERVER (%P): usage: %s "
35 // Indicates successful parsing of the command line
40 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
45 CORBA::ORB_init (argc
, argv
);
47 CORBA::Object_var poa_object
=
48 orb
->resolve_initial_references ("RootPOA");
50 if (CORBA::is_nil (poa_object
.in ()))
51 ACE_ERROR_RETURN ((LM_ERROR
,
52 "SERVER (%P): Unable to initialize the POA.\n"),
55 PortableServer::POA_var root_poa
=
56 PortableServer::POA::_narrow (poa_object
.in ());
58 PortableServer::POAManager_var poa_manager
=
59 root_poa
->the_POAManager ();
61 if (parse_args (argc
, argv
) != 0)
64 Test_i
*server_impl
= 0;
65 ACE_NEW_RETURN (server_impl
,
68 PortableServer::ServantBase_var
owner_transfer(server_impl
);
70 PortableServer::ObjectId_var id
=
71 root_poa
->activate_object (server_impl
);
73 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
75 CORBA::Object_var server
= CORBA::Object::_narrow (object
.in ());
77 CORBA::String_var ior
=
78 orb
->object_to_string (server
.in ());
80 CORBA::Object_var table_object
=
81 orb
->resolve_initial_references ("IORTable");
83 IORTable::Table_var adapter
=
84 IORTable::Table::_narrow (table_object
.in ());
86 adapter
->bind("Name-with-hyphens", ior
.in());
88 FILE *output_file
= ACE_OS::fopen (ior_file
, "w");
90 ACE_ERROR_RETURN ((LM_ERROR
,
91 "SERVER (%P): Cannot open output file "
92 "for writing IOR: %s",
95 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
96 ACE_OS::fclose (output_file
);
99 "SERVER (%P): Activated as file://%s\n",
102 poa_manager
->activate();
106 root_poa
->destroy (true, true);
110 catch (const CORBA::Exception
& ex
)
112 ex
._tao_print_exception ("SERVER (%P): Caught exception:");