2 #include "ace/Get_Opt.h"
3 #include "ace/OS_NS_stdio.h"
7 const ACE_TCHAR
*ior_output_file
= ACE_TEXT("server.ior");
10 parse_args (int argc
, ACE_TCHAR
*argv
[])
12 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:"));
15 while ((c
= get_opts ()) != -1)
19 ior_output_file
= get_opts
.optarg
;
24 ACE_ERROR_RETURN ((LM_ERROR
,
31 // Indicates successful parsing of the command line
43 CORBA::ORB_init (argc
, argv
);
45 CORBA::Object_var poa_object
=
46 orb
->resolve_initial_references("RootPOA");
48 PortableServer::POA_var root_poa
=
49 PortableServer::POA::_narrow (poa_object
.in ());
51 if (CORBA::is_nil (root_poa
.in ()))
52 ACE_ERROR_RETURN ((LM_ERROR
,
53 " (%P|%t) Panic: nil RootPOA\n"),
56 PortableServer::POAManager_var poa_manager
=
57 root_poa
->the_POAManager ();
59 if (parse_args (argc
, argv
) != 0)
62 test_i
*test_impl
= 0;
63 ACE_NEW_RETURN (test_impl
,
66 PortableServer::ServantBase_var
owner_transfer (test_impl
);
68 PortableServer::ObjectId_var id
=
69 root_poa
->activate_object (test_impl
);
71 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
74 Hang::_narrow (object
.in ());
76 CORBA::String_var ior
=
77 orb
->object_to_string (test
.in ());
79 // If the ior_output_file exists, output the ior to it
80 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
82 ACE_ERROR_RETURN ((LM_ERROR
,
83 "Cannot open output file for writing IOR: %s",
86 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
87 ACE_OS::fclose (output_file
);
89 poa_manager
->activate ();
91 ACE_Time_Value
tv (10);
96 "(%P|%t) server - event loop finished\n"));
98 root_poa
->destroy (1, 1);
102 catch (const CORBA::Exception
& ex
)
104 ex
._tao_print_exception ("Caught CORBA exception\n");
113 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
115 return Test::try_main (argc
, argv
);