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
42 CORBA::ORB_init (argc
, argv
);
44 CORBA::Object_var poa_object
=
45 orb
->resolve_initial_references("RootPOA");
47 PortableServer::POA_var root_poa
=
48 PortableServer::POA::_narrow (poa_object
.in ());
50 if (CORBA::is_nil (root_poa
.in ()))
51 ACE_ERROR_RETURN ((LM_ERROR
,
52 " (%P|%t) Panic: nil RootPOA\n"),
55 PortableServer::POAManager_var poa_manager
=
56 root_poa
->the_POAManager ();
58 if (parse_args (argc
, argv
) != 0)
61 test_i
*test_impl
= 0;
62 ACE_NEW_RETURN (test_impl
,
65 PortableServer::ServantBase_var
owner_transfer (test_impl
);
67 PortableServer::ObjectId_var id
=
68 root_poa
->activate_object (test_impl
);
70 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
73 Hang::_narrow (object
.in ());
75 CORBA::String_var ior
=
76 orb
->object_to_string (test
.in ());
78 // If the ior_output_file exists, output the ior to it
79 FILE *output_file
= ACE_OS::fopen (ior_output_file
, "w");
81 ACE_ERROR_RETURN ((LM_ERROR
,
82 "Cannot open output file for writing IOR: %s",
85 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
86 ACE_OS::fclose (output_file
);
88 poa_manager
->activate ();
90 ACE_Time_Value
tv (10);
95 "(%P|%t) server - event loop finished\n"));
97 root_poa
->destroy (true, true);
101 catch (const CORBA::Exception
& ex
)
103 ex
._tao_print_exception ("Caught CORBA exception\n");
112 ACE_TMAIN (int argc
, ACE_TCHAR
*argv
[])
114 return Test::try_main (argc
, argv
);