2 #include "ace/Get_Opt.h"
3 #include "ace/OS_NS_stdio.h"
6 const ACE_TCHAR
*ior_file
= 0;
9 parse_args (int argc
, ACE_TCHAR
*argv
[])
11 ACE_Get_Opt
get_opts (argc
, argv
, ACE_TEXT("o:c:n:s:"));
14 while ((c
= get_opts ()) != -1)
18 ior_file
= get_opts
.opt_arg ();
21 ACE_ERROR_RETURN ((LM_ERROR
,
32 ACE_TMAIN(int argc
, ACE_TCHAR
*argv
[])
37 CORBA::ORB_init (argc
, argv
, "Server ORB");
39 CORBA::Object_var poa_object
=
40 orb
->resolve_initial_references ("RootPOA");
42 if (CORBA::is_nil (poa_object
.in ()))
43 ACE_ERROR_RETURN ((LM_ERROR
,
44 " (%P|%t) Unable to initialize the POA.\n"),
47 PortableServer::POA_var root_poa
=
48 PortableServer::POA::_narrow (poa_object
.in ());
50 PortableServer::POAManager_var poa_manager
=
51 root_poa
->the_POAManager ();
53 if (::parse_args (argc
, argv
) != 0)
56 test_i
*test_impl
= 0;
57 ACE_NEW_RETURN (test_impl
, test_i (1, orb
.in ()), 1);
58 PortableServer::ServantBase_var
owner_transfer (test_impl
);
60 PortableServer::ObjectId_var id
=
61 root_poa
->activate_object (test_impl
);
63 CORBA::Object_var object
= root_poa
->id_to_reference (id
.in ());
65 RedirectionTest::test_var test
=
66 RedirectionTest::test::_narrow (object
.in ());
68 CORBA::String_var ior
=
69 orb
->object_to_string (test
.in ());
71 FILE *output_file
= ACE_OS::fopen (ior_file
, "w");
73 ACE_ERROR_RETURN ((LM_ERROR
,
74 "Cannot open output file <%s> for writing "
78 ACE_OS::fprintf (output_file
, "%s", ior
.in ());
79 ACE_OS::fclose (output_file
);
81 root_poa
->destroy (1, 1 );
85 ACE_DEBUG ((LM_DEBUG
, "Server event loop finished.\n"));
87 catch (const CORBA::Exception
& ex
)
89 ex
._tao_print_exception ("Caught exception:");