1 #include "Multiple_Impl.h"
2 #include "ace/Get_Opt.h"
3 #include "ace/OS_NS_stdio.h"
5 const ACE_TCHAR
*ior_output_file
= ACE_TEXT("test.ior");
8 parse_args (int argc
, ACE_TCHAR
*argv
[])
10 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
13 while ((c
= get_opts ()) != -1)
17 ior_output_file
= get_opts
.opt_arg ();
22 ACE_ERROR_RETURN ((LM_ERROR
,
29 // Indicates successful parsing of the command line
35 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
40 CORBA::ORB_var orb
= CORBA::ORB_init (argc
, argv
, "TAO");
42 CORBA::Object_var object
;
43 object
= orb
->resolve_initial_references ("RootPOA");
45 PortableServer::POA_var poa
= PortableServer::POA::_narrow(object
.in());
48 PortableServer::POAManager_var poa_manager
= poa
->the_POAManager();
50 if (parse_args (argc
, argv
) != 0)
53 // Create the servant.
54 Bottom_Impl
servant (orb
.in ());
56 // Create the delegated servant and intialize it
57 // with the "real" servant.
58 PortableServer::ObjectId_var id
= poa
->activate_object (&servant
);
59 CORBA::Object_var object_act
= poa
->id_to_reference (id
.in ());
60 Delegated_Bottom_Impl
delegated_servant(
61 Multiple::Bottom::_narrow (object_act
.in ()),
64 // Create the CORBA Object that is incarnated by the
66 id
= poa
->activate_object (&delegated_servant
);
67 object_act
= poa
->id_to_reference (id
.in ());
69 Multiple::Bottom_var bottom
=
70 Multiple::Bottom::_narrow (object_act
.in ());
72 // Now we stringify the object reference.
73 CORBA::String_var ior
=
74 orb
->object_to_string (bottom
.in ());
76 ACE_DEBUG ((LM_DEBUG
, "Activated as <%C>\n", ior
.in ()));
78 // If the ior_output_file exists, output the ior to it
80 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
83 ACE_ERROR_RETURN ((LM_ERROR
,
84 "Cannot open output file for writing IOR: %s",
87 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
88 ACE_OS::fclose (output_file
);
90 // Activate the POAManager
91 poa_manager
->activate();
95 catch (const CORBA::Exception
& ex
)
97 ex
._tao_print_exception (
98 "Multiple Execution Interrupted Exception!\n");