3 #include "tao/IORTable/IORTable.h"
4 #include "ace/OS_NS_stdio.h"
8 : ior_output_file_ (0),
14 Server_i::~Server_i ()
18 // Parse the command-line arguments and set options.
20 Server_i::parse_args ()
22 ACE_Get_Opt
get_opts (this->argc_
, this->argv_
, ACE_TEXT("do:ni:"));
25 while ((c
= get_opts ()) != -1)
28 case 'd': // debug flag.
31 case 'o': // output the IOR to a file.
32 this->ior_output_file_
= ACE_OS::fopen (get_opts
.opt_arg (), "w");
33 if (this->ior_output_file_
== 0)
34 ACE_ERROR_RETURN ((LM_ERROR
,
35 "Unable to open %s for writing: %p\n",
36 get_opts
.opt_arg ()), -1);
39 case 'i': // For Testing the InterOperable Naming Service.
40 this->ins_
= CORBA::string_dup (ACE_TEXT_ALWAYS_CHAR(get_opts
.opt_arg ()));
43 case '?': // display help for use of the server.
45 ACE_ERROR_RETURN ((LM_ERROR
,
48 " [-o] <ior_output_file>"
55 // Indicates successful parsing of command line.
59 // Add the ObjectID:IOR mapping to the IOR table of
63 Server_i::add_IOR_to_table (CORBA::String_var ior
)
67 if (TAO_debug_level
> 0)
69 "Adding (KEY:IOR) %C:%C\n",
73 CORBA::Object_var table_object
=
74 this->orb_manager_
.orb ()->resolve_initial_references (
77 IORTable::Table_var adapter
=
78 IORTable::Table::_narrow (table_object
.in ());
80 adapter
->bind (this->ins_
, ior
.in ());
82 catch (const CORBA::SystemException
& ex
)
84 ex
._tao_print_exception ("Exception caugh in add_IOR_to_table");
90 // Initialize the server.
92 Server_i::init (int argc
,
95 // Call the init of <TAO_ORB_Manager> to initialize the ORB and
96 // create a child POA under the root POA.
97 int result
= this->orb_manager_
.init_child_poa (argc
,
102 ACE_ERROR_RETURN ((LM_ERROR
,
110 int retval
= this->parse_args ();
115 CORBA::ORB_var orb
= this->orb_manager_
.orb ();
117 // Stash our ORB pointer for later reference.
118 this->servant_
.orb (orb
.in ());
122 CORBA::String_var str
=
123 this->orb_manager_
.activate_under_child_poa ("INS_servant",
126 ACE_DEBUG ((LM_DEBUG
,
127 "The IOR is: <%C>\n",
131 if (this->add_IOR_to_table (str
) != 0)
132 ACE_ERROR_RETURN ((LM_ERROR
,
133 "test_for_ins (): failed\n"),
136 if (this->ior_output_file_
)
138 ACE_OS::fprintf (this->ior_output_file_
,
141 ACE_OS::fclose (this->ior_output_file_
);
145 catch (const CORBA::Exception
& ex
)
147 ex
._tao_print_exception (
148 "\tException in activation of POA");
158 // Run the main event loop for the ORB.
159 int result
= this->orb_manager_
.run ();
162 ACE_ERROR_RETURN ((LM_ERROR
,