2 //=============================================================================
6 * This class implements a simple server for the
7 * Nested Upcalls - Triangle test.
9 * @author Michael Kircher
11 //=============================================================================
15 #include "tao/debug.h"
16 #include "ace/OS_NS_stdio.h"
18 Object_B_Server::Object_B_Server (void)
19 : ior_output_file_ (0)
24 Object_B_Server::parse_args (void)
26 ACE_Get_Opt
get_opts (argc_
, argv_
, ACE_TEXT("do:"));
29 while ((c
= get_opts ()) != -1)
32 case 'd': // debug flag.
35 case 'o': // output the IOR to a file.
36 this->ior_output_file_
= ACE_OS::fopen (get_opts
.opt_arg (), "w");
37 if (this->ior_output_file_
== 0)
38 ACE_ERROR_RETURN ((LM_ERROR
,
39 "Unable to open %s for writing: %p\n",
40 get_opts
.opt_arg ()), -1);
44 ACE_ERROR_RETURN ((LM_ERROR
,
47 " [-o] <ior_output_file>"
53 // Indicates successful parsing of command line.
58 Object_B_Server::init (int argc
,
61 // Call the init of TAO_ORB_Manager to create a child POA
62 // under the root POA.
63 this->orb_manager_
.init_child_poa (argc
,
71 // ~~ check for the return value here
73 CORBA::String_var str
=
74 this->orb_manager_
.activate_under_child_poa ("object_B",
77 if (this->ior_output_file_
)
79 ACE_OS::fprintf (this->ior_output_file_
,
82 ACE_OS::fclose (this->ior_output_file_
);
90 Object_B_Server::run (void)
92 int result
= this->orb_manager_
.run ();
95 ACE_ERROR_RETURN ((LM_ERROR
,
96 "Object_B_Server::run"),
102 Object_B_Server::~Object_B_Server (void)
107 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
109 Object_B_Server object_B_Server
;
111 ACE_DEBUG ((LM_DEBUG
,
112 "\n \t NestedUpCalls.Triangle_Test: Object B Server \n\n"));
116 int retval
= object_B_Server
.init (argc
, argv
);
122 object_B_Server
.run ();
125 catch (const CORBA::SystemException
& sysex
)
127 sysex
._tao_print_exception ("System Exception");
130 catch (const CORBA::UserException
& userex
)
132 userex
._tao_print_exception ("User Exception");